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

nobody@nowhere.com nobody@nowhere.com
Tue, 20 Aug 2002 08:43:03 -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"
        secs_per_day=24*60*60
        session=context.REQUEST.SESSION
        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']
            now=context.ZopeTime()
            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.

         SL