On Wed, Nov 08, 2006 at 11:37:43AM +1300, Andrew Groom wrote:
> Hi All,
> I've got a Zope3 app consisting of some sqlos classes for database 
> access (against a postgres database) and I need to write a script for 
> some batch processing of database content outside of Zope.
> The problem is that when I try to initialize a connection for sqlos 
> objects, e.g.:
> sqlobject_dsn = 'dbi://user:[EMAIL PROTECTED]/db'
> da = PostgresAdapter(sqlobject_dsn)
> sqlhub.processConnection = da
> and try to do something with my class, e.g.:
> DBClass.select().count()
> I get:
> AttributeError: 'ConnectionDescriptor' object has no attribute 
> 'accumulateSelect'

Probably because you are mixing in SQLOS into your classes and then
trying to manually manage the connection.

If you want to manage the connections and transactions yourself, then
use straight SQLObject. Otherwise, if you want your
connection/transaction management to be integrated into Zope 3, then use

So for your case I can see some possible paths to a solution without
extending sqlos:

    1. Load up your whole Z3 zcml configuration if you define your
       database adapters in zcml.
    2. Use zope.component to define an IZopeDatabaseAdapter and
       IConnectionName utilities, or zope.configuration to parse a few
       zcml files.
    3. Become inventive with SQLObject sub-classing:

        class Dog(SQLObject):
            """Dog for use outside Zope"""
            ... Dog methods ...

        class ZDog(SQLOS):
            """A Zope dog"""

I would probably go with 2, 3 might not work with MetaClasses, but I'm
not sure.

> My reading of the sqlobject documentation 
> (http://www.sqlobject.org/SQLObject.html#using-sqlobject-an-introduction) 
> is that sqlhub.processConnection is supposed to establish the connection 
> for all classes, but it doesn't seem to be the case.
> Help !!!!
> Cheers, Andrew.
> -----------------------------------
> Reurbanise - Urban Sustainability
> ph: (03) 3528 055, mobile: 0274 992 569
> http://www.reurbanise.co.nz
> _______________________________________________
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users

Brian Sutherland

Metropolis - "it's the first movie with a robot. And she's a woman.
              And she's EVIL!!"
Zope3-users mailing list

Reply via email to