On May 25, 2007, at 10:23 AM, Michael Bayer wrote:
Forgive my attention grabbing headline but I think Pylons integration with create_engine() needs a serious overhaul, small as it may be.
Agreed, and I'm working on that. :)
which would at best be a horrible kludge to get this working, as i am imitating a private key-making function to make it work. but even *that* doesnt work, because get_engines() at that point returns the _db_engines dict thats inside of database.py, but when the app actually runs, it returns the _db_engines thats on top of "g". setting it within lib/app_globals.py doesnt do any better. So I have to stick it inside of lib/base.py which is not at all where environmental options should be configured.
Fixed in latest Pylons trunk with new pylons.config object (there when the app is initialized and not running, AND there when the app is running).
design changes i would make: - definite: have just *one* dictionary which stores database engines, not two. database._db_engines and g._db_engines, if you even need g._db_engines at all (why is it needed in two places?) should be *the same dictionary*. having two of the same thing is useless and creates ambiguity.
Done in the latest Pylons trunk. Definitely a nice change as well.
- no reason why not: alter pylons.database.create_engine() to provide a "config_key" argument, which specifies exactly what key a particular database engine will be stored under. put this key as in .ini as well under sqlalchemy.key or similar so it can be affected from both places.
I'll be implementing this as Phil suggested, such that adding another name with a dot in the config will add more engine's available under that config key. Ie:
sqlalchemy.ro_only.dburi = ..... etc.
- nice to have: allow support for *any* keyword under sqlalchemy.XXXXX to be propigated from the .ini file to create_engine (), not just 'uri' and 'echo'. have awareness of the well known kwargs so that types can be changed from strings to ints/booleans as needed.
This will be part of the above implementation for the additional engine config with a key for usage.
Cheers, Ben
smime.p7s
Description: S/MIME cryptographic signature
