Using my new Google Groups super 
powers<https://groups.google.com/d/msg/web2py/trtS-S-4exs/aTLXn1yESboJ>, 
I have edited your original post, so if you'd like, you can delete this 
correction and we can pretend this never happened. ;-)

Anthony

On Thursday, June 21, 2012 6:40:37 PM UTC-4, Massimo Di Pierro wrote:
>
> Silly me. This
>
> def PUT(table_name,record_id):
>
> return db(db[table_name]._id==record_id).delete()
>
>
> was supposed to be
>
>
> def DELETE(table_name,record_id):
>
> return db(db[table_name]._id==record_id).delete()
>
>
> On Thursday, 21 June 2012 13:38:01 UTC-5, Derek wrote:
>>
>> Looks like you have Get, Post, and PUT and PUT. Where's Delete?
>>
>> On Wednesday, June 20, 2012 4:39:33 PM UTC-7, Massimo Di Pierro wrote:
>>>
>>> You can do
>>>
>>> @request.restful()
>>> def api():
>>>     response.view = 'generic.'+request.extension
>>>     def GET(*args,**vars):
>>>         patterns = 'auto'
>>>         parser = db.parse_as_rest(patterns,args,vars)
>>>         if parser.status == 200:
>>>             return dict(content=parser.response)
>>>         else:
>>>             raise HTTP(parser.status,parser.error)
>>>     def POST(table_name,**vars):
>>>         return db[table_name].validate_and_insert(**vars)
>>>
>>>     def PUT(table_name,record_id,**vars):
>>>
>>>         return db(db[table_name]._id==record_id).update(**vars)
>>>
>>>     def PUT(table_name,record_id):
>>>
>>> return db(db[table_name]._id==record_id).delete()
>>>
>>>     return locals()
>>>
>>>
>>> On Wednesday, 20 June 2012 11:30:26 UTC-5, Osama Hussain wrote:
>>>>
>>>> Using the following code web2py generated all possible patterns for all 
>>>> my tables for GET and POST methods:
>>>>
>>>> @request.restful()
>>>> def api():
>>>>     response.view = 'generic.'+request.extension
>>>>     def GET(*args,**vars):
>>>>         patterns = 'auto'
>>>>         parser = db.parse_as_rest(patterns,args,vars)
>>>>         if parser.status == 200:
>>>>             return dict(content=parser.response)
>>>>         else:
>>>>             raise HTTP(parser.status,parser.error)
>>>>     def POST(table_name,**vars):
>>>>         return db[table_name].validate_and_insert(**vars)
>>>>     return locals()
>>>>
>>>>
>>>> Is it possible to have patterns generated for PUT and DELETE methods?
>>>>
>>>>

-- 



Reply via email to