Merge branch 'master' of github.com:MongoEngine/mongoengine

This commit is contained in:
Ross Lawley 2013-06-03 13:14:21 +00:00
commit 2128e169f3
2 changed files with 8 additions and 8 deletions

View File

@ -27,9 +27,9 @@ MongoEngine includes a Django authentication backend, which uses MongoDB. The
:class:`~mongoengine.Document`, but implements most of the methods and :class:`~mongoengine.Document`, but implements most of the methods and
attributes that the standard Django :class:`User` model does - so the two are attributes that the standard Django :class:`User` model does - so the two are
moderately compatible. Using this backend will allow you to store users in moderately compatible. Using this backend will allow you to store users in
MongoDB but still use many of the Django authentication infrastucture (such as MongoDB but still use many of the Django authentication infrastructure (such as
the :func:`login_required` decorator and the :func:`authenticate` function). To the :func:`login_required` decorator and the :func:`authenticate` function). To
enable the MongoEngine auth backend, add the following to you **settings.py** enable the MongoEngine auth backend, add the following to your **settings.py**
file:: file::
AUTHENTICATION_BACKENDS = ( AUTHENTICATION_BACKENDS = (
@ -46,7 +46,7 @@ Custom User model
================= =================
Django 1.5 introduced `Custom user Models Django 1.5 introduced `Custom user Models
<https://docs.djangoproject.com/en/dev/topics/auth/customizing/#auth-custom-user>` <https://docs.djangoproject.com/en/dev/topics/auth/customizing/#auth-custom-user>`
which can be used as an alternative the Mongoengine authentication backend. which can be used as an alternative to the MongoEngine authentication backend.
The main advantage of this option is that other components relying on The main advantage of this option is that other components relying on
:mod:`django.contrib.auth` and supporting the new swappable user model are more :mod:`django.contrib.auth` and supporting the new swappable user model are more
@ -82,16 +82,16 @@ Sessions
======== ========
Django allows the use of different backend stores for its sessions. MongoEngine Django allows the use of different backend stores for its sessions. MongoEngine
provides a MongoDB-based session backend for Django, which allows you to use provides a MongoDB-based session backend for Django, which allows you to use
sessions in you Django application with just MongoDB. To enable the MongoEngine sessions in your Django application with just MongoDB. To enable the MongoEngine
session backend, ensure that your settings module has session backend, ensure that your settings module has
``'django.contrib.sessions.middleware.SessionMiddleware'`` in the ``'django.contrib.sessions.middleware.SessionMiddleware'`` in the
``MIDDLEWARE_CLASSES`` field and ``'django.contrib.sessions'`` in your ``MIDDLEWARE_CLASSES`` field and ``'django.contrib.sessions'`` in your
``INSTALLED_APPS``. From there, all you need to do is add the following line ``INSTALLED_APPS``. From there, all you need to do is add the following line
into you settings module:: into your settings module::
SESSION_ENGINE = 'mongoengine.django.sessions' SESSION_ENGINE = 'mongoengine.django.sessions'
Django provides session cookie, which expires after ```SESSION_COOKIE_AGE``` seconds, but doesnt delete cookie at sessions backend, so ``'mongoengine.django.sessions'`` supports `mongodb TTL Django provides session cookie, which expires after ```SESSION_COOKIE_AGE``` seconds, but doesn't delete cookie at sessions backend, so ``'mongoengine.django.sessions'`` supports `mongodb TTL
<http://docs.mongodb.org/manual/tutorial/expire-data/>`_. <http://docs.mongodb.org/manual/tutorial/expire-data/>`_.
.. versionadded:: 0.2.1 .. versionadded:: 0.2.1

View File

@ -36,7 +36,7 @@ MongoEngine supports :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetCl
to use them please use a URI style connection and provide the `replicaSet` name in the to use them please use a URI style connection and provide the `replicaSet` name in the
connection kwargs. connection kwargs.
Read preferences are supported throught the connection or via individual Read preferences are supported through the connection or via individual
queries by passing the read_preference :: queries by passing the read_preference ::
Bar.objects().read_preference(ReadPreference.PRIMARY) Bar.objects().read_preference(ReadPreference.PRIMARY)
@ -83,7 +83,7 @@ reasons.
The :class:`~mongoengine.context_managers.switch_db` context manager allows The :class:`~mongoengine.context_managers.switch_db` context manager allows
you to change the database alias for a given class allowing quick and easy you to change the database alias for a given class allowing quick and easy
access to the same User document across databases.eg :: access to the same User document across databases::
from mongoengine.context_managers import switch_db from mongoengine.context_managers import switch_db