Merge "Don't query stack tags twice"

This commit is contained in:
Jenkins 2016-02-15 07:24:43 +00:00 committed by Gerrit Code Review
commit fe2d05164c
2 changed files with 7 additions and 5 deletions

View File

@ -71,11 +71,8 @@ class Stack(
raw_template.RawTemplate.get_by_id(
context, db_stack['raw_template_id']))
elif field == 'tags':
if db_stack.get(field) is not None:
stack['tags'] = stack_tag.StackTagList.get(
context, db_stack['id'])
else:
stack['tags'] = None
stack['tags'] = stack_tag.StackTagList.from_db_object(
context, db_stack.get(field))
else:
stack[field] = db_stack.__dict__.get(field)
stack._context = context

View File

@ -80,3 +80,8 @@ class StackTagList(
@classmethod
def delete(cls, context, stack_id):
db_api.stack_tags_delete(context, stack_id)
@classmethod
def from_db_object(cls, context, db_tags):
if db_tags is not None:
return base.obj_make_list(context, cls(), StackTag, db_tags)