u may try your stuff as mixin, that may or may not work.
I don't know whether this is currently possible with Declarative or
not. In the case it isn't, patching Declarative should be quite easy
(but I don't know if such a patch would be accepted or not). If you
don't want to go down that route, Elixir does support that pattern.
--
Gaëtan de Menten
http://openhex.org
the "Column" objects that are present on each declarative class are
unique to that class, so the creation of those three Column objects
would have to occur for each class. This suggests that the correct
approach would be to extend the declarative metaclass to provide this
behavior:
from sqlalchemy import *
from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base
class MyDefaults(DeclarativeMeta):
def __init__(cls, classname, bases, dict_):
dict_['id'] = Column(Integer, primary_key=True)
dict_['creation_time'] = Column(DateTime)
dict_['modify_time'] = Column(DateTime)
return DeclarativeMeta.__init__(cls, classname, bases, dict_)
Base = declarative_base(metaclass=MyDefaults)
class TestEntity(Base):
__tablename__ = 'test'
value = Column(String)
print TestEntity.id == 5
print TestEntity.creation_time