[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Basic Zope Objects
Fri, 06 Dec 2002 13:51:15 -0500
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/BasicObject.stx#3-241
Here's an example of how to work with a session using a
## Script (Python) "lastView"
if session.has_key('last view'):
# The script has been viewed before, since the 'last view'
# has been previously set in the session.
session['last view']=now # reset last view to now
return 'Seconds since last view %.2f' % ((now - then) * secs_per_day)
# The script hasn't been viewed before, since there's no 'last
# view' in the session data.
return 'This is your first view'
% Anonymous User - Aug. 20, 2002 8:43 am:
As far as I remember, "context" as in context.REQUEST.SESSION has not yet been discussed.
For the sake of understanding a sentence on "context" might be in order.
% Anonymous User - Aug. 27, 2002 7:16 am:
Is it also possible to use container.REQUEST.SESSION in order to connect to the Session-Scope?! And what is
the exact difference between 'context' and 'container'?
% Anonymous User - Aug. 29, 2002 11:00 am:
This is the object on which the script is being called, also known as the "acquisition parent" of the script.
This may be the container, but varies according to the path through which the script is accessed.
This is the Folder "Auto Lunch Order", in which this script is located. This doesn't change unless you move
the script. If the script is in a ZClass, the Container is the class instance.
Remember how we used a DTML method from root in a subfolder? Root would be the container, while the subfolder
is the context.
% Anonymous User - Dec. 6, 2002 1:51 pm:
Something need to be "imported from".
Error Type: NameError
Error Value: global name 'SessionIdManagerErr' is not defined