[storm] Reference to Proxy?
Matthias Urlichs
matthias at urlichs.de
Tue Jul 7 17:11:43 BST 2009
Hi,
I have a database that's structured like a reverse infoheritance model,
i.e. there's a main table with basic object relationship info, and a huge
heap of detail tables with different content.
Sort of like this:
class Base(object):
__storm_table__ = "base"
id = Int(primary=True) # my ID
parent_id = Int() # one of several r'ship fields
parent = Reference(parent_id,id)
discriminator = Int() # which detail table to use?
class DetailBase(object):
id = Int(primary=True)
ref = Reference(id,Base.id) # points to the Base table, obviously
parent = Proxy(ref,Base.parent)
class DetailOne(DetailBase):
_discriminator = 1 # associated with Base.discriminator via a metaclass,
# irrelevant for now
def __init__(self):
self.parent = None
Storm crashes on the last line:
File "/usr/lib/python2.5/site-packages/storm/references.py", line 418, in __set__
return self._remote_prop.__set__(self._reference.__get__(obj), value)
File "/usr/lib/python2.5/site-packages/storm/references.py", line 399, in __get__
obj._remote_prop = resolver.resolve_one(obj._unresolved_prop)
File "/usr/lib/python2.5/site-packages/storm/references.py", line 887, in resolve_one
return _find_descriptor_obj(self._used_cls, property)
File "/usr/lib/python2.5/site-packages/storm/references.py", line 916, in _find_descriptor_obj
raise RuntimeError("Reference used in an unknown class")
This seems not to work because the proxy points to a reference.
What would it take to fix that? Is there a workaround?
I already tried to modify DetailBase like this:
parent_id = Proxy(_obj, _BaseObject.parent_id)
parent = Reference(parent_id,BaseObject.id)
File "/usr/lib/python2.5/site-packages/storm/references.py", line 183, in __set__
self._relation.unlink(get_obj_info(local), remote_info, True)
File "/usr/lib/python2.5/site-packages/storm/references.py", line 715, in unlink
local_vars[local_column].set(None)
--
More information about the storm
mailing list