1
0
mirror of https://github.com/django/django.git synced 2025-04-06 22:46:41 +00:00

magic-removal: Merged to [2300]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2301 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-02-10 21:35:29 +00:00
parent 021b38a52c
commit d43d498ba2
5 changed files with 29 additions and 1 deletions

View File

@ -36,6 +36,7 @@ answer newbie questions, and generally made Django that much better:
David Ascher <http://ascher.ca/>
Arthur <avandorp@gmail.com>
Jiri Barton
Ned Batchelder <http://www.nedbatchelder.com/>
James Bennett
Paul Bissex <http://e-scribe.com/>
Simon Blanchard

View File

@ -25,6 +25,12 @@ class SessionWrapper(object):
del self._session[key]
self.modified = True
def keys(self):
return self._session.keys()
def items(self):
return self._session.items()
def get(self, key, default=None):
return self._session.get(key, default)

View File

@ -26,7 +26,7 @@ integer_re = re.compile(r'^-?\d+$')
ip4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$')
phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
slug_re = re.compile(r'^[-\w]+$')
url_re = re.compile(r'^http://\S+$')
url_re = re.compile(r'^https?://\S+$')
lazy_inter = lazy(lambda a,b: str(a) % b, str)

View File

@ -228,6 +228,21 @@ information.
.. _request objects: http://www.djangoproject.com/documentation/request_response/#httprequest-objects
.. _session documentation: http://www.djangoproject.com/documentation/sessions/
How to log a user in
--------------------
To log a user in, do the following within a view::
from django.models.auth import users
request.session[users.SESSION_KEY] = some_user.id
Because this uses sessions, you'll need to make sure you have
``SessionMiddleware`` enabled. See the `session documentation`_ for more
information.
This assumes ``some_user`` is your ``User`` instance. Depending on your task,
you'll probably want to make sure to validate the user's username and password.
Limiting access to logged-in users
----------------------------------

View File

@ -45,6 +45,12 @@ It implements the following standard dictionary methods:
* ``get(key, default=None)``
Example: ``fav_color = request.session.get('fav_color', 'red')``
* ``keys()``
**New in Django development version.**
* ``items()``
**New in Django development version.**
It also has these three methods:
* ``set_test_cookie()``