From 3c8c2d75b4db0645fa423862bea7d70973e54d8e Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Wed, 13 Feb 2019 20:34:47 +0000 Subject: [PATCH] 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 --- placement/objects/user.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/placement/objects/user.py b/placement/objects/user.py index 8d0c217a5..a3b0920f2 100644 --- a/placement/objects/user.py +++ b/placement/objects/user.py @@ -11,8 +11,6 @@ # under the License. from oslo_db import exception as db_exc -from oslo_versionedobjects import base -from oslo_versionedobjects import fields import sqlalchemy as sa from placement.db.sqlalchemy import models @@ -56,21 +54,23 @@ def _get_user_by_external_id(ctx, external_id): return dict(res) -@base.VersionedObjectRegistry.register_if(False) -class User(base.VersionedObject): +class User(object): - fields = { - 'id': fields.IntegerField(read_only=True), - 'external_id': fields.StringField(nullable=False), - } + def __init__(self, context, id=None, external_id=None, updated_at=None, + created_at=None): + self._context = context + self.id = id + self.external_id = external_id + self.updated_at = updated_at + self.created_at = created_at @staticmethod def _from_db_object(ctx, target, source): - for field in target.fields: - setattr(target, field, source[field]) - 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 @classmethod