[Zope3-dev] Re: ZopeX3 with sqlos

Derrick 'dman' Hudson dman at dman13.dyndns.org
Mon Jul 5 20:25:36 EDT 2004


On Mon, Jul 05, 2004 at 06:42:23PM -0300, Sidnei da Silva wrote:
| On Mon, Jul 05, 2004 at 05:27:57PM -0400, Derrick 'dman' Hudson wrote:
| | I modified the SQLObjectContainer class (in
| | sqlos/container/__init_.py) adding the line
| |     classNames = ('Person',)
| | where Person is the name of the sqlos:factory configured in ZCML.
| 
| You could just as well have subclassed SQLObjectContainer.

I was going to get around to asking about that ... is that the
intended usage pattern or is there supposed to be a configuration
parameter (maybe using schema)?  Maybe sqlos should contain a
SchemaSQLObjectContainer class that provides clasNames as a schema
parameter.  That would make it easier for new users to begin
experimenting with the framework while not removing the ability to
specialize the container in filesystem code.

| | I also modified sqlobject/dbconnection.py.  Around line 434, I added
| | the line
| |     self.query = 'SELECT * FROM acl'
| | right above where it says
| |     if dbconn.debug:
| |         dbconn.printDebug(rawconn, self.query, 'Select')
| |     self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
| | 
| | 'ACL' is the name of the already-existing table I wanted to display
| | the contents of.  I kept seeing invalid SQL statements being
| | generated.  I don't know if that is a result of something else I set
| | wrong or a bug in sqlobject's trunk revision.  This hack let me
| | sidestep that issue for the time being.
| 
| Yuck! What database you are using? I suspect you are using the
| Postgres adapter with a different database.

The database backend is postgres.  The table structure and data exists
from an older project I created a while back.  I used the psycopgda
adapter from the zopeproducts CVS repository.  That DA needs updating
as it gives deprecation warnings and the installation instructions
appear out of sync with Z3 beta1.  The table itself is called 'acl'
with columns 'loginname', 'rptid', and 'type'.  The table has no
primary key (or rather, postgres considers all three columns together
as the pk).  For SQLObject I set type as the primary key because it is
an int and the others are strings.  The erroneous sql I saw generated
was 'select acl_type, from acl where 1==1' (note the comma) and
'select from acl where 0=1' (IIRC, the error anyways was nothing
between 'select' and 'from').  I haven't looked deeper into that yet,
but I do know that sqlobject 0.5 can load the tables in that db.

I forgot to mention, I also had a problem with the system finding the
db connection.  sqlobject.main.SelectResults.__iter__ would end up
with the local variable conn being None.  I worked around that by
putting _connection = connectionForURI() in my SQLObject subclass.  I
wonder if that caused some of the sql generation problems?  I don't
know.

I did, however, get the contents view of a SQLObjectContainer class to
display with data that resembles the data in the db.  That was a good
thing :-) and indicates that it is mostly "there".  I applied those
dirty hacks as a quick way to see something working and give me a
starting point.  Now I need to do some more research and fine tune
my assembly of parameters so all the logic works like it ought.

-D

-- 
"...Deep Hack Mode--that mysterious and frightening state of
consciousness where Mortal Users fear to tread."
(By Matt Welsh)
 
www: http://dman13.dyndns.org/~dman/            jabber: dman at dman13.dyndns.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20040705/a84032cc/attachment.bin


More information about the Zope3-dev mailing list