Hello everyone,
I am currently working on a Pylons project, and keep on receiving the
following error from SQLAlchemy:
InvalidRequestError: stale association proxy, parent object has gone
out of scope
Here is the code for the model:
class AccountInfo(Base):
__tablename__ = 'account_info'
userid = schema.Column(types.Integer,
schema.ForeignKey("users.id"), nullable=False, primary_key=True)
enabled = schema.Column(types.Integer, default=1)
username = schema.Column(types.Unicode(25), nullable=False,unique=True)
password = schema.Column(types.Unicode(255), default=u'password')
#leveled_privs = orm.relation("PrivilegeLevel",
backref="account_info",
collection_class=attribute_mapped_collection('priv_id'))
# Below creates a relationship between AccountInfo and
PrivilegeLevel placed into a dict sorted by priv_id
perms = orm.relation("Privilege", secondary=privileges_assoc)#,
backref="account_info")
privileges = association_proxy("perms","name")
def __init__(self,info):
for k,v in info:
setattr(self, k, v)
"privileges" is the source of the problem. Whenever I try to use it in
the site, I get the previously mentioned error. I've taken a look at
the documentation on the site, and I believe that I am using it
correctly.
When I searched google, I wasn't able to find anything useful. I did
find something about removing stale cached attribute instances here:
http://www.mail-archive.com/[email protected]/msg08914.html
But I couldn't find any attributes on my instances that seemed similar
to what that user was speaking about.
Here's an example of how I'm using it, if that helps:
> "edit.perms" in myAccountInfoInstance.privileges
True
In the Python shell, it works occasionally. In a request, not at all
Is anyone able to help me?
Cody
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.