It seems that, if a SQLObject is part of a join, defining a custom
__len__ on it will cause that join to hang forever. Is this expected
behavior? If so, I suggest that this be added to the documentation, as
part of a list of "don't do these things, they'll break the way
SQLObject works under the hood," as this is a pretty insidious bug to
track down. ;) But easily worked around when you know it's there.

If this isn't actually expected behavior, here's a script that
demonstrates the issue, tested on both SQLite and Postgres. The first
time you run the script, it'll work fine since the objects are cached.
After that, it'll hang on the last line.

justin


#!/usr/bin/python
from sqlobject import *
sqlhub.processConnection = connectionForURI(
"sqlite:///tmp/test.db?debug=true" )

class Container( SQLObject ):
    name = StringCol()
    items = MultipleJoin( "Item" )

class Item( SQLObject ):
    container = ForeignKey( "Container" )
    number = IntCol()
    def __len__( self ): return self.number

if not sqlhub.getConnection().tableExists( Container.sqlmeta.table ):
    Container.createTable()
    Item.createTable()
    container = Container( name="foo" )
    item = Item( container=container, number=5 )

container = Container.get(1)
print container.items


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to