Some of the doc strings were incorrect in manager.py. Manager.py methods should return querySets, not lists
This commit is contained in:
parent
7a428b703b
commit
8512364560
1 changed files with 7 additions and 7 deletions
|
|
@ -159,7 +159,7 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
typeclasses (list, optional): Python pats to restrict matches with.
|
typeclasses (list, optional): Python pats to restrict matches with.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): Objects fullfilling both the `attribute_name` and
|
matches (query): Objects fullfilling both the `attribute_name` and
|
||||||
`attribute_value` criterions.
|
`attribute_value` criterions.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
@ -178,11 +178,11 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
# This doesn't work if attribute_value is an object. Workaround below
|
# This doesn't work if attribute_value is an object. Workaround below
|
||||||
|
|
||||||
if isinstance(attribute_value, (str, int, float, bool)):
|
if isinstance(attribute_value, (str, int, float, bool)):
|
||||||
return list(self.filter(
|
return self.filter(
|
||||||
cand_restriction
|
cand_restriction
|
||||||
& type_restriction
|
& type_restriction
|
||||||
& Q(db_attributes__db_key=attribute_name, db_attributes__db_value=attribute_value)
|
& Q(db_attributes__db_key=attribute_name, db_attributes__db_value=attribute_value)
|
||||||
).order_by("id"))
|
).order_by("id")
|
||||||
else:
|
else:
|
||||||
# We must loop for safety since the referenced lookup gives deepcopy error if attribute value is an object.
|
# We must loop for safety since the referenced lookup gives deepcopy error if attribute value is an object.
|
||||||
global _ATTR
|
global _ATTR
|
||||||
|
|
@ -273,12 +273,12 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
to exclude from the match.
|
to exclude from the match.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
contents (list): Matching contents, without excludeobj, if given.
|
contents (query): Matching contents, without excludeobj, if given.
|
||||||
"""
|
"""
|
||||||
exclude_restriction = (
|
exclude_restriction = (
|
||||||
Q(pk__in=[_GA(obj, "id") for obj in make_iter(excludeobj)]) if excludeobj else Q()
|
Q(pk__in=[_GA(obj, "id") for obj in make_iter(excludeobj)]) if excludeobj else Q()
|
||||||
)
|
)
|
||||||
return list(self.filter(db_location=location).exclude(exclude_restriction).order_by("id"))
|
return self.filter(db_location=location).exclude(exclude_restriction).order_by("id")
|
||||||
|
|
||||||
def get_objs_with_key_or_alias(self, ostring, exact=True, candidates=None, typeclasses=None):
|
def get_objs_with_key_or_alias(self, ostring, exact=True, candidates=None, typeclasses=None):
|
||||||
"""
|
"""
|
||||||
|
|
@ -291,7 +291,7 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
typeclasses (list): Only match objects with typeclasses having thess path strings.
|
typeclasses (list): Only match objects with typeclasses having thess path strings.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): A list of matches of length 0, 1 or more.
|
matches (query): A list of matches of length 0, 1 or more.
|
||||||
"""
|
"""
|
||||||
if not isinstance(ostring, str):
|
if not isinstance(ostring, str):
|
||||||
if hasattr(ostring, "key"):
|
if hasattr(ostring, "key"):
|
||||||
|
|
@ -309,7 +309,7 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
|
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
|
||||||
if exact:
|
if exact:
|
||||||
# exact match - do direct search
|
# exact match - do direct search
|
||||||
return list(
|
return (
|
||||||
(
|
(
|
||||||
self.filter(
|
self.filter(
|
||||||
cand_restriction
|
cand_restriction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue