[Zope3-Users] sqlobject and psycopg
Jim Fulton
jim at zope.com
Wed Feb 9 09:52:08 EST 2005
Luca Manini wrote:
> Hi,
>
> I have some simple Python classes that use SQLObject and PostgreSQL
> for persistence (both from Debian unstable).
>
> I'm trying to integrate those classe in a module I'm writing for Zope
> 3 (Zope 3 from svn).
>
> The first thing I've tried is to make a folderish class with a view
> that list the instances of my class.
>
> Getting the instances is very easy from plain Python as class
> SQLObject has two methods setConnection() and select() that do the
> job.
>
> My problem is that the very same code does not work from Zope. I get a
> traceback like this:
>
> File "/home/manini/projects/endian/network/trunk/zope_en/browser/views.py", line 27, in get_lines
> Product.setConnection(__connection__)
> File "/usr/lib/python2.3/site-packages/sqlobject/main.py", line 1102, in setConnection
> value = dbconnection.connectionForURI(value)
> File "/usr/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 601, in connectionForURI
> conn = self.schemeBuilders[scheme]().connectionFromURI(uri)
> File "/usr/lib/python2.3/site-packages/sqlobject/postgres/pgconnection.py", line 45, in connectionFromURI
> return cls(host=host, db=path, user=user, passwd=password, **args)
> File "/usr/lib/python2.3/site-packages/sqlobject/postgres/pgconnection.py", line 24, in __init__
> import psycopg
> File "/usr/local/src/zope_3/trunk/src/zodbcode/module.py", line 274, in __import__
> return self._saved_import(name, globals, locals, fromlist)
> File "/usr/local/src/zope_3/trunk/src/zodbcode/module.py", line 271, in __import__
> fromlist)
> File "/usr/local/src/zope_3/trunk/src/zodbcode/module.py", line 239, in _import
> mod = registry.findModule(fullname)
> AttributeError: 'str' object has no attribute 'findModule'
As Stephan noted, this is almost certainly due to a bug in Zope 3's
persistent module code. I suggest trying again on Stephan's branch.
If that doesn't work, then perhaps you could submit an issue to the collector.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-users
mailing list