Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread Dave S


On Tuesday, March 13, 2018 at 9:25:44 PM UTC-7, yogeshwar khalkar wrote:
>
> Hi Leonel,
>
> print request.env.request_method 
>
> prints -  "OPTIONS"
>
> Thanks,
> Yogeshwar
>
>
Ah, the Angular library is doing a two-step.  OPTIONS is a request for the 
supported (HTTP) verbs.  I'm kind of surprised to see it, but you can try 
doing a 

def UpdateAgenda():
   def OPTIONS: 
  return "POST,OPTIONS"
   [...]


Note:  in my node.js code where I handle OPTIONS, I have both returning a 
string as above and returning JSON.  I haven't worked with it recently 
enough to remember what the traces looked like.

/dps

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread yogeshwar khalkar
Hi Leonel,

print request.env.request_method

prints -  "OPTIONS"

Thanks,
Yogeshwar

On Wed, Mar 14, 2018 at 2:19 AM, Val K  wrote:

> And keep in mind that 'return locals()' should be related to updateAgenda,
> not PUT + I think it should be PUT(id, **kw) because you pass additional
> payload, otherwise  you'll get 'bad request'
>
> --
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: call to PUT restapi from angular

2018-03-13 Thread yogeshwar khalkar
Still don't work.
It returns 405 method not found.
On Mar 13, 2018 7:00 PM, "Leonel Câmara"  wrote:

> You're missing a return locals()
>
>
> @request.restful()
> def updateAgenda():
>
> def PUT(id):
> data = json(request.body.read())
> ret = db(db.agenda.id 
> 
>  == id]).update(**data)
> return ret
> return locals() # the restful decorator uses this dictionary to get the 
> correct function for each method
>
> --
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.