Skip to content

Commit

Permalink
Merge "Use common db model class from Oslo"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 30, 2013
2 parents 9e8f89f + 6979ae0 commit d8223b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 34 deletions.
35 changes: 2 additions & 33 deletions keystone/common/sql/core.py
Expand Up @@ -28,6 +28,7 @@

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

Expand Down Expand Up @@ -149,7 +150,7 @@ def process_result_value(self, value, dialect):
return jsonutils.loads(value)


class DictBase(object):
class DictBase(models.ModelBase):
attributes = []

@classmethod
Expand Down Expand Up @@ -178,43 +179,11 @@ def to_dict(self, include_extra_dict=False):

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.
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Expand Up @@ -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

0 comments on commit d8223b0

Please sign in to comment.