[storm] Reference to Proxy?
BožoDragojevič
bozo.dragojevic at gmail.com
Wed Jul 8 00:33:27 BST 2009
Matthias Urlichs <matthias at ...> writes:
>
> 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")
>
I've uploaded the changes that were needed to 0.10 to pull this off at
lp:~bozo-dragojevic-joost/storm/proxiable-references
Not sure it's directly useable with 0.14 -- I had some trouble when I tried
upgrading from 0.10, but don't remember if it was related to this or some other
local modifications that I did...
Bozzo
More information about the storm
mailing list