> 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
> """
>
Thanks Gustavo, that's exactly the solution I was looking for since it
would save having to declare the prefix for each table individually. I
suspect there will be a problem with the config object not being fully
populated when config.get() is called from the model, but I may have a
work around for that.
Much appreciated! Thanks again.
--
Regards,
Benjamin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---