Django

Code

Changeset 2788

Show
Ignore:
Timestamp:
04/28/06 21:57:58 (2 years ago)
Author:
adrian
Message:

magic-removal: Proofread docs/sessions.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/docs/sessions.txt

    r2744 r2788  
    1111================= 
    1212 
    13 Session functionality is enabled by default. 
    14  
    15 You can turn session functionality on and off by editing the 
    16 ``MIDDLEWARE_CLASSES`` setting. To activate sessions, make sure 
    17 ``MIDDLEWARE_CLASSES`` contains ``"django.contrib.sessions.middleware.SessionMiddleware"``. 
     13Sessions are implemented via middleware_. 
     14 
     15Turn session functionality on and off by editing the ``MIDDLEWARE_CLASSES`` 
     16setting. To activate sessions, make sure ``MIDDLEWARE_CLASSES`` contains 
     17``"django.contrib.sessions.middleware.SessionMiddleware"``. 
     18 
     19The default ``settings.py`` created by ``django-admin.py startproject`` has 
     20``SessionMiddleware`` activated. 
    1821 
    1922If you don't want to use sessions, you might as well remove the 
     
    2124bit of overhead. 
    2225 
     26.. _middleware: http://www.djangoproject.com/documentation/middleware/ 
     27 
    2328Using sessions in views 
    2429======================= 
    2530 
    26 Each ``HttpRequest`` object -- the first argument to any Django view function -- 
    27 has a ``session`` attribute, which is a dictionary-like object. You can read 
    28 it and write to it. 
     31When ``SessionMiddleware`` is activated, each ``HttpRequest`` object -- the 
     32first argument to any Django view function -- will have a ``session`` 
     33attribute, which is a dictionary-like object. You can read it and write to it. 
    2934 
    3035It implements the following standard dictionary methods: 
    31  
    32     * ``__contains__(key)`` 
    33       Example: ``'fav_color' in request.session`` 
    3436 
    3537    * ``__getitem__(key)`` 
     
    4244      Example: ``del request.session['fav_color']``. This raises ``KeyError`` 
    4345      if the given ``key`` isn't already in the session. 
     46 
     47    * ``__contains__(key)`` 
     48      Example: ``'fav_color' in request.session`` 
    4449 
    4550    * ``get(key, default=None)``