Don't use OVO in User object

This changes the User object to be a plain Python object
with an explicit __init__.

Change-Id: I0e0019e34d58ce0375ee2a2495786ee2f48b5b49
This commit is contained in:
Chris Dent 2019-02-13 20:34:47 +00:00
parent 6f7342f4e2
commit 3c8c2d75b4

View File

@ -11,8 +11,6 @@
# under the License. # under the License.
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_versionedobjects import base
from oslo_versionedobjects import fields
import sqlalchemy as sa import sqlalchemy as sa
from placement.db.sqlalchemy import models from placement.db.sqlalchemy import models
@ -56,21 +54,23 @@ def _get_user_by_external_id(ctx, external_id):
return dict(res) return dict(res)
@base.VersionedObjectRegistry.register_if(False) class User(object):
class User(base.VersionedObject):
fields = { def __init__(self, context, id=None, external_id=None, updated_at=None,
'id': fields.IntegerField(read_only=True), created_at=None):
'external_id': fields.StringField(nullable=False), self._context = context
} self.id = id
self.external_id = external_id
self.updated_at = updated_at
self.created_at = created_at
@staticmethod @staticmethod
def _from_db_object(ctx, target, source): def _from_db_object(ctx, target, source):
for field in target.fields:
setattr(target, field, source[field])
target._context = ctx target._context = ctx
target.obj_reset_changes() target.id = source['id']
target.external_id = source['external_id']
target.updated_at = source['updated_at']
target.created_at = source['created_at']
return target return target
@classmethod @classmethod