def transform_object(self, obj, depth):
     if depth == 0:
         return smart_repr(obj)
     elif isinstance(obj, BaseDocument):
         return self.transform_document(obj, depth)
     elif isinstance(obj, DBRef):
         # DBRef
         return self.transform_object(obj.id, depth)
     elif isinstance(obj, dict):
         # Dictionaries
         return self.transform_dict(obj, depth)
     elif isinstance(obj, list):
         # List
         return [self.transform_object(value, depth) for value in obj]
     elif obj is None:
         return None
     else:
         return smart_repr(obj)
Ejemplo n.º 2
0
 def transform_object(self, obj, depth):
     """
     Models to natives
     Recursion for (embedded) objects
     """
     if depth == 0:
         return smart_repr(obj)
     elif isinstance(obj, BaseDocument):
         return self.transform_document(obj, depth)
     elif isinstance(obj, DBRef):
         # DBRef
         return self.transform_object(obj.id, depth)
     elif isinstance(obj, dict):
         # Dictionaries
         return self.transform_dict(obj, depth)
     elif isinstance(obj, list):
         # List
         return [self.transform_object(value, depth) for value in obj]
     elif obj is None:
         return None
     else:
         return smart_repr(obj)
Ejemplo n.º 3
0
 def __repr__(self):
     return '<%s(queryset=%s, fields=%s)>' % (
         self.__class__.__name__,
         smart_repr(self.queryset),
         smart_repr(self.fields)
     )
Ejemplo n.º 4
0
 def __repr__(self):
     return unicode_to_repr(
         '<%s(queryset=%s)>' %
         (self.__class__.__name__, smart_repr(self.queryset)))
 def __repr__(self):
     return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % (
         self.__class__.__name__,
         smart_repr(self.queryset),
         smart_repr(self.fields)
     ))