[ 
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.

Reply via email to