|
a/Ming/ming/session.py |
|
b/Ming/ming/session.py |
|
... |
|
... |
23 |
except TypeError:
|
23 |
except TypeError:
|
24 |
return None
|
24 |
return None
|
25 |
|
25 |
|
26 |
def get(self, cls, **kwargs):
|
26 |
def get(self, cls, **kwargs):
|
27 |
bson = self._impl(cls).find_one(kwargs)
|
27 |
bson = self._impl(cls).find_one(kwargs)
|
|
|
28 |
if bson is None: return None
|
28 |
if bson: return cls.make(bson)
|
29 |
return cls.make(bson)
|
29 |
else: return None
|
|
|
30 |
|
30 |
|
31 |
def find(self, cls, *args, **kwargs):
|
31 |
def find(self, cls, *args, **kwargs):
|
32 |
cursor = self._impl(cls).find(*args, **kwargs)
|
32 |
cursor = self._impl(cls).find(*args, **kwargs)
|
33 |
return Cursor(cls, cursor)
|
33 |
return Cursor(cls, cursor)
|
34 |
|
34 |
|
|
... |
|
... |
112 |
Does not change it locally
|
112 |
Does not change it locally
|
113 |
"""
|
113 |
"""
|
114 |
key = kwargs.keys()[0]
|
114 |
key = kwargs.keys()[0]
|
115 |
value = kwargs[key]
|
115 |
value = kwargs[key]
|
116 |
if value is None:
|
116 |
if value is None:
|
117 |
raise "%s=%s" % (key, value)
|
117 |
raise ValueError, "%s=%s" % (key, value)
|
118 |
|
118 |
|
119 |
if key not in doc:
|
119 |
if key not in doc:
|
120 |
self._impl(doc).update(
|
120 |
self._impl(doc).update(
|
121 |
{'_id': doc._id, key: None},
|
121 |
{'_id': doc._id, key: None},
|
122 |
{'$set': {key: value}}
|
122 |
{'$set': {key: value}}
|