El 04/06/12 16:37, Michael Bayer escribió:
On Jun 1, 2012, at 12:30 PM, Antonio Beamud Montero wrote:

El 01/06/12 16:59, Michael Bayer escribió:
@appender needs to be a method that just accepts a mapped object to be added to 
the collection.   then, @internally_instrumented is needed to prevent the 
collections system from placing additional insturmentation on standard methods 
like __setitem__.   Also building custom dictionary collections is very 
difficult in any case (for me as well) so you were close, and that's pretty 
good !

Only one more question.. Querying for example the ULine object, always give me 
the permissions for all objects.. Exists any way to filter that permissions by 
the User object I filter in the query, i.e. something like:

   objs = 
session.query(ULine).join(PermissionAssoc).join(Permission).join(User).filter(User.username
 == u'kratos').all()
   print objs[0].permissions
----
   MyMappedCollection({u'read': [<__main__.Permission object at 
0xa04442c>,<__main__.Permission object at 0xa04454c>]})
----
haven't looked at your example again but you'd work it out in SQL first to 
figure out the query you want, then convert to the ORM.  Is the issue that you 
don't know what the SQL is, or just how to get the Query to produce it ?

The query is easy, my problem is with the property 'permissions', associated to a object. The definition in the PermissionAssoc is:

 permissions = orm.relationship(Permission,
                                backref='association',
                                lazy=False,
                                collection_class=MyMappedCollection)

But I don't know how to configure this relationship to filter by a user (I don't know if it's possible). Like a dynamic relationship (to not query always all the permissions for all user associated to this object).

Greetings.






--
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