Re: how to use several Bases with config.include and a shared DBSession

2011-12-17 Thread Chris Withers
On 16/12/2011 23:48, Michael Bayer wrote: I was just looking to express (and top post, its just easier) that right now the sharing the base patterns arent' nailed down, but that it can be whatever. We can make it work whatever way people think should become a best practice. Though usually things

Re: how to use several Bases with config.include and a shared DBSession

2011-12-17 Thread Viktor Nagy
As far as I could understand the SQLAlchemy docs (especially [1], some kind of a centralised session handling is a must have, as the current habit of defining a DBSession = scoped_session actually create separate session factories, and only the session provided by each of these are the same. That

Re: how to use several Bases with config.include and a shared DBSession

2011-12-17 Thread Michael Bayer
On Dec 17, 2011, at 4:40 AM, Chris Withers wrote: On 16/12/2011 23:48, Michael Bayer wrote: I was just looking to express (and top post, its just easier) that right now the sharing the base patterns arent' nailed down, but that it can be whatever. We can make it work whatever way people

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Chris McDonough
On Fri, 2011-12-16 at 02:02 +0100, Viktor Nagy wrote: hi, I'm no SQLAlchemy expert but out of curiosity, why can't there be a master package that all the apps depend on that declares a Base that all the other packages depend on and import from? - C I'm stuck and sweating with a should

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Robert Forkel
sqlahelpers tried to do exactly this; but this approach makes it impossible to provide arguments for the construction of the declarative base [1]. I moved away from sqlahelpers because I wanted to supply my own base class. regards, robert [1]

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Michael Merickel
In SQLAlchemy the metadata is the central object that binds tables together and describes their relationships. It is not possible to describe relationships between tables that are defined using different metadata objects. As you know already, each Base creates its own shared metadata object

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Robert Forkel
On the other hand, I'm not doing anything in my custom cls passed to declarative_base which could not be done in a mixin class [1]. [1] http://www.sqlalchemy.org/docs/orm/extensions/declarative.html#mixin-and-custom-base-classes On Fri, Dec 16, 2011 at 9:21 AM, Robert Forkel

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Mike Orr
On Fri, Dec 16, 2011 at 12:23 AM, Michael Merickel mmeri...@gmail.com wrote: In SQLAlchemy the metadata is the central object that binds tables together and describes their relationships. It is not possible to describe relationships between tables that are defined using different metadata

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Michael Merickel
I don't see a different solution in here. It is all just an extension of the you must share something idea. I could've explicitly pointed out all the possible ways to inject a common metadata into the declarative base, etc but in the end you still have a common metadata that you import/inject.

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Chris Withers
Sorry to top-post, but this is one of the reasons I wrote mortar_rdb, writing offline from memory, the url is: http://packages.python.org/mortar_rdb. Anyway, have a read of the docs, it solves the Base-shared-across-packages problem as well as providing session and transaction management.

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Viktor Nagy
Hi guys, thanks for all the info. My goal is to reuse existing apps that might define their own Base classes, but I would like to have foreign key relationships into many directions. Actually, for the moment, it seems to me that ForeignKey(MyClass.id) instead of string based

Re: how to use several Bases with config.include and a shared DBSession

2011-12-16 Thread Mike Orr
On Fri, Dec 16, 2011 at 11:20 AM, Chris Withers ch...@simplistix.co.uk wrote: Sorry to top-post, but this is one of the reasons I wrote mortar_rdb, writing offline from memory, the url is: http://packages.python.org/mortar_rdb. Anyway, have a read of the docs, it solves the

Re: how to use several Bases with config.include and a shared DBSession

2011-12-15 Thread John Anderson
On 12/15/2011 07:02 PM, Viktor Nagy wrote: hi, I'm stuck and sweating with a should be simple, so common problem related sqlalchemy and portable pyramid app development. I would like bind together several apps using config.include. All these apps use their own DBSession and Base

Re: how to use several Bases with config.include and a shared DBSession

2011-12-15 Thread Viktor Nagy
On Fri, Dec 16, 2011 at 5:07 AM, John Anderson son...@gmail.com wrote: On 12/15/2011 07:02 PM, Viktor Nagy wrote: hi, I'm stuck and sweating with a should be simple, so common problem related sqlalchemy and portable pyramid app development. I would like bind together several apps using

Re: how to use several Bases with config.include and a shared DBSession

2011-12-15 Thread John Anderson
On 12/15/2011 10:25 PM, Viktor Nagy wrote: On Fri, Dec 16, 2011 at 5:07 AM, John Anderson son...@gmail.com mailto:son...@gmail.com wrote: On 12/15/2011 07:02 PM, Viktor Nagy wrote: hi, I'm stuck and sweating with a should be simple, so common problem related sqlalchemy and