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>]})
----

One of this objects is for the user john, and other for the user kratos, and I only want the Permission for the user kratos.

P.D: Other options is create the mapping using the user_id key and get something like:

   print objs[0].permissions[user1.id]
   [<__main__.Permission object at 0xa04442c>]
   print objs[0].permissions[user2.id]
   [<__main__.Permission object at 0xa04454c>]

But this always loads all the Permissions too.


Thanks.


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

Reply via email to