I have problems with the FSSession product (0.4.2) http://www.zope.org/Members/gaaros/FSSession Firstly, I rename the FSSession object to prevent naming confusion. ------ index_html --------------------------- <dtml-call changesSession> <dtml-var "_.str(changesSession)"> <!-- this returns: oldvariablesinceyesterday = "peppe" --> <dtml-call "changesSession.set('name','peter')"> <dtml-var "_.str(changesSession)"> <!-- this returns: oldvariablesinceyesterday = "peppe" name = "peter" --> <dtml-call changesSession> <dtml-var "_.str(changesSession)"> <!-- this returns: oldvariablesinceyesterday = "peppe" --> ------ /index_html --------------------------- Did you see what happened?? I lost a variable I managed to set as a cookie when calling the FSSession object again towards the bottom! Why this? How to prevent it? What I do in reality (the above pseudo) is that in standard_html_header I call the FSSession object and then use it to display custom Stylesheets. Then I call the FSSession object again to use it in standard_html_footer to use it to display different footers. The <dtml-call FSSession> is vital to be able to begin to use it, but why isn't it enough just to do it once in standard_html_header in a code like this: <dtml-var standard_html_header> <h1>A Page</h1> <dtml-var standard_html_footer> One simple alternative is to set a REQUEST variable in standard_html_header and use that instead of using the object in the standard_html_footer Welcoming some Zopezen Peter
Peter Bengtsson writes:
Did you see what happened?? I lost a variable I managed to set as a cookie when calling the FSSession object again towards the bottom! Why this? How to prevent it?
What I do in reality (the above pseudo) is that in standard_html_header I call the FSSession object and then use it to display custom Stylesheets. Then I call the FSSession object again to use it in standard_html_footer to use it to display different footers.
The <dtml-call FSSession> is vital to be able to begin to use it, but why isn't it enough just to do it once in standard_html_header in a code like this: <dtml-var standard_html_header> <h1>A Page</h1> <dtml-var standard_html_footer>
One simple alternative is to set a REQUEST variable in standard_html_header and use that instead of using the object in the standard_html_footer
Hello Peter You are supposed to call FSSession only once which initializes it for the whole transaction. Just don't call it again in 'standard_html_footer'. FSsession commits its data at the end of the transaction. By calling it again in 'standard_html_footer' you force it to reread its data before it had the chance to commit its old state. Let me know if it works. Maybe I should ignore additional calls to FSSession if they occur in the same transaction. Pavlos PS I am no longer on the 'zope' list so continue emailing me directly if you still have problems.
Peter Bengtsson writes:
Did you see what happened?? I lost a variable I managed to set as a
cookie
when calling the FSSession object again towards the bottom! Why this? How to prevent it?
What I do in reality (the above pseudo) is that in standard_html_header I call the FSSession object and then use it to display custom Stylesheets. Then I call the FSSession object again to use it in standard_html_footer to use it to display different footers.
The <dtml-call FSSession> is vital to be able to begin to use it, but why isn't it enough just to do it once in standard_html_header in a code like this: <dtml-var standard_html_header> <h1>A Page</h1> <dtml-var standard_html_footer>
You are supposed to call FSSession only once which initializes it for the whole transaction. Just don't call it again in 'standard_html_footer'. FSsession commits its data at the end of the transaction. By calling it again in 'standard_html_footer' you force it to reread its data before it had the chance to commit its old state.
Let me know if it works. Maybe I should ignore additional calls to FSSession if they occur in the same transaction.
I HAVE to call the FSSession object twice. Since I view only index_html, it uses the call of standard_html_header. standard_html_footer is called by index_html included into index_html I can't really explain it but standard_html_footer appear to be "independent" of standard_html_header (where the FSSession call occurs). Only the REQUEST object spans between both standard_html_header and standard_html_footer. What I would like to be able to do (see it as a bug report/feature request) is to call it and standard_html_header and still have it standard_html_footer with index_html as the link. Peter
Peter Bengtsson writes:
... FSSession initialized twice ==> bindings lost ... That's quite normal.
We use a small DTML Method for initialization: "initializeSession" <dtml-unless SessionInitialized__> <dtml-call FSSession> <dtml-call "REQUEST.set('SessionInitialized__',1)"> </dtml-unless> This way, we can call "initializeSession" whenever we think, we may access session data without worring whether it has already been done. Dieter
Thank you. I took it. I still think the FSSession should have a check for it so that you don't have to care in your Python Scripts or DTML *. BTW, why do you name your variable with two __ underscores? In python, I thought only the underscores in the begin matters (more or less). Just curious. Cheers, Peter
<dtml-unless SessionInitialized__> <dtml-call FSSession> <dtml-call "REQUEST.set('SessionInitialized__',1)"> </dtml-unless>
This way, we can call "initializeSession" whenever we think, we may access session data without worring whether it has already been done.
Dieter
Peter Bengtsson writes:
BTW, why do you name your variable with two __ underscores? In python, I thought only the underscores in the begin matters (more or less). Just curious. Namespaces in Zope are quite global. As a result, there is a high risk of name collisions. Decorating internally used names with appropriate name parts reduces the risk of collisions with other bindings in the various namespaces.
Dieter
participants (3)
-
Dieter Maurer -
pavlos@gaaros.com -
Peter Bengtsson