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

Changeset 394

Show
Ignore:
Timestamp:
06/28/05 21:57:50
Author:
mikerobi
Message:

qlobject adaptor should cleanup \n sqlobject sessions should clean up now

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/config.py

    r392 r394  
    208208     
    209209    serverVars = [ 
    210                 'server.environment', 
    211                 'server.logToScreen', 
    212                 'server.logFile', 
    213                 'server.protocolVersion', 
    214                 'server.socketHost', 
    215                 'server.socketPort', 
    216                 'server.socketFile', 
    217                 'server.reverseDNS', 
    218                 'server.socketQueueSize', 
    219                 'server.threadPool' 
    220              
     210                  'server.environment', 
     211                  'server.logToScreen', 
     212                  'server.logFile', 
     213                  'server.protocolVersion', 
     214                  'server.socketHost', 
     215                  'server.socketPort', 
     216                  'server.socketFile', 
     217                  'server.reverseDNS', 
     218                  'server.socketQueueSize', 
     219                  'server.threadPool' 
     220                 
    221221 
    222222    for var in serverVars: 
  • trunk/cherrypy/lib/filter/sessionfilter/sqlobjectadaptor.py

    r392 r394  
    2929import cherrypy 
    3030from cherrypy import _cputil 
    31 from basesession import BaseSession 
     31from baseadaptor import BaseSession 
    3232from sessionerrors import * 
    3333 
     
    3535from basesessiondict import BaseSessionDict 
    3636 
     37import time 
    3738 
    3839class SQLObjectSessionDict(BaseSessionDict): 
     
    118119     
    119120    def cleanUpOldSessions(self): 
    120         # running a single query would be a huge performace boost 
    121         pass 
     121        # print cleaning up sql sessions 
     122        now = time.time() 
     123        for session in Session.select( ((now - Session.q.last_access) < Session.q.timeout) ): 
     124            Session.delete(session.id) 
  • trunk/docs/book/xml/sessions.xml

    r373 r394  
    77  <abstract> 
    88    <para> 
    9       CherryPy 2.1 includes a powerful sessions system provided via a new "sessionFilter". 
    10       The old sessions system was difficult to extend and was not thread safe, while the 
    11       new system addresses these issues and includes several powerful new features. 
     9      CherryPy 2.1 includes a powerful sessions system provided via 
     10      a new "sessionFilter".  The old sessions system was difficult 
     11      to extend and was not thread safe.  The new system addresses  
     12      these issues and includes several powerful new features. 
    1213    </para> 
    1314  </abstract> 
     
    3334      <title>SessionDicts</title> 
    3435      <para> 
    35         All session data is accessed through an instance of a SessionDict class. 
    36         SesssionDicts provide a dictionary like interface. 
     36        All session data is accessed through an instance of 
     37        a SessionDict class.  SesssionDicts provide a dictionary 
     38        like interface. 
    3739      </para> 
    3840 
     
    99101    </section> <!-- end of cpg.sessions section --> 
    100102     
    101     <section> <!-- _cpSessionList section --> 
    102       <title>_cpSessionsList</title> 
    103       <para> 
    104         Named sessions are created by placing an entry into _cpSessionsList. 
    105         _cpSessionsList is a special class attribute containing a list of 
    106         sessions defined for that particular class. 
    107       </para> 
     103    <section> <!-- session configuration --> 
     104      <title>Session Configuration</title> 
     105      <itemizedlist> 
     106        <listitem> 
     107          <section> 
     108            <title>sessionFilter.on</title> 
     109            <para> 
     110              Can be True or False.  Will toggle on/off all sessions within the current path. 
     111              By default the session filter is turned off. 
     112            </para> 
     113          </section> 
     114        </listitem> 
     115         
     116        <listitem> 
     117          <section> 
     118            <title>sessionFilter.sessionList</title> 
     119            <para> 
     120              The sessionsList is the most important configuration setting for the session filter. 
     121              The sessionsList is a python list containing an entry for every named session. 
     122              Careless changes to the sessionsList are likely to break the application, so the 
     123              sessionsList should only be modified from within application code, and not from  
     124              the configuration file. 
     125            </para> 
     126          </section> 
     127        </listitem> 
     128      </itemizedlist> 
     129       
     130      <para> 
     131        These settings are common to all storage types. 
     132      </para> 
     133       
     134      <itemizedlist> 
     135        <listitem> 
     136          <section> 
     137            <title>sessionFilter.sessionName.on</title> 
     138            <para> 
     139              Can be True or False.  Will toggle on/off a specific named session.  The setting 
     140              only affects individual sessions, the sessionfilter must still be turned on using 
     141              sessionFilter.on. 
     142            </para> 
     143          </section> 
     144        </listitem> 
     145         
     146        <listitem> 
     147          <section> 
     148            <title>sessionFilter.sessionName.storageType</title> 
     149            <para> 
     150              The storagType is the string name of the storage type for sessionName. 
     151              The built in storageType are: 'ram', 'file', 'anydb', 'sqlobject'.  If the  
     152              storageType does not match one of the built in storage adaptors a special attribute 
     153              look up is performed.  If ommited the storageType will default to 'ram'. 
     154            </para> 
     155          </section> 
     156        </listitem> 
     157 
     158        <listitem> 
     159          <section> 
     160            <title>sessionFilter.sessionName.timeout</title> 
     161            <para> 
     162              The number of minutes of inactivity before an individual session can be removed. 
     163            </para> 
     164          </section> 
     165        </listitem> 
     166 
     167        <listitem> 
     168          <section> 
     169            <title>sessionFilter.sessionName.cleanUpDelay</title> 
     170            <para> 
     171              The number of minutes to wait before cleaning up old sessions. 
     172            </para> 
     173          </section> 
     174        </listitem> 
     175 
     176        <listitem> 
     177          <section> 
     178            <title>sessionFilter.sessionName.cookiePrefix</title> 
     179            <para> 
     180              The cookiePrefix is prepended to the beginning of every session cookie name. 
     181            </para> 
     182          </section> 
     183        </listitem> 
     184 
     185      </itemizedlist> 
    108186      <example> 
    109         <title>_cpSessionList</title> 
     187        <title>Session Configuration</title> 
    110188        <para> 
    111189        </para> 
     
    113191          class MyBBS: 
    114192              # create a session named 'admin' using the SessionStorageClass 
    115               _cpSessionList = [SessionStorageClass(sessionName = 'admin')] 
    116  
     193              def __init__(self): 
     194                  cpg.config.update({ 
     195                                      'global'    : { 'sessionFilter.on' : True }, 
     196                                      '/site/bbs' : { 
     197                                                      'sessionFilter.sessionsList'    : ['bbs'], 
     198                                                      'sessionFilter.bbs.storageType' : 'ram', 
     199                                                      'sessionFilter.bbs.timeout'     : 25 
     200                                                    } 
     201                                   }) 
    117202              def admin(self): 
    118203                  if cpg.session.admin['user'] != "root": 
    119                       return "you are not root" 
     204                  return "you are not root" 
     205              admin.exposed = True 
    120206        </programlisting> 
    121207      </example> 
    122     </section> <!-- end _cpSessionList section --> 
     208    </section> <!-- end sessionconfiguration --> 
    123209       
    124210  </section> 
     
    157243      <title>Relational Storage</title> 
    158244      <para> 
    159         With relational database drivers, all data is stored in a relational database table.  Due to the nature of 
    160         relational databases, there are several restrictions on how data can be stored.  Each session 
    161         is stored as a single row in the session table.  The session table must be created with a column 
    162         for each variable needed by the application.  This makes it impossible to store arbitrary key/value pairs,  
    163         as can be done using several of the other storage drivers.  In addition, relational databases also place 
    164         restrictions on the type of data that can be stored in each column.  Attempting to store the wrong 
    165         type of data in a session variable will result in an error. 
    166       </para> 
    167        
    168       <para> 
    169         Despite these restrictions, storing session data in relational database has many advantages. 
    170         This approach allows session data to be integrated into an existing relational database, which 
    171         dynamic web applications often use anyway.  This approach allows for a level of scalability not possible 
    172         with other storage drivers.  In addition, by using a networked database server, session data can be easily 
    173         shared between a cluster of web servers. 
     245        With relational database drivers, all data is stored in a relational  
     246        database table.  Due to the nature of relational databases, there are several 
     247        restrictions on how data can be stored.  Each session is stored as a single  
     248        row in the session table.  The session table must be created with a column for 
     249        each variable needed by the application.  This makes it impossible to store arbitrary 
     250        key/value pairs, as can be done using several of the other storage drivers.   
     251        In addition, relational databases also place restrictions on the type of data  
     252        that can be stored in each column.  Attempting to store the wrong type of data  
     253        in a session variable will result in an error. 
     254      </para> 
     255       
     256      <para> 
     257        Despite these restrictions, storing session data in relational database has many 
     258        advantages.  This approach allows session data to be integrated into an existing 
     259        relational database, which dynamic web applications often use anyway.  This approach 
     260        allows for a level of scalability not possible with other storage drivers. In addition,  
     261        by using a networked database server, session data can be easily shared between a  
     262        cluster of web servers. 
    174263      </para> 
    175264 

Hosted by WebFaction

Log in as guest/cpguest to create tickets