Mike Orr escreveu:
Care to change it to a I-know-who-my-session-is model? As you can see below, the session itself doesn't need to know what bind= it will use. Doing it the way in the pylonsdocs hinders multiple databases in the same session (but in different MetaData()s.If you create a new app in Pylons' development version, it will ask if you want SQLAlchemy, and if so it will preconfigure the model according to that article.
---8<--- def __init__(bind): metadata.bind = bind def __setup__(bind): metadata.bind = bind metadata.create_all() # XXX: hookup sa-migrate metadata = sa.MetaData() Session = scoped_session(sessionmaker(transactional=True, autoflush=True)) table = Table(...) class Stuff(object): pass Session.mapper(Stuff, table) ---8<---
signature.asc
Description: OpenPGP digital signature
