An association proxy is a Python descriptor attached to a class and by itself 
is not anything like the InstrumentedAttribute/relationship() object used for a 
relationship.   So it cannot be passed to mapper options that expect 
InstrumentedAttribute, or those options need to be enhanced to detect when an 
association proxy is passed in, which would be to check for its class as an 
AssociationProxy object, then call _get_property() on it to get the ultimate 
relationship().

It would be a good idea for us to stick a ".property" accessor on 
AssociationProxy so this kind of thing would work automatically but I'd want to 
have tests that it works under all kinds of join()/options() scenarios.  added 
#2236 for that.



On Jul 29, 2011, at 12:32 AM, espresso maker wrote:

> Anyone know of another sqlalchemy + beaker example I can look it?
> 
> On Jul 27, 2:05 pm, espresso maker <espressso.ma...@gmail.com> wrote:
>> Hi there,
>> 
>> I am trying to follow the setup in this 
>> examplehttp://www.sqlalchemy.org/trac/browser/examples/beaker_cachingto
>> enable beaker caching in sqlalchemy. However, I ran into an issue.
>> 
>> #1. When I try to cache a relation that happens to be an association
>> proxy I get the following error:
>> 
>> AttributeError: 'AssociationProxy' object has no attribute 'property'
>> 
>> This is how my query looks like:
>> 
>> def get_user(user_id):
>>     return Session.query(User).\
>>        options(FromCache('default', 'user')).\
>>        options(RelationshipCache('default', 'user_groups',
>> User.groups)).\
>>        get(user_id)
>> 
>> Anyone ran into this problem?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to