Ok, I applied that change to the version I'm using (0.3.8). That
fixed it.
But I think I stumbled on another bug/inconcistancy.
If I tried to str/repr obj.attr it failed.
I looked around the code and this fix seemed to work, but I'm not sure
if it fits in with how the class is intended to
Ron wrote:
Ok, I applied that change to the version I'm using (0.3.8). That
fixed it.
But I think I stumbled on another bug/inconcistancy.
If I tried to str/repr obj.attr it failed.
[...]
Does that make sense? Or is the problem deeper in the code? It
seems to go along with what you
Now I'm having trouble with updating values in AttributeDict:
so
obj.attrs['key'] = 'somevalue' (works)
obj.attrs['key'] = 'newvalue'(second one doesn't work)
I get this error:
File /usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.8-
py2.4.egg/sqlalchemy/orm/mapper.py, line 679,
Now I'm having trouble with updating values in AttributeDict:
so
obj.attrs['key'] = 'somevalue' (works)
obj.attrs['key'] = 'newvalue'(second one doesn't work)
I get this error:
File /usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.8-
py2.4.egg/sqlalchemy/orm/mapper.py, line 679,
Ron wrote:
Now I'm having trouble with updating values in AttributeDict:
so
obj.attrs['key'] = 'somevalue' (works)
obj.attrs['key'] = 'newvalue'(second one doesn't work)
I get this error:
File /usr/local/lib/python2.4/site-packages/SQLAlchemy-0.3.8-
the legal way is the association_proxy and family.
here another shorter ... a hack:
i did have similar need - obj.somerelation.append( left=.., right=..),
so i did monkeypatch the InstrumentedList's append to use the item
returned from collection's append -
def append( self, *args,
Using the association_proxy extension in combination with your
dictionary collection class is an easy way to get this kind of
simplified access. Assuming your Attribute's value is in a
property called 'value', you can set up simple dict access like so:
class Obj(object):
attrs =
Ron wrote:
When I try the above I get this error at flush time:
InvalidRequestError: Class 'str' entity name 'None' has no mapper
associated with it
Here is my dictionary collection_class:
class AttributeDictNEW(dict):
My Attribute Dict
def append(self, item):
The association proxy will take care of Attribute construction for
you, so you can get away with just:
class AttributeDictNEW(dict):
def append(self, item):
self[item.key] = item
def __iter__(self):
return self.itervalues()
So now I if I try to get something