You're doing it wrong, but it's not too hard to correct - it will mostly be 
shifting your existing code-blocks around as-is.

Check out the current version of Pyramid's scaffold for SqlAlchemy (I think 
the template change happened in Pyramid 1.6) , which uses a more 
streamlined approach that should make more sense than older methods.

Think of the SqlAlchemy "engine_from_config" as less of an engine, and more 
of something that manages a connection pool.  With that understanding, you 
basically want it to start up on application setup as part of your pyramid 
app's `__init__.py:main` def, where the `config` and `settings` are 
available -- otherwise you'll lose all the benefits of having a connection 
pool, as the pool/connections would be destroyed on every request.

In the current Pyramid scaffold, __init__.py includes models/__init__.py 
through a scan.  The models init does the following in the 'includeme' hook 
on startup : 
(https://github.com/Pylons/pyramid/blob/master/pyramid/scaffolds/alchemy/%2Bpackage%2B/models/__init__.py_tmpl)

1. create an engine from config includeme calls getengine which calls `
engine_from_config`
2. sets up a request method that makes a memoized/reifed factory for the 
current transaction-aware dbSession onto the request


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to