Hi All!

I have users_table mapped to User model.

###

mapper(
    User,
    users_table,
    properties={
        'locality': relation(Locality, uselist=False),
        'office': relation(Office, uselist=False,
 
primaryjoin=users_table.c.office_id==offices_table.c.id,
 
foreign_keys=[users_table.c.office_id]),
        'groups': relation(Group, lazy=True,
secondary=users_groups_table, backref='users'),
        'roles': relation(Role, lazy=True,
secondary=users_roles_table, backref='users'),
        'localities': relation(Locality, lazy=True,
secondary=users_localities_table, backref='users'),
    }
)

# Caching options. A set of RelationshipCache options
# which can be applied to Query(), causing the "lazy load"
# of these attributes to be loaded from cache.
cache_user_relationships = cache.RelationshipCache('default', 'by_id',
User.locality).and_(
                           cache.RelationshipCache('default', 'by_id',
User.office)).and_(
                           cache.RelationshipCache('default', 'by_id',
User.groups)).and_(
                           cache.RelationshipCache('default', 'by_id',
User.roles)).and_(
                           cache.RelationshipCache('default', 'by_id',
User.localities))

###

When I try to invalidate query I make:

q = meta.Session.query(User).\
                 options(cache_user_relationships).\
                 options(cache.FromCache('default', 'by_username')).\
                 filter_by(username=SOME_USERNAME, disabled=False)
q.invalidate()

But this invalidate only User model data, not data cached from
relations that use RelationshipCache :( How can I invalidate
relationship cache? If it's possible I want to invalidate only
_certain_  relation cache, for example `office`.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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