Django

Code

Changeset 7725

Show
Ignore:
Timestamp:
06/23/08 00:08:07 (5 months ago)
Author:
gwilson
Message:

Several Django styling fixes in the contrib.sessions app.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/sessions/backends/base.py

    r7687 r7725  
    66import time 
    77from datetime import datetime, timedelta 
    8 from django.conf import settings 
    9 from django.core.exceptions import SuspiciousOperation 
    10  
    118try: 
    129    import cPickle as pickle 
    1310except ImportError: 
    1411    import pickle 
     12 
     13from django.conf import settings 
     14from django.core.exceptions import SuspiciousOperation 
     15 
    1516 
    1617class SessionBase(object): 
     
    170171    def set_expiry(self, value): 
    171172        """ 
    172         Sets a custom expiration for the session. ``value`` can be an integer, a 
    173         Python ``datetime`` or ``timedelta`` object or ``None``. 
     173        Sets a custom expiration for the session. ``value`` can be an integer, 
     174        a Python ``datetime`` or ``timedelta`` object or ``None``. 
    174175 
    175176        If ``value`` is an integer, the session will expire after that many 
  • django/trunk/django/contrib/sessions/backends/cache.py

    r7586 r7725  
    22from django.contrib.sessions.backends.base import SessionBase 
    33from django.core.cache import cache 
     4 
    45 
    56class SessionStore(SessionBase): 
  • django/trunk/django/contrib/sessions/backends/db.py

    r7586 r7725  
     1import datetime 
     2 
    13from django.conf import settings 
    24from django.contrib.sessions.models import Session 
    35from django.contrib.sessions.backends.base import SessionBase 
    46from django.core.exceptions import SuspiciousOperation 
    5 import datetime 
     7 
    68 
    79class SessionStore(SessionBase): 
    810    """ 
    9     Implements database session store 
     11    Implements database session store. 
    1012    """ 
    1113    def __init__(self, session_key=None): 
  • django/trunk/django/contrib/sessions/backends/file.py

    r7329 r7725  
    11import os 
    22import tempfile 
     3 
    34from django.conf import settings 
    45from django.contrib.sessions.backends.base import SessionBase 
    56from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured 
     7 
    68 
    79class SessionStore(SessionBase): 
     
    1618        # Make sure the storage path is valid. 
    1719        if not os.path.isdir(self.storage_path): 
    18             raise ImproperlyConfigured("The session storage path %r doesn't exist. "\ 
    19                                        "Please set your SESSION_FILE_PATH setting "\ 
    20                                        "to an existing directory in which Django "\ 
    21                                        "can store session data." % self.storage_path) 
     20            raise ImproperlyConfigured( 
     21                "The session storage path %r doesn't exist. Please set your" 
     22                " SESSION_FILE_PATH setting to an existing directory in which" 
     23                " Django can store session data." % self.storage_path) 
    2224 
    2325        self.file_prefix = settings.SESSION_COOKIE_NAME 
     
    3234 
    3335        # Make sure we're not vulnerable to directory traversal. Session keys 
    34         # should always be md5s, so they should never contain directory components. 
     36        # should always be md5s, so they should never contain directory 
     37        # components. 
    3538        if os.path.sep in session_key: 
    36             raise SuspiciousOperation("Invalid characters (directory components) in session key") 
     39            raise SuspiciousOperation( 
     40                "Invalid characters (directory components) in session key") 
    3741 
    3842        return os.path.join(self.storage_path, self.file_prefix + session_key) 
  • django/trunk/django/contrib/sessions/middleware.py

    r7586 r7725  
    77TEST_COOKIE_NAME = 'testcookie' 
    88TEST_COOKIE_VALUE = 'worked' 
     9 
    910 
    1011class SessionMiddleware(object): 
     
    4142                        path=settings.SESSION_COOKIE_PATH, 
    4243                        secure=settings.SESSION_COOKIE_SECURE or None) 
    43  
    4444        return response 
  • django/trunk/django/contrib/sessions/models.py

    r7131 r7725  
    77from django.conf import settings 
    88 
     9 
    910class SessionManager(models.Manager): 
    1011    def encode(self, session_dict): 
    11         "Returns the given session dictionary pickled and encoded as a string." 
     12        """ 
     13        Returns the given session dictionary pickled and encoded as a string. 
     14        """ 
    1215        pickled = pickle.dumps(session_dict) 
    1316        pickled_md5 = md5.new(pickled + settings.SECRET_KEY).hexdigest() 
     
    2124            s.delete() # Clear sessions with no data. 
    2225        return s 
     26 
    2327 
    2428class Session(models.Model): 
     
    3943    on the Django website). 
    4044    """ 
    41     session_key = models.CharField(_('session key'), max_length=40, primary_key=True) 
     45    session_key = models.CharField(_('session key'), max_length=40, 
     46                                   primary_key=True) 
    4247    session_data = models.TextField(_('session data')) 
    4348    expire_date = models.DateTimeField(_('expire date'))