Refactored home/no-home usage and fixed exception catch
This commit is contained in:
parent
cde2f4efdf
commit
6e863f2bd7
1 changed files with 8 additions and 4 deletions
|
|
@ -676,15 +676,19 @@ class ObjectDBManager(TypedObjectManager):
|
||||||
|
|
||||||
location = dbid_to_obj(location, self.model)
|
location = dbid_to_obj(location, self.model)
|
||||||
destination = dbid_to_obj(destination, self.model)
|
destination = dbid_to_obj(destination, self.model)
|
||||||
home = dbid_to_obj(home, self.model)
|
if home:
|
||||||
if not home:
|
home = dbid_to_obj(home, self.model)
|
||||||
|
|
||||||
|
if not nohome and not home:
|
||||||
try:
|
try:
|
||||||
home = dbid_to_obj(settings.DEFAULT_HOME, self.model) if not nohome else None
|
home = dbid_to_obj(settings.DEFAULT_HOME, self.model)
|
||||||
except self.model_ObjectDB.DoesNotExist:
|
except self.model.DoesNotExist:
|
||||||
raise self.model.DoesNotExist(
|
raise self.model.DoesNotExist(
|
||||||
"settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed."
|
"settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed."
|
||||||
% settings.DEFAULT_HOME
|
% settings.DEFAULT_HOME
|
||||||
)
|
)
|
||||||
|
elif nohome and not home:
|
||||||
|
home = None
|
||||||
|
|
||||||
# create new instance
|
# create new instance
|
||||||
new_object = typeclass(
|
new_object = typeclass(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue