I didn't test, but you may try this :

for row in auth.groups():
    print row

row should contain the different column of auth_group table and you can
usually get those column like this row.name (column name in this example).

You could also try as_list() :

http://web2py.com/books/default/chapter/29/06#as_dict-and-as_list

If it doesn't work, use the query I wrote above :

rows = query
for row in rows:
     do stuff

Richard

On Tue, Oct 30, 2012 at 12:35 PM, Francisco Barretto <[email protected]
> wrote:

> Ok Richard, I've got it. You are right. Without parameters it works but I
> cant manage to get a userfull list out of it. Accesint the webpage doesn't
> help either, since I need to compare memberships inside the controller
> actions.
>
> I would need a list containing all user groups but I got instead, some
> kind of raw table which I don't know how to iterate with.
>
> Can you help me go further?
>
> Thanks, mate!
>
>
> On Tuesday, October 30, 2012 2:07:40 PM UTC-2, Richard wrote:
>
>> Ok!
>>
>> I read the book.
>>
>> You should not pass the user id.
>>
>> auth.groups() and not auth.groups(auth.user.id)
>>
>> Also you can go to this URL :
>>
>> http://127.0.0.1/yourappname/**default/user/groups<http://127.0.0.1/yourappname/default/user/groups>and
>>  you will get the list of group your current logged user is in.
>>
>> Richard
>>
>> On Tue, Oct 30, 2012 at 11:51 AM, Richard Vézina 
>> <[email protected]>wrote:
>>
>>> I don't know if web2py has a given command or how to use it, but this
>>> query should give you what you the information you are searching :
>>>
>>> db((db.auth_user.email == 'USER_EMAIL')&(db.auth_**membership.user_id
>>> == db.auth_user.id)&(db.auth_**group.id <http://db.auth_group.id>
>>> ==db.auth_membership.**group_id)).select(db.auth_**group.ALL)
>>>
>>> Richard
>>>
>>>
>>> On Tue, Oct 30, 2012 at 11:15 AM, Francisco Barretto <
>>> [email protected]> wrote:
>>>
>>>> Hi Folks!
>>>>
>>>> How do I list all groups that a user belong? I've found out that Auth
>>>> has this function:
>>>>
>>>> groups(self)
>>>> displays the groups and their roles for the logged in user
>>>>
>>>> I dont manage to get it working. I've tried something like this:
>>>>
>>>> def myGroups():
>>>>     return dict(auth.groups(auth.user_id)**)
>>>>
>>>> and get this error:
>>>> <type 'exceptions.TypeError'> groups() takes exactly 1 argument (2
>>>> given)
>>>>
>>>> any idea on how to do this properly? Thanks!
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>  --
>
>
>
>

-- 



Reply via email to