Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lig/mongoengine into dev
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
  • Loading branch information
hmarr committed Mar 6, 2011
2 parents ce8b3ea + 34b923b commit 6917128
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.*
!.gitignore
*.pyc
.*.swp
*.egg
Expand All @@ -9,4 +11,4 @@ mongoengine.egg-info/
env/
.settings
.project
.pydevproject
.pydevproject
2 changes: 1 addition & 1 deletion mongoengine/django/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_user(cls, username, password, email=None):
else:
email = '@'.join([email_name, domain_part.lower()])

user = User(username=username, email=email, date_joined=now)
user = cls(username=username, email=email, date_joined=now)
user.set_password(password)
user.save()
return user
Expand Down
9 changes: 7 additions & 2 deletions mongoengine/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def __init__(self, document, collection):
self._ordering = []
self._snapshot = False
self._timeout = True
self._class_check = True

# If inheritance is allowed, only return instances and instances of
# subclasses of the class being used
Expand All @@ -348,7 +349,8 @@ def __init__(self, document, collection):
def _query(self):
if self._mongo_query is None:
self._mongo_query = self._query_obj.to_query(self._document)
self._mongo_query.update(self._initial_query)
if self._class_check:
self._mongo_query.update(self._initial_query)
return self._mongo_query

def ensure_index(self, key_or_list, drop_dups=False, background=False,
Expand Down Expand Up @@ -399,14 +401,16 @@ def _build_index_spec(cls, doc_cls, key_or_list):

return index_list

def __call__(self, q_obj=None, **query):
def __call__(self, q_obj=None, class_check=True, **query):
"""Filter the selected documents by calling the
:class:`~mongoengine.queryset.QuerySet` with a query.
:param q_obj: a :class:`~mongoengine.queryset.Q` object to be used in
the query; the :class:`~mongoengine.queryset.QuerySet` is filtered
multiple times with different :class:`~mongoengine.queryset.Q`
objects, only the last one will be used
:param class_check: If set to False bypass class name check when
querying collection
:param query: Django-style query keyword arguments
"""
#if q_obj:
Expand All @@ -417,6 +421,7 @@ def __call__(self, q_obj=None, **query):
self._query_obj &= query
self._mongo_query = None
self._cursor_obj = None
self._class_check = class_check
return self

def filter(self, *q_objs, **query):
Expand Down

0 comments on commit 6917128

Please sign in to comment.