Merge "Use common db model class from Oslo"

This commit is contained in:
Jenkins 2013-08-30 04:20:40 +00:00 committed by Gerrit Code Review
commit d8223b00e8
2 changed files with 4 additions and 34 deletions

View File

@ -28,6 +28,7 @@ from sqlalchemy import types as sql_types
from keystone import config
from keystone import exception
from keystone.openstack.common.db.sqlalchemy import models
from keystone.openstack.common import jsonutils
from keystone.openstack.common import log as logging
@ -149,7 +150,7 @@ class JsonBlob(sql_types.TypeDecorator):
return jsonutils.loads(value)
class DictBase(object):
class DictBase(models.ModelBase):
attributes = []
@classmethod
@ -178,43 +179,11 @@ class DictBase(object):
return d
def __setitem__(self, key, value):
setattr(self, key, value)
def __getitem__(self, key):
if key in self.extra:
return self.extra[key]
return getattr(self, key)
def get(self, key, default=None):
return getattr(self, key, default)
def __iter__(self):
self._i = iter(sqlalchemy.orm.object_mapper(self).columns)
return self
def next(self):
n = self._i.next().name
return n
def update(self, values):
"""Make the model object behave like a dict."""
for k, v in values.iteritems():
setattr(self, k, v)
def iteritems(self):
"""Make the model object behave like a dict.
Includes attributes from joins.
"""
return dict([(k, getattr(self, k)) for k in self])
#local = dict(self)
#joined = dict([(k, v) for k, v in self.__dict__.iteritems()
# if not k[0] == '_'])
#local.update(joined)
#return local.iteritems()
def mysql_on_checkout(dbapi_conn, connection_rec, connection_proxy):
"""Ensures that MySQL connections checked out of the pool are alive.

View File

@ -15,7 +15,8 @@ passlib
lxml
iso8601>=0.1.4
python-keystoneclient>=0.3.0
oslo.config>=1.1.0
-f http://tarballs.openstack.org/oslo.config/oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3
oslo.config>=1.2.0a3
Babel>=0.9.6
oauth2
dogpile.cache>=0.5.0