From manini.luca at tiscali.it Sun Feb 20 17:52:23 2005 From: manini.luca at tiscali.it (Luca Manini) Date: Sun, 20 Feb 2005 17:52:23 +0100 Subject: [Z3-sqlos] Problems with the SQLOS 'example' Message-ID: <16920.49223.495874.609465@paperino.local> Hi, I'm trying to use SQLOS in order to reuse some SQLObject (PostgreSQL) classes (not written by me) in Zope 3. I've read the doc at http://codespeak.net/z3/sqlos/index.html but I can not get the 'example' running, but I think I'm quite close :-) I've asked for help on the zope-3-users ML with no result (yet?). I took notes (see below) of everithing I've done (from a fresh start). Can anybody help me? Of course feel free to ask for more info! ===================== My try at using SQLOS ===================== This notes are being written as I try to use SQLOS; obiviously in order to use SQLObject's bases classes from Zope 3. Doc ====== http://codespeak.net/z3/sqlos/ Parts ===== 1) Zope 3 from svn svn co svn://svn.zope.org/repos/main/Zope3/tags/ZopeInterface-3.0.1 into /usr/local/src Instance created in ZOPE_INSTANCE=/usr/local/var/zope_sqlos_try 2) sqlos from svn svn co http://codespeak.net/svn/z3/sqlos/trunk into $ZOPE_INSTANCE/lib/python/sqlos 3) SQLObject from Debian (unstable - version 0.6-1) apt-get install python2.3-sqlobject 4) psycopgda from svn svn co svn://svn.zope.org/repos/main/psycopgda/trunk into $ZOPE_INSTANCE/lib/python/psycopgda 5) following the doc at codespeak I'll make a module called 'contacts', with a module contacts/people.py with single class Person (SQLOS) that implements the interface IPerson defined in contacts/interfaces.py. Steps ===== 1) create a go.sh script in contacts to set up PYTHONPATH (if needed) and run ZOPE_INSTANCE/bin/run_zope 2) check Zope comes up ... OK 3) make contacts module ./__init__.py # empty ./configure.zcml # as per doc ./contacts-configure.zcml # standard ./go.sh # simple ./interfaces.py # as per doc ./makefile # just for clean ./people.py # as per doc 4) cp contacts-configure.zcml in etc/packege-includes add ZOPE_INSTANCE to PYTHONPATH in go.sh ./go.sh BANG!!!! :: zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/usr/local/var/zope_sqlos_try/etc/site.zcml", line 6.2-6.55 ZopeXMLConfigurationError: File "/usr/local/var/zope_sqlos_try/etc/ package-includes/contacts-configure.zcml", line 1.0-1.29 ZopeXMLConfigurationError: File "/usr/local/ var/zope_sqlos_try/contacts/configure.zcml", line 24.2 ConfigurationError: ('Unknown directive', u'http://namespaces.sqlobject.org/sqlos', u'factory') OK, my configure.zcml (as per doc) contains a factory statement (???) that comes from the sqlos namespace:: It seems Zope 3 does not know about the namespace. I see that in the sqlos module there is a meta.zcml file and in package-includes there are many *-meta.zcml that import packages and include meta.zcml files. So let's try adding a sqlos-configure.zcml to package-includes:: > cat ......./etc/package-includes/sqlos-configure.zcml > cat ......./etc/package-includes/sqlos-meta.zcml ./go.sh BANG!!!! :: zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/usr/local/var/zope_sqlos_try/etc/site.zcml", line 6.2-6.55 ZopeXMLConfigurationError: File "/usr/local/var/zope_sqlos_try/etc/package-includes/ contacts-configure.zcml", line 1.0-1.29 ZopeXMLConfigurationError: File "/usr/local/var/zope_sqlos_try/ contacts/configure.zcml", line 24.2-28.10 ConfigurationError: ('Missing parameter:', 'component') OK, in ../lib/python/sqlos/metadirectives.py I find:: class IFactoryDirective(Interface): """ Define a factory """ component = GlobalObject( title=u"Component to be used", required=True) OK, adding the component seems to fix that:: Zope comes up and I have two new 'addable types': SQLObjectContainer and SQLObjectPrincipalSource. Adding any of them do work, but (of course) there is nothing to add into. 5) Now it is time to add a connection! As per docs, I add this to configure.zcml:: Zope 3 comes up, but no news ... 6) Define a container .... As per doc, interface IPersonContainer added to contacts/interfaces.py, implementation PersonContainer added to contacts/people.py, some stuff added to configure.zcml. ./go.sh ... Zope comes up, I can add a PersonContainer but the connection is wrong (and PostgreSQL was not even running...) so I changed the dsn to an existing db dsn='dbi://postgres://postgres at localhost/network' and get PostgreSQL running .... and ... BANG !!! File "/usr/local/src/ZopeInterface-3.0.1/ src/zope/app/rdb/__init__.py", line 141, in connect raise DatabaseException, str(error) DatabaseException: unpack list of wrong size -- bye, Luca From manini.luca at tiscali.it Mon Feb 21 12:23:39 2005 From: manini.luca at tiscali.it (Luca Manini) Date: Mon, 21 Feb 2005 12:23:39 +0100 Subject: [Z3-sqlos] Problems with the SQLOS 'example' In-Reply-To: <16920.49223.495874.609465@paperino.local> References: <16920.49223.495874.609465@paperino.local> Message-ID: <16921.50363.343204.379238@paperino.local> Luke> Hi, I'm trying to use SQLOS in order to reuse some SQLObject Luke> (PostgreSQL) classes (not written by me) in Zope 3. [snip] Luke> dsn='dbi://postgres://postgres at localhost/network' Uhm, this was really stupid! Fixed: and now I can create the container ... and my notes do grow. Todo: adding instances! thanks anybody anyway -- bye, Luca