Merge "Fix init method for HasStandardAttributes"

This commit is contained in:
Jenkins 2016-08-20 00:46:14 +00:00 committed by Gerrit Code Review
commit 351e50be34
1 changed files with 8 additions and 2 deletions

View File

@ -194,11 +194,17 @@ class HasStandardAttributes(object):
single_parent=True,
uselist=False)
def __init__(self, description='', *args, **kwargs):
def __init__(self, *args, **kwargs):
standard_attr_keys = ['description', 'created_at',
'updated_at', 'revision_number']
standard_attr_kwargs = {}
for key in standard_attr_keys:
if key in kwargs:
standard_attr_kwargs[key] = kwargs.pop(key)
super(HasStandardAttributes, self).__init__(*args, **kwargs)
# here we automatically create the related standard attribute object
self.standard_attr = StandardAttribute(
resource_type=self.__tablename__, description=description)
resource_type=self.__tablename__, **standard_attr_kwargs)
@declarative.declared_attr
def description(cls):