Django

Code

Changeset 6344

Show
Ignore:
Timestamp:
09/15/07 17:36:53 (1 year ago)
Author:
adrian
Message:

Edited docs/sessions.txt changes from [6333]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/sessions.txt

    r6333 r6344  
    1919      The default ``settings.py`` created by ``django-admin.py startproject`` has 
    2020      ``SessionMiddleware`` activated. 
    21        
     21 
    2222    * Add ``'django.contrib.sessions'`` to your ``INSTALLED_APPS`` setting, 
    2323      and run ``manage.py syncdb`` to install the single database table 
    2424      that stores session data. 
    25        
     25 
    2626      **New in development version**: this step is optional if you're not using 
    27       the database session backend; see `configuring the session engine`_.  
     27      the database session backend; see `configuring the session engine`_. 
    2828 
    2929If you don't want to use sessions, you might as well remove the 
     
    5151You might also want to set the ``SESSION_FILE_PATH`` setting (which 
    5252defaults to ``/tmp``) to control where Django stores session files. Be 
    53 sure to check that your web server has permissions to read and write to 
     53sure to check that your Web server has permissions to read and write to 
    5454this location. 
    5555 
     
    6565.. note:: 
    6666 
    67     You probably don't want to use cache-based sessions if you're not using 
    68     the memcached cache backend. The local memory and simple cache backends 
     67    You should probably only use cache-based sessions if you're using the 
     68    memcached cache backend. The local memory and simple cache backends 
    6969    don't retain data long enough to be good choices, and it'll be faster 
    7070    to use file or database sessions directly instead of sending everything 
     
    195195=========================== 
    196196 
    197 The ``SessionStore`` which implements the session storage method can be imported 
    198 and a API is available to manipulate the session data outside of a view:: 
     197**New in Django development version** 
     198 
     199An API is available to manipulate session data outside of a view:: 
    199200 
    200201    >>> from django.contrib.sessions.engines.db import SessionStore 
     
    205206    >>> s.save() 
    206207 
    207 Or if you are using the ``django.contrib.sessions.engine.db`` each  
    208 session is just a normal Django model. The ``Session`` model 
    209 is defined in ``django/contrib/sessions/models.py``. Because it's a normal 
    210 model, you can access sessions using the normal Django database API:: 
     208If you're using the ``django.contrib.sessions.engine.db`` backend, each 
     209session is just a normal Django model. The ``Session`` model is defined in 
     210``django/contrib/sessions/models.py``. Because it's a normal model, you can 
     211access sessions using the normal Django database API:: 
    211212 
    212213    >>> from django.contrib.sessions.models import Session 
    213214    >>> s = Session.objects.get(pk='2b1189a188b44ad18c35e113ac6ceead') 
    214215    >>> s.expire_date 
    215     datetime.datetime(2005, 8, 20, 13, 35, 12)   
     216    datetime.datetime(2005, 8, 20, 13, 35, 12) 
    216217 
    217218Note that you'll need to call ``get_decoded()`` to get the session dictionary. 
     
    307308Controls where Django stores session data. Valid values are: 
    308309 
    309     * ``'django.contrib.sessions.backends.db'``       
    310     * ``'django.contrib.sessions.backends.file'``     
     310    * ``'django.contrib.sessions.backends.db'`` 
     311    * ``'django.contrib.sessions.backends.file'`` 
    311312    * ``'django.contrib.sessions.backends.cache'`` 
    312      
     313 
    313314See `configuring the session engine`_ for more details. 
    314315