I've decided that for a WSGI framework I'm working on (based on Werkzeug, if that helps) that SQLAlchemy will be the official ORM - as in, the framework will handle the database side of the equation and the user just provides the models. However, I am trying to figure out how to make sure that the tables, all imported from distinct apps, all use the same metadata. Whatever solution I use, I want to make sure that:
- Every model is on the same, pre-bound metadata - Both table/object/mapper and ext.declarative are usable - It will run both on the Web and from command line tools What I was thinking about doing was making every app have a "models" function like this: def models(metadata, AlchemyObject) foo_table = Table("myapp_foos", metadata...) class Foo(object): pass foo_mapper = mapper(Foo, foo_table) class Bar(AlchemyObject): ... return [foo_mapper, Bar] But that is ugly and non-Pythonic. Does anyone know of a way that I can make sure that every app is using the same metadata for its models, but doesn't put too much of a burden on the users? Regards, LeafStorm BDFL, Pacific Science (PS: Is it possible to access the underlying tables and classes from mapper objects? I can't find anything about it in the docs.) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---