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

Changeset 318

Show
Ignore:
Timestamp:
06/15/05 15:53:15
Author:
mikerobi
Message:

some session documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/docs/xml/sessions.xml

    r313 r318  
    44         xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    55         xml:id="sessions"> 
    6   <title>Sessions</title> 
     6  <title>Sessions Management</title> 
     7  <abstract> 
     8    <para> 
     9      CherryPY2.1 Includes a powerfull new sessionFilter. 
     10      The old session system was difficult to extend and was not thread safe.   
     11      The new system adresses these issues and includes several powerfull new features. 
     12    </para> 
     13  </abstract> 
     14   
     15  <section id="sessionfeaturs"> 
     16    <title>Session Features</title> 
     17    <itemizedlist> 
     18      <listitem>Multiple Storage Types</listitem> 
     19      <listitem>Thread Safety</listitem> 
     20      <listitem>Easy to extend</listitem> 
     21      <listitem>Session Caching<listitem> 
     22      <listitem>Multiple Named Sessions</listitem> 
     23    </itemizedlist> 
     24  </section> 
     25   
     26  <section id="sessionconfig"> 
     27    <title>Session Configuration</tile> 
     28  </section> 
     29 
     30  <section id="usingsessions"> 
     31    <title>Using Sessions</title> 
     32    <section> 
     33      <title>SessionDicts<title> 
     34      <para> 
     35        All session data is accessed through an instance of a SessionDict class. 
     36        SesssionDicts provide a dictionary like interface. 
     37      </para> 
     38 
     39      <para> 
     40        The following dictionary methods are provided: 
     41        <itemizedlist> 
     42          <listitem>__setitem__(key, value)</listitem> 
     43          <listitem>__getitem__</listitem> 
     44          <listitem>get(key, default)</listitem> 
     45        </itemizedlist> 
     46        SessionDicts also contain the following attributes: 
     47        <itemizedlist> 
     48          <listitem>sessionKey (read only)</listitem> 
     49          <listitem>lastAccess (read only)</listitem> 
     50          <listitem>createdAt  (read only)</listitem> 
     51          <listitem>timeout   </listitem> 
     52        </itemizedlist> 
     53      </para> 
     54    </section> <!-- end SessionDict section --> 
     55 
     56    <section> 
     57      <title>cpg.sessions</title> 
     58      <para> 
     59        cpg.sessions is the single point of access for all session data. 
     60        When each request is proccessed the sessionFilter looks for any sessions defined  
     61        for requested portion of the site.  For each named session, a SessionDict is created and  
     62        attached to cpg.sessions, as an attribute bearing the session name. 
     63      </para> 
     64       
     65      <para> 
     66      Given a session named "checkoutSession", all session data will be accessed through: 
     67      <blockqoute>cpg.sessions.checkoutSession</blockqoute> 
     68      </para> 
     69 
     70      <example> 
     71        <title>cpg.session example</title> 
     72        <para> 
     73          This code iterates over a list of items in a shopping cart, and computes  
     74          The total cost of all items. 
     75        </para> 
     76        <programlisting> 
     77          totalCost = 0.0 
     78           
     79          for item in cpg.sessions.checkoutSession['shoppingCart']: 
     80              totalCost += item.cost 
     81        </programlisting> 
     82      </example> 
     83 
     84 
     85      <section> 
     86        <title>The default session</title> 
     87        <para> 
     88          By defualt the session filter provide a session named "default",  
     89          which is accessed through "cpg.sessions.default". 
     90        </para> 
     91 
     92        <para> 
     93          Unless there is a clear advantage to having more that one named sessions,  
     94          the default session should be used to store all session data. 
     95          The default session may (in the future) optomized to provide better performance 
     96          than can be achived with named sessions. 
     97        </para> 
     98      </section> 
     99 
     100     
     101    </section> 
     102  </section> 
     103 
     104  <section id="sessionstoragetypes"> 
     105    <itemizedlist> 
     106      <listitem>ram</listitem> 
     107      <listitem>file</listitem> 
     108      <listitem>anydb</listitem> 
     109      <listitem>sqlobject</listitem> 
     110    </itemizedlist> 
     111  </section> 
     112 
     113  <section id="customsessionstorage"> 
     114    <title>Writing Custom Session Storage Drivers</title> 
     115  </section> 
     116 
    7117</section> 

Hosted by WebFaction

Log in as guest/cpguest to create tickets