Ticket #1883 (closed defect: duplicate)
extend object dispatch to use HTTP verb info
| Reported by: | mramm | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.0b3 |
| Component: | TurboGears | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I think we should provide a way to specify which method is called based on HTTP verb type.
We could do this with special method names
def POST_employee(self,...)
pass
def GET_employee(self,....)
pass
or we could ask people to define an employee object which subclasses Resource and defines Get, Post, Put, and whatever other http verbs are required.
But either way, we need to make it easy and somewhat obvious call differnt methods on a resource based on the HTTP verb used in the request.
Change History
comment:1 Changed 4 years ago by mramm
- Version changed from 1.0.4.4 to trunk
- Milestone set to 2.0-preview-2
comment:3 Changed 3 years ago by jorge.vargas
I like the idea, I just don't like the approach. How about this? I think I got the inspiration from how appengine does it.
@expose('some/template/file')
def employee(self,...):
def get():
pass
def post():
pass
And you could also do
def POST_employee(self,...)
pass
def GET_employee(self,....)
pass
@expose('some/template/file')
def employee(self,...):
get = GET_employee
post = POST_employee
last but not least we could just provide a check so you can do
@expose()
def employee(self):
if tg.is_get():
pass