Ah, now I understand what you are trying to do.

This works for me in that the Add button takes me to auth_group.  You will 
have to define an oncreate function to link the new group back to the user, 
by the way. RTFM for that.

Stare at my query until you understand how it works. 

The controller is named auth_group.py. 

@auth.requires_login()
def index(): 
    query = (
            (db.auth_group.id==db.auth_membership.group_id) &
            (db.auth_membership.user_id==auth.user.id)
            )
    form = SQLFORM.grid(query)
    return dict(form=form)

On Friday, October 25, 2013 2:34:07 AM UTC-4, Jayakumar Bellie wrote:
>
> *Web2py version:* 2.5.1-stable+timestamp.2013.06.06.15.39.19
>
>     query = ((db.auth_group.id>0) & 
> (db.auth_group.id==db.auth_membership.group_id) 
> & (db.auth_user.id==db.auth_membership.user_id) & (auth.user.id==
> db.auth_user.id))
>     #return dict(table=query)
>     displayFields = [db.auth_group.id, db.auth_group.role, 
> db.auth_group.description]
>     displayHeaders = {'auth_group.role': T('Role'), 
> 'auth_group.description' : T('Description')}
>     table = SQLFORM.grid(query,
>                          fields=displayFields,
>                          headers=displayHeaders,
>                          deletable=False,
>                          create=False,
>                          editable=False,
>                          details=False,
>                          csv=False,
>                          links=[lambda row: A("Edit", 
> _href=URL('manage_group', args=[row.auth_group.id]))],
>                          paginate=10)
>     return dict(table=table)
>
> *When I enable editable or create it will take to auth_user, but it 
> should take to auth_group*
>
>
> --------------------------------------------------------------------------------------------
> On Friday, October 25, 2013 2:45:58 AM UTC+5:30, Cliff Kachinske wrote:
>>
>> What version of Web2py?
>>
>> Can you post your code? 
>>
>> I've been using Web2py since v 1.8 and I've never seen the behavior you 
>> describe.
>>
>> On Thursday, October 24, 2013 8:51:38 AM UTC-4, Jayakumar Bellie wrote:
>>>
>>> I have tried that, it did not work.
>>>
>>> On Thursday, October 24, 2013 12:01:05 PM UTC+5:30, Niphlod wrote:
>>>>
>>>> use the field_id argument to tell the grid what id should use to 
>>>> generate the links.
>>>>
>>>> On Thursday, October 24, 2013 7:39:02 AM UTC+2, Jayakumar Bellie wrote:
>>>>>
>>>>> That does not work.
>>>>> Add button still takes to user add.
>>>>>
>>>>>
>>>>> On Thursday, October 24, 2013 1:51:26 AM UTC+5:30, Cliff Kachinske 
>>>>> wrote:
>>>>>>
>>>>>> If you want grid to manage groups, use this query: db.auth_group.id
>>>>>> >0.
>>>>>>
>>>>>> On Wednesday, October 23, 2013 4:41:46 AM UTC-4, Jayakumar Bellie 
>>>>>> wrote:
>>>>>>>
>>>>>>> When you send the query as you defined to SQLForm, it creates the 
>>>>>>> list. When you click on add it takes to auth_user add, but it should 
>>>>>>> take 
>>>>>>> to auth_group add.
>>>>>>>
>>>>>>>
>>>>>>> On Tuesday, October 22, 2013 4:11:17 PM UTC+5:30, Cliff Kachinske 
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> This defines a set of Row objects.
>>>>>>>> query = db((db.auth_group.id==db.auth_membership.group_id) & (
>>>>>>>> db.auth_user.id==db.auth_membership.user_id) & (db.auth_user.id==
>>>>>>>> auth.user.id)).select(db.auth_group.ALL)
>>>>>>>>
>>>>>>>> This is how you define a query object.
>>>>>>>> query = ((db.auth_group.id==db.auth_membership.group_id) & (
>>>>>>>> db.auth_user.id==db.auth_membership.user_id) & (db.auth_user.id==
>>>>>>>> auth.user.id))
>>>>>>>>
>>>>>>>> On Tuesday, October 22, 2013 2:05:12 AM UTC-4, Jayakumar Bellie 
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> How does that matter the my query?
>>>>>>>>> I have to give some where condition.
>>>>>>>>> Can you elaborate.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, October 18, 2013 9:05:06 PM UTC+5:30, villas wrote:
>>>>>>>>>>
>>>>>>>>>> HI Jayakumar
>>>>>>>>>>
>>>>>>>>>> Try using a query rather than a rows object.
>>>>>>>>>>
>>>>>>>>>> For example, rather than:
>>>>>>>>>>      query = db().select(db.auth_user.ALL)  ## gives a rows 
>>>>>>>>>> object,  unusable by grid
>>>>>>>>>>
>>>>>>>>>> Use this:
>>>>>>>>>>      query = db.auth_user.id>0  
>>>>>>>>>>
>>>>>>>>>> Hope you get the idea.
>>>>>>>>>> Best regards,  D
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Friday, 18 October 2013 06:43:24 UTC+1, Jayakumar Bellie wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I want to fetch all the auth_group list of a user from auth_user 
>>>>>>>>>>> mapping auth_membership.
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------
>>>>>>>>>>>     query = db((db.auth_group.id==db.auth_membership.group_id) 
>>>>>>>>>>> & (db.auth_user.id==db.auth_membership.user_id) & (
>>>>>>>>>>> db.auth_user.id==auth.user.id)).select(db.auth_group.ALL)
>>>>>>>>>>> *    # When I do the return over here, I am able to see the 
>>>>>>>>>>> required data. But when I send it to the SQLFORM.grip it through 
>>>>>>>>>>> the 
>>>>>>>>>>> execption given below*
>>>>>>>>>>> *    #return dict(table=where)                                 
>>>>>>>>>>>                                                                     
>>>>>>>>>>>         
>>>>>>>>>>>                                           *
>>>>>>>>>>>     displayFields = [db.auth_group.role, 
>>>>>>>>>>> db.auth_group.description]
>>>>>>>>>>>     displayHeaders = {'auth_group.role': T('Role'), 
>>>>>>>>>>> 'auth_group.description' : T('Description')}
>>>>>>>>>>>     table = SQLFORM.grid(query,
>>>>>>>>>>>                          #left=left,                             
>>>>>>>>>>>                                                                     
>>>>>>>>>>>         
>>>>>>>>>>>                                        
>>>>>>>>>>>                          fields=displayFields,
>>>>>>>>>>>                          headers=displayHeaders,
>>>>>>>>>>>                          deletable=False,
>>>>>>>>>>>                          create=True,
>>>>>>>>>>>                          editable=False,
>>>>>>>>>>>                          details=False,
>>>>>>>>>>>                          csv=False,
>>>>>>>>>>>                          links=[lambda row: A("Edit", 
>>>>>>>>>>> _href=URL('manage_group', args=[row.id]))],                     
>>>>>>>>>>>                                                              
>>>>>>>>>>>                          paginate=10)
>>>>>>>>>>>     return dict(table=table)
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------
>>>>>>>>>>>
>>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>>   File "/home/www-data/web2py/gluon/restricted.py", line 212, in 
>>>>>>>>>>> restricted
>>>>>>>>>>>     exec ccode in environment
>>>>>>>>>>>   File 
>>>>>>>>>>> "/home/www-data/web2py/applications/Telematics/controllers/group.py"
>>>>>>>>>>>  
>>>>>>>>>>> <http://127.0.0.1:8000/admin/default/edit/Telematics/controllers/group.py>,
>>>>>>>>>>>  line 64, in <module>
>>>>>>>>>>>   File "/home/www-data/web2py/gluon/globals.py", line 194, in 
>>>>>>>>>>> <lambda>
>>>>>>>>>>>     self._caller = lambda f: f()
>>>>>>>>>>>   File "/home/www-data/web2py/gluon/tools.py", line 3022, in f
>>>>>>>>>>>     return action(*a, **b)
>>>>>>>>>>>   File 
>>>>>>>>>>> "/home/www-data/web2py/applications/Telematics/controllers/group.py"
>>>>>>>>>>>  
>>>>>>>>>>> <http://127.0.0.1:8000/admin/default/edit/Telematics/controllers/group.py>,
>>>>>>>>>>>  line 22, in list_groups
>>>>>>>>>>>     paginate=10)
>>>>>>>>>>>   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1861, in grid
>>>>>>>>>>>     db = query._db
>>>>>>>>>>> AttributeError: 'Rows' object has no attribute '_db'
>>>>>>>>>>>
>>>>>>>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to