[Zope-dev] Re: zope.sqlalchemy

Christian Theune ct at gocept.com
Tue May 6 17:55:01 EDT 2008


Hi,

On Tue, May 06, 2008 at 12:53:05PM -0400, Michael Bayer wrote:
>
> On May 6, 2008, at 12:14 PM, Laurence Rowe wrote:
>
>> Martijn Faassen wrote:
>>> One thing I understood from Christian Theune is that with scoped  
>>> sessions, explicit session.save() is not always necessary. Since I  
>>> see it being used here, could you perhaps comment on this?
>>
>> Registering a mapper with Session.mapper would work with this  
>> extension, but I'm reluctant to recommend it for two reasons: I don't 
>> know how it works with the declarative plugin; and it necessarily 
>> limits mapped classes to a single Session and therefor a single engine. 
>> In a zope context I think it's quite likely that you could have the 
>> same classes mapped to different databases (i.e. two instances of a 
>> single application).
>
> hi there -
>
> a little background on the "save_on_init" option of Session.mapper.    
> This behavior has its roots way back in SQLAlchemy 0.1, when there was  
> no Session or Query or anything like that, and objects, when  
> instantiated, went directly to a thread-local registry automatically.   
> When SQLA 0.2 came out, we introduced all the additional constructs like 
> Session and such which are familiar today, but extensions were provided 
> which, when enabled, would re-enable the 0.1 behavior of "everything 
> threadlocal/automatic" in a similar way.   Ultimately thats where 
> Session.mapper comes from.

That's interesting, thanks for the heads-up. For some reason I didn't hit that
and was quite happy with save on init (I obviously only use one database at a
time ...) but the reasons and concerns given tell me that our core transaction
integration shouldn't force this onto people and we might not want to use it
for grok at all.

In fact at the sprint we discussed the similarities and differences of RDB
versus ODB and found that the step of 'add an object to the db' is actually
two functions (in one gesture) in the ODB: relate object B to object A
and, therefore add it to the same database as object A is in.

Whereas (due to the mapping of classes to tables) in RDB we only need to tell
which database to go to. Those are similar but differen gestures and I'm not
sure we had a definitive result when discussing this.


Christian

-- 
gocept gmbh & co. kg - forsterstrasse 29 - 06112 halle (saale) - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


More information about the Zope-Dev mailing list