Figured it out.
I need to put user_signature=True in all the links as well.
Sorry for the noise.
On Saturday, August 25, 2012 9:52:17 PM UTC+8, lyn2py wrote:
>
> Hi Massimo,
>
> I picked Option(1).
> They both have @auth.requires_membership('Admin') and user_signature=True
> (the default setting)
> I used a logged-in account that has access to both functions.
>
> Both pages can be accessed individually, but cannot be accessed when
> either link is used.
>
> I am using the latest trunk
> Version 2.00.0 (2012-08-24 23:47:44) dev
>
>
>
> On Saturday, August 25, 2012 9:04:13 PM UTC+8, Massimo Di Pierro wrote:
>>
>> You have two options:
>>
>> 1) decorate your functions with @auth.requires_login() and user_signature
>> = True (default)
>> 2) leave the functions as they are and user_signature = False (no
>> protection)
>>
>> You cannot have a per user signature and at same time not require a
>> logged in user.
>>
>>
>>
>> On Saturday, 25 August 2012 06:53:11 UTC-5, lyn2py wrote:
>>>
>>> I have 2 SQLFORM.grids, they are:
>>>
>>> ##MODELS
>>> db.define_table('company', #each staff can only see the customers under
>>> their account
>>> Field('company_name', 'string',length=255,requires=IS_NOT_EMPTY()),
>>> Field('description','text'),
>>> format='%(company_name)s'
>>> )
>>>
>>> db.define_table('employees', #each customer has their key contacts
>>> Field('company_id','reference company',writable=False,label='Company
>>> Name'),
>>> Field('first_name', 'string',length=255,requires=IS_NOT_EMPTY()),
>>> Field('last_name', 'string',length=255,requires=IS_NOT_EMPTY()),
>>> Field('role', 'string',length=255,requires=IS_NOT_EMPTY()),
>>> )
>>>
>>> ##CONTROLLER
>>> def company():
>>> grid=SQLFORM.grid(db.company.created_by==auth.user_id,links =
>>> [lambda row: A('Add Employee',,_href=URL("default","employees",args='new')))
>>> return locals()
>>>
>>> def employees():
>>> grid=SQLFORM.grid(db.employees.created_by==auth.user_id,links =
>>> [lambda row: A('View Company
>>> Details',_href=URL("default","company",args=row.company_id)))
>>> return locals()
>>>
>>> The problem I have is, When I click on the LINK (either the *Add
>>> Employee* or the *View Company Details* links), I am told "Not
>>> Authorized".
>>> I assume it has to do with user_signature.
>>>
>>> How can I use SQLFORM.grid with user-defined links and still keep
>>> user_signature=True?
>>>
>>> If I am using it wrongly or misinterpret its correct use, please correct
>>> me.
>>>
>>> Thank you!
>>>
>>
--