Hi Micheal,

makes sense - i've implemented it and so far so good.

Some details, if it might help:
*I inject the session created in the different apps (w1, w2 or w3)
into the "models_app"
*The base class (1 unique base class used by all models) is created in
the "models app".

Thanks,

On May 20, 5:41 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On May 19, 2011, at 11:06 AM, 371c wrote:
>
>
>
> > Hi all,
>
> > Scenario: i have a couple of models that i'd like to reuse across 3
> > different web apps (w1, w2, w3).
>
> > The idea is to:
>
> > * create a separate project (eg. models_app) to be installed into the
> > python env via "python setup install" - sort of like a shared library.
>
> > * In w1, w2 and/or w3, import "models_app" to have access to the
> > shared models.
>
> > I have no idea of what could be the dangers of doing this especially
> > in respect to sqla (scoped?) sessions,  transactions and the like..
>
> > Any thoughts, alternatives?
>
> The model, that is your classes, mappers, and Table objects (lets call it the 
> class-level structure), represent a fixed structure that represent a schema 
> that may exist in any arbitrary database; the instantiation of that model, 
> i.e. individual object instances, then represent the data within a specific 
> database.    The class-level structure isn't linked to an actual database.    
> The Session on the other hand represents a handle to an active transaction in 
> a database - it then maintains individual object instances, which by their 
> association with the Session, are extensions of the Session's state which is 
> ultimately an in-memory representation of a remote transaction.
>
> So sharing the model among different applications, that is, the class-level 
> structure doesn't really have any impact on anything, its only the Session as 
> well as the *instances* of your model classes, attached to that Session, that 
> have some association with a particular database.  

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

Reply via email to