Re: [Zope-dev] Re: Strange serializing error when commiting -> zope.sqlalchemy

2008-06-03 Thread Dieter Maurer
Hermann Himmelbauer wrote at 2008-6-3 14:00 +0200:
> ...
>Hmmm, it's not that easy: I have multiple sites on one Zope3 instance, whereas 
>every site should connect to another database. For that reason, I thought 
>about a local utility. However, this results in this serialization error.

Usually, you should not commit in a test suite.

If you do not commit, you will not have pickling problems.



-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: Strange serializing error when commiting -> zope.sqlalchemy

2008-06-03 Thread Laurence Rowe
See the long discussion on zope.sqlalchemy Integration ideas. I think
the simplest way to achieve this is to register a global utility for
each site, with the site name as the utility name perhaps.

You can then register an ISession adapter for the root object in each
site that does:

session = getUtility(ISessionContext, name=sitename)()

Also sqlalchemy.orm.session.object_session can be used to return the
session of a currently mapped object. You could register it as an
adapter for ISession too, and then ISession(context) should return the
session wherever you need it.

Laurence

2008/6/3 Hermann Himmelbauer <[EMAIL PROTECTED]>:
> Am Dienstag, 3. Juni 2008 12:21 schrieb Laurence Rowe:
>> Laurence Rowe wrote:
>> >> I found it by myself: I registered a zope.sqlalchemy related utility,
>> >> which stores an engine (self.engine = create_engine(DSN,...)) and a
>> >> scoped session (self.Session = scoped_session(sessionmaker...)). These
>> >> two objects cannot be serialized, hence the above problem.
>> >>
>> >> Now I'm unsure what to do about this problem - is there any code
>> >> available that demonstrates how to register SA engines/Sessions as
>> >> utilities?
>> >
>> > The simplest solution is to register the Session object as a global
>> > utility.
>>
>> Though that would be quite unnecessary too ;-). If you are ok with one
>> global scoped session for your app, then just use `from mymodule import
>> Session; session = Session()`.
>
> Hmmm, it's not that easy: I have multiple sites on one Zope3 instance, whereas
> every site should connect to another database. For that reason, I thought
> about a local utility. However, this results in this serialization error.
>
> Best Regards,
> Hermann
>
> --
> [EMAIL PROTECTED]
> GPG key ID: 299893C7 (on keyservers)
> FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
>
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: Strange serializing error when commiting -> zope.sqlalchemy

2008-06-03 Thread Hermann Himmelbauer
Am Dienstag, 3. Juni 2008 12:21 schrieb Laurence Rowe:
> Laurence Rowe wrote:
> >> I found it by myself: I registered a zope.sqlalchemy related utility,
> >> which stores an engine (self.engine = create_engine(DSN,...)) and a
> >> scoped session (self.Session = scoped_session(sessionmaker...)). These
> >> two objects cannot be serialized, hence the above problem.
> >>
> >> Now I'm unsure what to do about this problem - is there any code
> >> available that demonstrates how to register SA engines/Sessions as
> >> utilities?
> >
> > The simplest solution is to register the Session object as a global
> > utility.
>
> Though that would be quite unnecessary too ;-). If you are ok with one
> global scoped session for your app, then just use `from mymodule import
> Session; session = Session()`.

Hmmm, it's not that easy: I have multiple sites on one Zope3 instance, whereas 
every site should connect to another database. For that reason, I thought 
about a local utility. However, this results in this serialization error.

Best Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )