Add try block into domain.get_id_by_name function

If we try to check if a domain exists, and we fetch with
get_id_by_name() function it will return with None if
the domain not exists, and return the id when yes.
This commit is contained in:
SIPOS, Peter 2016-11-16 14:02:43 +01:00
parent 88f0faa73b
commit bbb71f401c

View File

@ -477,8 +477,11 @@ class Domain(db.Model):
""" """
Return domain id Return domain id
""" """
domain = Domain.query.filter(Domain.name==name).first() try:
return domain.id domain = Domain.query.filter(Domain.name==name).first()
return domain.id
except:
return None
def update(self): def update(self):
""" """