Merge branch 'master' into dev

This commit is contained in:
Ross Lawley
2011-05-18 08:13:58 +01:00
4 changed files with 119 additions and 4 deletions

View File

@@ -508,6 +508,17 @@ class BaseDocument(object):
return True
return False
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
""" For list, dic key """
if self.pk is None:
# For new object
return super(BaseDocument,self).__hash__()
else:
return hash(self.pk)
if sys.version_info < (2, 5):
# Prior to Python 2.5, Exception was an old-style class
import types

View File

@@ -538,7 +538,7 @@ class QuerySet(object):
"""
operators = ['ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'mod',
'all', 'size', 'exists', 'not']
geo_operators = ['within_distance', 'within_box', 'near']
geo_operators = ['within_distance', 'within_spherical_distance', 'within_box', 'near', 'near_sphere']
match_operators = ['contains', 'icontains', 'startswith',
'istartswith', 'endswith', 'iendswith',
'exact', 'iexact']
@@ -582,8 +582,12 @@ class QuerySet(object):
if op in geo_operators:
if op == "within_distance":
value = {'$within': {'$center': value}}
elif op == "within_spherical_distance":
value = {'$within': {'$centerSphere': value}}
elif op == "near":
value = {'$near': value}
elif op == "near_sphere":
value = {'$nearSphere': value}
elif op == 'within_box':
value = {'$within': {'$box': value}}
else: