Today while working on a project not using TG I was poking around the 
identity code looking to see what the method was to get all of a user's 
permissions. I was rather surprised to see that every group the user is 
a member of is iterated through to build up the permissions[1]. Is there 
a reason that a sql join isn't used instead[2]? I would have thought a 
join was better performing.

Just wondering what I'm overlooking or misunderstanding,
Janzert

1. All the TG related code I found uses something similar to this:
     @property
     def permissions(self):
         p = set()
         for g in self.groups:
             p |= set(g.permissions)
         return p

2. Why not something like the following (untested code)?
     @property
     def permissions(self):
         p_q = session.query(Permission).join(['tg_group', 'tg_user'])
         p_q.filter_by(user_id = self.user_id)
        return p_q.all()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to