mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
[soc2009/multidb] Updated db-backed session to be multi-db compatible. Patch from Russell Keith-Magee.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ba0d00ddbb
commit
64d4c4c09f
7
TODO
7
TODO
@ -7,12 +7,13 @@ Required for v1.2
|
||||
* Finalize the sql.Query internals
|
||||
* Clean up the use of db.backend.query_class()
|
||||
* Verify it still works with GeoDjango
|
||||
* Resolve internal uses of multidb interface
|
||||
* Update database backend for session store to use Multidb
|
||||
* Check default Site creation behavior
|
||||
* Resolve the public facing UI issues around using multi-db
|
||||
* Should we take the opportunity to modify DB backends to use fully qualified paths?
|
||||
* Should we clean up DATABASES['DATABASE_NAME'] to DATABASES['NAME'] etc?
|
||||
* Meta.using? Is is still required/desirable?
|
||||
* Fix the regressiontests/multiple_database test failures
|
||||
* Give instances knowledge of the database from which they were loaded.
|
||||
* Cascade instance using to m2m queries
|
||||
* Cleanup of new API entry points
|
||||
* validate() on a field
|
||||
* name/purpose clash with Honza?
|
||||
|
@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
from django.conf import settings
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.contrib.sessions.backends.base import SessionBase, CreateError
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
@ -9,6 +10,10 @@ class SessionStore(SessionBase):
|
||||
"""
|
||||
Implements database session store.
|
||||
"""
|
||||
def __init__(self, session_key=None):
|
||||
self.using = getattr(settings, "SESSION_DB_ALIAS", DEFAULT_DB_ALIAS)
|
||||
super(SessionStore, self).__init__(session_key)
|
||||
|
||||
def load(self):
|
||||
try:
|
||||
s = Session.objects.get(
|
||||
@ -54,12 +59,12 @@ class SessionStore(SessionBase):
|
||||
expire_date = self.get_expiry_date()
|
||||
)
|
||||
# TODO update for multidb
|
||||
sid = transaction.savepoint(using=DEFAULT_DB_ALIAS)
|
||||
sid = transaction.savepoint(using=self.using)
|
||||
try:
|
||||
obj.save(force_insert=must_create)
|
||||
except IntegrityError:
|
||||
if must_create:
|
||||
transaction.savepoint_rollback(sid, using=DEFAULT_DB_ALIAS)
|
||||
transaction.savepoint_rollback(sid, using=self.using)
|
||||
raise CreateError
|
||||
raise
|
||||
|
||||
|
@ -1056,6 +1056,18 @@ See the :ref:`topics-http-sessions`.
|
||||
|
||||
.. setting:: SESSION_EXPIRE_AT_BROWSER_CLOSE
|
||||
|
||||
SESSION_DB_ALIAS
|
||||
----------------
|
||||
|
||||
.. versionadded:: 1.2
|
||||
|
||||
Default: ``None``
|
||||
|
||||
If you're using database-backed session storage, this selects the database
|
||||
alias that will be used to store session data. By default, Django will use
|
||||
the ``default`` database, but you can store session data on any database
|
||||
you choose.
|
||||
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE
|
||||
-------------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user