#6020: Group comparing with basestring
---------------------------------------------+------------------------------
Reporter:  italomaia <[EMAIL PROTECTED]>  |       Owner:  nobody                
  
  Status:  new                               |   Component:  Contrib apps       
     
 Version:  SVN                               |    Keywords:  auth, group, 
improviment
   Stage:  Unreviewed                        |   Has_patch:  0                  
     
---------------------------------------------+------------------------------
 Sometimes, i have to check is a user is in a particular group(from auth),
 and i have to load the group
 i'm checking against, before i can use the "in" operator. Something like
 this:
 {{{
 MyGroupName="badass_people"
 group=Group.objects.get(name=MyGroupName)
 if group in user.groups:
     ...
 else:
     ...
 }}}
 I would like to suggest the overwrite of the method __cmp__, so that
 something like this:
 {{{
 group="badass_people"
 if group in user.groups:
     ...
 else:
     ...
 }}}


 I believe the code to do so is something like this:

 {{{
 class Group(models.Model):
     #stuff stuff ...
     def __cmp__(self, group):
         if isinstance(group, basestring):
             return cmp(self.name,group)
     #more stuff...
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/6020>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to