[Zope3-Users] sqlobject problem
jinty at web.de
Wed Nov 8 07:28:15 EST 2006
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:password@localhost/db'
> da = PostgresAdapter(sqlobject_dsn)
> sqlhub.processConnection = da
> and try to do something with my class, e.g.:
> I get:
> AttributeError: 'ConnectionDescriptor' object has no attribute
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
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
3. Become inventive with SQLObject sub-classing:
"""Dog for use outside Zope"""
... Dog methods ...
"""A Zope dog"""
I would probably go with 2, 3 might not work with MetaClasses, but I'm
> My reading of the sqlobject documentation
> 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
> Zope3-users mailing list
> Zope3-users at zope.org
Metropolis - "it's the first movie with a robot. And she's a woman.
And she's EVIL!!"
More information about the Zope3-users