Edited docs/sessions.txt changes from [6333]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6344 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2007-09-15 22:36:53 +00:00
parent c079d52fe7
commit b448593432
1 changed files with 17 additions and 16 deletions

View File

@ -50,7 +50,7 @@ To use file-based sessions, set the ``SESSION_ENGINE`` setting to
You might also want to set the ``SESSION_FILE_PATH`` setting (which You might also want to set the ``SESSION_FILE_PATH`` setting (which
defaults to ``/tmp``) to control where Django stores session files. Be defaults to ``/tmp``) to control where Django stores session files. Be
sure to check that your web server has permissions to read and write to sure to check that your Web server has permissions to read and write to
this location. this location.
Using cache-based sessions Using cache-based sessions
@ -64,8 +64,8 @@ you've configured your cache; see the `cache documentation`_ for details.
.. note:: .. note::
You probably don't want to use cache-based sessions if you're not using You should probably only use cache-based sessions if you're using the
the memcached cache backend. The local memory and simple cache backends memcached cache backend. The local memory and simple cache backends
don't retain data long enough to be good choices, and it'll be faster don't retain data long enough to be good choices, and it'll be faster
to use file or database sessions directly instead of sending everything to use file or database sessions directly instead of sending everything
through the file or database cache backends. through the file or database cache backends.
@ -194,8 +194,9 @@ Here's a typical usage example::
Using sessions out of views Using sessions out of views
=========================== ===========================
The ``SessionStore`` which implements the session storage method can be imported **New in Django development version**
and a API is available to manipulate the session data outside of a view::
An API is available to manipulate session data outside of a view::
>>> from django.contrib.sessions.engines.db import SessionStore >>> from django.contrib.sessions.engines.db import SessionStore
>>> s = SessionStore(session_key='2b1189a188b44ad18c35e113ac6ceead') >>> s = SessionStore(session_key='2b1189a188b44ad18c35e113ac6ceead')
@ -204,10 +205,10 @@ and a API is available to manipulate the session data outside of a view::
datetime.datetime(2005, 8, 20, 13, 35, 0) datetime.datetime(2005, 8, 20, 13, 35, 0)
>>> s.save() >>> s.save()
Or if you are using the ``django.contrib.sessions.engine.db`` each If you're using the ``django.contrib.sessions.engine.db`` backend, each
session is just a normal Django model. The ``Session`` model session is just a normal Django model. The ``Session`` model is defined in
is defined in ``django/contrib/sessions/models.py``. Because it's a normal ``django/contrib/sessions/models.py``. Because it's a normal model, you can
model, you can access sessions using the normal Django database API:: access sessions using the normal Django database API::
>>> from django.contrib.sessions.models import Session >>> from django.contrib.sessions.models import Session
>>> s = Session.objects.get(pk='2b1189a188b44ad18c35e113ac6ceead') >>> s = Session.objects.get(pk='2b1189a188b44ad18c35e113ac6ceead')