On Nov 24, 2010, at 9:53 AM, Daniel Holth wrote:

> I am also interested in having unrelated packages participate in the 
> SQLAlchemy session but unfortunately have not had the opportunity to write 
> and release those packages. A couple of SQLAlchemy notes:

Yea, that is one of the things having a common 3rd package import point will 
allow for. Since the unrelated packages can all import the same DBSession.

> It is not necessary for every mapped class to inherit from the same 
> declarative base class. For example, non-declarative models won't inherit 
> from any common base. There can be any number of declarative_base() classes.
> 
> It is convenient to have a common, threadlocal session. Especially for 
> query_property. 
> http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.scoping.ScopedSession.query_property

Yep, thats what would be available as pyramid_sqla.DBSession. For folks that 
might want to setup multiple db sessions instead of sharing a single one 
amongst their apps, I could see something fairly simple like so:

setup_dbsession(settings, name='read_only', prefix='sqlalchemy.read.')

And then in the models.py at module scope:

from pyramid_sqla import get_dbsession

DBSession = get_dbsession('read_only')

This way one could setup and easiyl use multiple db sessions in the much rarer 
case this is desired. Might make sense to use the get_dbsession setup by 
default actually, since how its acquired could then be updated later instead of 
having a 'DBSession' object hardcoded at module scope in pyramid_sqla.

Cheers,
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-de...@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to