nanomongo.util
¶
-
nanomongo.util.
check_spec
(cls, spec)[source]¶ Check the query spec for given class and log warnings. Not extensive, helpful to catch mistyped queries.
- Dotted keys (eg.
{'foo.bar': 1}
) in spec are checked for top-level (ie.foo
) field existence - Dotted keys are also checked for their top-level field type (must be
dict
orlist
) - Normal keys (eg.
{'foo': 1}
) in spec are checked for top-level (ie.foo
) field existence - Normal keys with non-dict queries (ie. not something like
{'foo': {'$gte': 0, '$lte': 1}}
) are also checked for their data type
- Dotted keys (eg.
-
class
nanomongo.util.
RecordingDict
(*args, **kwargs)[source]¶ A dict subclass modifying
dict.__setitem__()
anddict.__delitem__()
methods to record changes internally in its__nanodiff__
attribute.-
check_can_update
(modifier, field_name)[source]¶ Check if given modifier field_name combination can be added. MongoDB does not allow field duplication with update modifiers. This is to be used with methods
add_to_set()
…
-
clear_other_modifiers
(current_mod, field_name)[source]¶ Given
current_mod
, removes otherfield_name
modifiers, eg. when called with$set
, removes$unset
and$addToSet
etc. onfield_name
.
-
get_sub_diff
()[source]¶ Find fields of
RecordingDict
type, iterate over their diff and build dotted keys to be merged into top level diff.
-
-
class
nanomongo.util.
NanomongoSONManipulator
(as_class, transforms=None)[source]¶ A pymongo SON Manipulator used on data that comes from the database to transform data to the document class we want because as_class argument to pymongo find methods is called in a way that screws us.
- Recursively applied, we don’t want that
- __init__ is not properly used but rather __setitem__, fails us
JIRA: PYTHON-175 PYTHON-215