Fix return type for all situations of get_all_scripts manager method, as inspired by #2117

This commit is contained in:
Griatch 2020-06-28 11:37:17 +02:00
parent a84843d314
commit 0c53f1bcc3

View file

@ -73,7 +73,7 @@ class ScriptDBManager(TypedObjectManager):
Get all scripts in the database. Get all scripts in the database.
Args: Args:
key (str, optional): Restrict result to only those key (str or int, optional): Restrict result to only those
with matching key or dbref. with matching key or dbref.
Returns: Returns:
@ -83,12 +83,9 @@ class ScriptDBManager(TypedObjectManager):
if key: if key:
script = [] script = []
dbref = self.dbref(key) dbref = self.dbref(key)
if dbref or dbref == 0: if dbref:
# return either [] or a valid list (never [None]) return self.filter(id=dbref)
script = [res for res in [self.dbref_search(dbref)] if res] return self.filter(db_key__iexact=key.strip())
if not script:
script = self.filter(db_key=key)
return script
return self.all() return self.all()
def delete_script(self, dbref): def delete_script(self, dbref):
@ -231,7 +228,7 @@ class ScriptDBManager(TypedObjectManager):
ostring = ostring.strip() ostring = ostring.strip()
dbref = self.dbref(ostring) dbref = self.dbref(ostring)
if dbref or dbref == 0: if dbref:
# this is a dbref, try to find the script directly # this is a dbref, try to find the script directly
dbref_match = self.dbref_search(dbref) dbref_match = self.dbref_search(dbref)
if dbref_match and not ( if dbref_match and not (