I'm working with Gustavo Niemeyer, and I believe he contacted zzzeek about a similar issue. We ran into this problem in another case where there was some SQLAlchemy code that wasn't properly honoring the "passive" flag... Now, even though the fix that went in for this is still there in [EMAIL PROTECTED], some *other* code changes have regressed it back to its original condition. I've attached a minimal example showing the problem.
-r 1176 runs the test fine. -r 1177, all the way up to HEAD, error out with the relation-ed attribute evaluating to None. So something in 1176:1177 caused this regression. I was unable to figure out exactly what it was, but I hope this information should make it trivial to spot the problem.
"""
r1177 | zzzeek | 2006-03-20 20:38:54 -0800 (Mon, 20 Mar 2006)
a few changes to attributes.py to allow faster initialization of object attributes on new objects
"""
Looks related ;-)
Thanks!
--
Christopher Armstrong
International Man of Twistery
http://radix.twistedmatrix.com/
http://twistedmatrix.com/
http://canonical.com/
import os
import tempfile
from sqlalchemy import (Table, Column, Integer, ForeignKey, relation,
objectstore, mapper)
from sqlalchemy.ext.proxy import ProxyEngine
main_engine = ProxyEngine()
table_one = Table('one', main_engine,
Column('id', Integer, primary_key=True),
Column('two_id', Integer, ForeignKey('two.id')),
)
table_two = Table('two', main_engine,
Column('id', Integer, primary_key=True))
class One(object):
pass
class Two(object):
pass
Two.mapper = mapper(Two, table_two)
One.mapper = mapper(One, table_one,
properties={'two': relation(Two.mapper),
})
def test():
trans = objectstore.begin()
try:
two = Two()
two.id = 2
one = One()
one.id = 1
one.two_id = 2
except:
trans.rollback()
raise
else:
trans.commit()
one = One.mapper.get(1)
assert one.two is not None
print "Happy SQLAlchemy"
fn = tempfile.mktemp()
main_engine.connect('sqlite://filename='+fn)
try:
table_one.create()
table_two.create()
test()
finally:
if os.path.isdir(fn):
os.unlink(fn)

