Added customization of create() method

The create method will return a response.  This patch avoids hiding that
response from the create() return values.
This commit is contained in:
tengqm
2015-01-23 16:02:42 +08:00
parent f65602a49b
commit b4110e3e80

View File

@@ -104,3 +104,14 @@ class Resource(base.Resource):
for data in resp:
value = cls.existing(**data)
yield value
def create(self, session):
'''
Overriden version of the create method.
We want to know more about the object being created, so the response
should not be just thrown away
'''
resp = self.create_by_id(session, self._attrs, self.id, path_args=self)
self._attrs[self.id_attribute] = resp[self.id_attribute]
self._reset_dirty()
return self, resp