def associate_with(sqltype): # TODO(leizhang) When we removed sqlalchemy 0.7 dependence # we can import MutableDict directly and remove ./mutable.py try: from sqlalchemy.ext.mutable import MutableDict as sa_MutableDict sa_MutableDict.associate_with(Json) except ImportError: from heat.db.sqlalchemy.mutable import MutableDict MutableDict.associate_with(Json)
impl = types.Text def process_bind_param(self, value, dialect): return dumps(value) def process_result_value(self, value, dialect): return loads(value) # TODO(leizhang) When we removed sqlalchemy 0.7 dependence # we can import MutableDict directly and remove ./mutable.py try: from sqlalchemy.ext.mutable import MutableDict as sa_MutableDict sa_MutableDict.associate_with(Json) except ImportError: from heat.db.sqlalchemy.mutable import MutableDict MutableDict.associate_with(Json) class HeatBase(object): """Base class for Heat Models.""" __table_args__ = {'mysql_engine': 'InnoDB'} __table_initialized__ = False created_at = sqlalchemy.Column(sqlalchemy.DateTime, default=timeutils.utcnow) updated_at = sqlalchemy.Column(sqlalchemy.DateTime, onupdate=timeutils.utcnow) def save(self, session=None): """Save this object.""" if not session: session = Session.object_session(self)
return self.impl def process_bind_param(self, value, dialect): return dumps(value) def process_result_value(self, value, dialect): return loads(value) # TODO(leizhang) When we removed sqlalchemy 0.7 dependence # we can import MutableDict directly and remove ./mutable.py try: from sqlalchemy.ext.mutable import MutableDict as sa_MutableDict sa_MutableDict.associate_with(Json) except ImportError: from heat.db.sqlalchemy.mutable import MutableDict MutableDict.associate_with(Json) class HeatBase(models.ModelBase, models.TimestampMixin): """Base class for Heat Models.""" __table_args__ = {'mysql_engine': 'InnoDB'} def expire(self, session=None, attrs=None): """Expire this object ().""" if not session: session = Session.object_session(self) if not session: session = get_session() session.expire(self, attrs) def refresh(self, session=None, attrs=None):