[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Basic Zope Objects

nobody@nowhere.com nobody@nowhere.com
Tue, 27 Aug 2002 07:16:46 -0400

A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/BasicObject.stx#3-187


      Here's an example of how to work with a session using a
      Python-based Script::

        ## 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.
            then=session['last view']
            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. 
        session['last view']=context.ZopeTime()
        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'?