def filter(self, *arguments, **kwargs): ''' Filters a queryset in order to produce a different set of document from subsequent queries. Usage:: User.objects.filter(first_name="Bernardo").filter(last_name="Bernardo").find_all(callback=handle_all) # or User.objects.filter(first_name="Bernardo", starting_year__gt=2010).find_all(callback=handle_all) The available filter options are the same as used in MongoEngine. ''' from motorengine.query_builder.node import Q, QCombination, QNot from motorengine.query_builder.transform import validate_fields if arguments and len(arguments) == 1 and isinstance(arguments[0], (Q, QNot, QCombination)): if self._filters: self._filters = self._filters & arguments[0] else: self._filters = arguments[0] else: validate_fields(self.__klass__, kwargs) if self._filters: self._filters = self._filters & Q(**kwargs) else: if arguments and len(arguments) == 1 and isinstance(arguments[0], dict): self._filters = Q(arguments[0]) else: self._filters = Q(**kwargs) return self
def filter(self, *arguments, **kwargs): ''' Filters a queryset in order to produce a different set of document from subsequent queries. Usage:: User.objects.filter(first_name="Bernardo").filter(last_name="Bernardo").find_all(callback=handle_all) # or User.objects.filter(first_name="Bernardo", starting_year__gt=2010).find_all(callback=handle_all) The available filter options are the same as used in MongoEngine. ''' from motorengine.query_builder.node import Q, QCombination, QNot from motorengine.query_builder.transform import validate_fields if arguments and len(arguments) == 1 and isinstance( arguments[0], (Q, QNot, QCombination)): if self._filters: self._filters = self._filters & arguments[0] else: self._filters = arguments[0] else: validate_fields(self.__klass__, kwargs) if self._filters: self._filters = self._filters & Q(**kwargs) else: if arguments and len(arguments) == 1 and isinstance( arguments[0], dict): self._filters = Q(arguments[0]) else: self._filters = Q(**kwargs) return self
def filter(self, *arguments, **kwargs): if arguments and len(arguments) == 1 and isinstance( arguments[0], (Q, QNot, QCombination)): if self._filters: self._filters = self._filters & arguments[0] else: self._filters = arguments[0] else: validate_fields(self.__klass__, kwargs) if self._filters: self._filters = self._filters & Q(**kwargs) else: if arguments and len(arguments) == 1 and isinstance( arguments[0], dict): self._filters = Q(arguments[0]) else: self._filters = Q(**kwargs) return self