Benjamin said:
> class SomeTable (DeclarativeBase):
> __tablename__ = config.get("database.table.prefix")+'sometable'
I haven't tried this, but I guess it'd work:
"""
class _ModelMeta(DeclarativeBase.__metaclass__):
def __init__(cls, name, bases, ns):
table_name = ns['table_name']
cls.__tablename__ = config.get("database.table.prefix") + table_name
DeclarativeBase.__init__(cls, name, bases, ns)
class BaseModel(object):
__metaclass__ = _ModelMeta
"""
And then, instead of subclassing DeclarativeBase, you'd subclass BaseModel:
"""
class User(BaseModel):
table_name = "users"
class Group(BaseModel):
table_name = "groups"
"""
For more information about metaclasses, I'd recommend this:
http://cleverdevil.org/computing/78/
HTH,
--
Gustavo Narea <xri://=Gustavo>.
| Tech blog: =Gustavo/(+blog)/tech ~ About me: =Gustavo/about |
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---