Hi, 

I have a similar issue:

Model:
db.define_table('t_familiares',
    Field('f_parentesco', type='string', label=T('Parentesco'), requires = 
IS_IN_SET(['Conyuge', 'Hija','Hijo','Padre','Madre','Pareja'], 
zero=T('Elige uno'), error_message='Escoge una opción válida')),
    Field('f_nombre', type='string', label=T('Nombre'), requires = 
IS_NOT_EMPTY()),
    Field('f_apellidos', type='string', label=T('Apellidos'), requires = 
IS_NOT_EMPTY()),
    Field('f_titular', db.auth_user, label=T('Titular de la Familia')),
    auth.signature,
    format='%(f_nombre)s' '%(f_apellidos)s',
    migrate=settings.migrate)

db.t_familiares.f_titular.requires= (IS_IN_DB(db,'auth_user.id','%(first_name)s 
''%(last_name)s'))

Controller:
@auth.requires_membership('gestor')
def gestor_usuarios():
    fields=[db.auth_user.id,db.auth_user.first_name,db.auth_
user.last_name,db.auth_user.email, db.auth_user.dni,db.auth_user.
f_numero_socio]
    links = [lambda row: 
A('Familiares',_href=URL("gestor","familiares_socio_manage",args=[row.id],user_signature=True),
 
_class='btn', action='view')]
    grid = SQLFORM.grid(db.auth_user, fields=fields, 
links=links, user_signature=True, details=True, deletable=True, editable= 
True)
    return locals()

It works fine but, when I follow the link 'Familiares' I go to:

Controller:
##Seleccionamos los familiares de un socio en particular
@auth.requires_membership('gestor')
def familiares_socio_manage():
    familiares =(db.t_familiares.f_titular==(request.args(0,cast=int)))
    form = SQLFORM.grid(familiares,user_signature=True)
    return locals()

*In this case the records are displayed right but the links of the grid: 
Wiew, Edit and Delete drive to a 404 ERROR NOT FOUND.*

I guess it has to be related to the user_signature value, because if I get 
it off the links I just get *NOT AUTHORIZED*

Any suggestion? Thanks

El sábado, 25 de agosto de 2012 15:52:17 UTC+2, lyn2py escribió:
>
> 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!
>>>
>>

-- 
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