Right!

You always have the answer! The parameters of the fields added with 
auth.signature are not visible so I did not guess.

So for others, I just added the line: 
db.address.created_by.readable = db.address.modified_by.readable = db.
address.created_on.readable = db.address.modified_on.readable = True
db.auth_user.created_by.readable = db.auth_user.modified_by.readable = db.
auth_user.created_on.readable = db.auth_user.modified_on.readable = True

in the GET function to make the magic happen.

Thanks again,

Mike


Le lundi 18 avril 2016 16:53:12 UTC+2, Anthony a écrit :
>
> It only returns readable fields (notice you're also not getting 
> id_auth_user), so temporarily set all the fields to readable.
>
> Anthony
>
> On Monday, April 18, 2016 at 10:11:59 AM UTC-4, Mamisoa Andriantafika 
> wrote:
>>
>> Hi,
>>
>> Here is a very standard code:
>>
>> @request.restful()
>> def api_users():
>>     response.view = 'generic.json' # or 'generic.' + request.extension
>>     def GET(*args,**vars):
>>         patterns = [
>>             "/user[auth_user]",
>>             "/user/{auth_user.id}",
>>             "/user/{auth_user.id}/:field",
>>             "/membership[auth_membership]",
>>             "/membership/{auth_membership.group_id}/user[auth_user.id]", 
>>  # show user with selected membership
>>             "/membership/{auth_membership.group_id}/user[auth_user.id
>> ]/:field",
>>             "/address[address]",
>>             "/address/{address.id_auth_user}"
>>             ]
>>         parser = db.parse_as_rest(patterns, args, vars)
>>         data = parser.response
>>         if parser.status == 200:
>>             return dict(content=data)
>>         else:
>>             raise HTTP(parser.status, parser.error)
>>
>>
>> When I GET from this request:
>>
>> https://localhost/test/default/api_users/address/1
>>
>> it results this RESPONSE : 
>>
>> {"content": [{"town_pid11_6": "Bruxelles", "address2_pid11_4": null, 
>> "address_rank": 1, "zipcode_pid11_5": "1000", "box_num_pid11_2": null, 
>> "home_num_pid11_1": 65, "address1_pid11_3": "Rue de la Montagne", 
>> "country_pid11_7": "Belgique", "id": 2}, {"town_pid11_6": "Bruxelles", 
>> "address2_pid11_4": null, "address_rank": 2, "zipcode_pid11_5": "1000", 
>> "box_num_pid11_2": null, "home_num_pid11_1": 34, "address1_pid11_3": 
>> "Rue du gouvernement", "country_pid11_7": "Belgique", "id": 
>> 3}]}
>>
>> which does not expose the fields created_by modified_by modified_on 
>> created_on .
>>
>> although the model is:
>>
>> db.define_table('address',
>>     Field('id_auth_user', 'reference auth_user', writable = False, 
>> readable = False),
>>     Field('home_num_pid11_1', 'integer'),
>>     Field('box_num_pid11_2', 'string'),
>>     Field('address1_pid11_3', 'string'),
>>     Field('address2_pid11_4', 'string'),
>>     Field('zipcode_pid11_5', 'string'),
>>     Field('town_pid11_6', 'string'),
>>     Field('country_pid11_7', 'string'),
>>     Field('address_rank','integer'),
>>     auth.signature)
>>
>> and the fields are filled correctly on insertion. Not to mention that in 
>> the above example, the auth_signature fields are not null.
>>
>> Any idea? Or maybe there is a setting to expose them ?
>>
>>
>>
>> Le lundi 18 avril 2016 14:34:12 UTC+2, Anthony a écrit :
>>>
>>> Please show some code.
>>>
>>> On Sunday, April 17, 2016 at 6:45:58 PM UTC-4, Mamisoa Andriantafika 
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Using the REST service, a GET doesn't show the fields from 
>>>> auth_signature.
>>>>
>>>> Is there a way to make them visible from the REST api?
>>>>
>>>> Mike
>>>>
>>>

-- 
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/d/optout.

Reply via email to