You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Lars Trieloff (JIRA)" <ji...@apache.org> on 2007/10/20 01:07:50 UTC

[jira] Created: (SLING-73) Session is not saved for POST scripts nor is it made available to the script

Session is not saved for POST scripts nor is it made available to the script
----------------------------------------------------------------------------

                 Key: SLING-73
                 URL: https://issues.apache.org/jira/browse/SLING-73
             Project: Sling
          Issue Type: Bug
          Components: microsling
            Reporter: Lars Trieloff


POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-73) Session is not saved for POST scripts nor is it made available to the script

Posted by "Lars Trieloff (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars Trieloff updated SLING-73:
-------------------------------

    Attachment: POST.esp

An example script that modifies repository content.

> Session is not saved for POST scripts nor is it made available to the script
> ----------------------------------------------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Lars Trieloff (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536442 ] 

Lars Trieloff commented on SLING-73:
------------------------------------

I think the default behavior should be to save the session as this is what most people want to do.

As an additional convenience method I would add a save() and rollback() method to sling helper, so you can simply add a 

<% sling.save() %> at the end of every page,

or even better only a 

<% sling.rollback() %> 

if something went wrong, as I suppose a <% sling.save() %> is forgotten easily and will lead to lots of noise on the user mailing list.

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536439 ] 

fmeschbe edited comment on SLING-73 at 10/20/07 9:56 AM:
------------------------------------------------------------------

I do not actually want to save the session after the script has run - in fact I would prefer to rollback any unsafed changes when the scripted ended. The reason for this is, that only the script may decide whether changes must be save or not. And changes may remain unsafed due to unexpected script termination caused by any Throwable and such changes should of course not be saved.

Two points, which might help:

(1) You may also save the item you modified. So after resource.item.setProperty() you may call resource.item.save().

(2) the session is available as part of the SlingRequestContext which is availables as Packages.org.apache.sling.microsling.api.SlingRequestContext.Accessor.getSlingRequestContext(request).

I agree, that this is very ugly and unlucky. Therefore the SlingRequestContext will be provided as a global variable requestContext.

      was (Author: fmeschbe):
    I do not actually want to save the session after the script has run - in fact I would prefer to rollback any unsafed changes when the scripted ended.

Two points, which might help:

(1) You may also save the item you modified. So after resource.item.setProperty() you may call resource.item.save().

(2) the session is available as part of the SlingRequestContext which is availables as Packages.org.apache.sling.microsling.api.SlingRequestContext.Accessor.getSlingRequestContext(request).

I agree, that this is very ugly and unlucky. Therefore the SlingRequestContext will be provided as a global variable slingRequestContext.
  
> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned SLING-73:
--------------------------------------

    Assignee: Felix Meschberger

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-73) Session is not saved for POST scripts nor is it made available to the script

Posted by "Lars Trieloff (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars Trieloff updated SLING-73:
-------------------------------

    Attachment: microsling-save-session-on-post.patch

This patch saves the session after processing an unsafe request. Additionally it changes the javadoc to actually match the behavior of the code.

> Session is not saved for POST scripts nor is it made available to the script
> ----------------------------------------------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>         Attachments: microsling-save-session-on-post.patch
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated SLING-73:
-----------------------------------

    Description: 
POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

  was:POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

        Summary: Provided SlingRequestContext to scripts  (was: Session is not saved for POST scripts nor is it made available to the script)

Adapting issue summary to reflect the concrete request (as I understand it)

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-73) Session is not saved for POST scripts nor is it made available to the script

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536439 ] 

Felix Meschberger commented on SLING-73:
----------------------------------------

I do not actually want to save the session after the script has run - in fact I would prefer to rollback any unsafed changes when the scripted ended.

Two points, which might help:

(1) You may also save the item you modified. So after resource.item.setProperty() you may call resource.item.save().

(2) the session is available as part of the SlingRequestContext which is availables as Packages.org.apache.sling.microsling.api.SlingRequestContext.Accessor.getSlingRequestContext(request).

I agree, that this is very ugly and unlucky. Therefore the SlingRequestContext will be provided as a global variable slingRequestContext.

> Session is not saved for POST scripts nor is it made available to the script
> ----------------------------------------------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Lars Trieloff (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars Trieloff closed SLING-73.
------------------------------


Solves my immediate need, still I think we should discuss adopting the default behavior to the expectations of the user.

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-73.
------------------------------------

    Resolution: Fixed

Added the requestContext scripting variable providing the SlingRequestContext in Rev. 586757.

If this would solve your problem, please close. Thanks.

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-73) Provided SlingRequestContext to scripts

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536519 ] 

Felix Meschberger commented on SLING-73:
----------------------------------------

I agree, that this needs to be discussed. I therefore started a thread on the list [1]

[1] http://www.mail-archive.com/sling-dev@incubator.apache.org/msg00562.html

> Provided SlingRequestContext to scripts
> ---------------------------------------
>
>                 Key: SLING-73
>                 URL: https://issues.apache.org/jira/browse/SLING-73
>             Project: Sling
>          Issue Type: Bug
>          Components: microsling
>            Reporter: Lars Trieloff
>            Assignee: Felix Meschberger
>         Attachments: microsling-save-session-on-post.patch, POST.esp
>
>
> POST scripts (e.g. attached POST.js) cannot have side-effects because the session is not saved after processing the script. Unfortunately the session is not made available to the script so the script cannot save the session itself (which I would consider an ugly workaround).
> If the SlingRequestContext would be provided as a scripting variable, the session would be available and could be saved.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.