Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 278

Show
Ignore:
Timestamp:
06/11/05 09:03:43
Author:
mikerobi
Message:

fixed tut10, changed CHERRRYPYTEAM link

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHERRYPYTEAM.txt

    r229 r278  
    1 See http://trac.cherrypy.org/cgi-bin/trac.cgi/wiki/CherryPyTeam 
     1See http://trac.cherrypy.org/wiki/CherryPyTeam 
  • trunk/cherrypy/tutorial/tut10_sessionfilter.py

    r275 r278  
    11""" 
    2 Tutorial 08 - Sessions 
    3  
    4 Storing session data in CherryPy applications is very easy: cpg.request 
    5 provides a dictionary called sessionMap that represents the session 
    6 data for the current user. If you use RAM based sessions, you can store 
    7 any kind of object into that dictionary; otherwise, you are limited to 
    8 objects that can be pickled. 
     2Tutorial 10 - Advanced sessionFilter usage see tut10_sessionfilter.conf 
    93""" 
    104 
     
    2317        yield '\n</body></html>' 
    2418 
    25     samplePages = ['admin', 'index', 'forum', 'sqlobject'
     19    samplePages = ['admin', 'index', 'forum'
    2620 
    2721    def admin(self): 
     
    4741 
    4842        # Store the new value in the session dictionary 
     43        # cpg.sessions.sessionMap is available by default 
    4944        cpg.sessions.sessionMap['count'] = count 
    5045 
     
    5550    index.exposed = True 
    5651 
     52    # these functions do the same as the index but with a different session dictionary 
     53    def admin(self): 
     54        adminCount = cpg.sessions.adminSession.get('adminCount', 0) + 1 
     55        cpg.sessions.adminSession['adminCount'] = adminCount 
     56         
     57        key = cpg.sessions.adminSession.key 
     58        return self.__examplePage('ram', adminCount, self.samplePages, key) 
     59 
     60    admin.exposed = True 
     61     
     62    def forum(self): 
     63        forumCount = cpg.sessions.forumSession.get('forumCount', 0) + 1 
     64        cpg.sessions.forumSession['forumCount'] = forumCount 
     65         
     66        key = cpg.sessions.forumSession.key 
     67        return self.__examplePage('ram', forumCount, self.samplePages, key) 
     68    forum.exposed=True 
     69 
    5770cpg.root = HitCounter() 
    5871 

Hosted by WebFaction

Log in as guest/cpguest to create tickets