Ticket #1925 (closed defect: fixed)
Create REST controller and add dispatch hooks for it.
| Reported by: | mramm | Owned by: | percious |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.0b3 |
| Component: | TurboGears | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
We need a HTTP verb aware controller to make generating restful resources easier.
The API we're looking for is described here:
http://pythonisito.blogspot.com/2008/07/restfulness-in-turbogears.html
class Root(controllers.RootController):
class index(RestMethod):
@expose('json')
def get(self, **kw):
return dict(method='GET', args=kw)
@expose('json')
def post(self, **kw):
return dict(method='POST', args=kw)
@expose('json')
def put(self, **kw):
return dict(method='PUT', args=kw)
# NOT exposed, for some reason
def delete(self, **kw):
return dict(method='DELETE', args=kw)
Change History
comment:2 Changed 3 years ago by mramm
- Milestone changed from 1.9.7b2 to 2.0
This may be a duplicate.
comment:3 Changed 3 years ago by percious
- Owner changed from anonymous to percious
This is probably pretty close to the solution I am after.
class Root(controllers.RootController):
def default(self, *args, **kw):
@expose('json')
def get(self, *args, **kw):
return dict(method='GET', args=kw)
@expose('json')
def post(self, *args, **kw):
return dict(method='POST', args=kw)
@expose('json')
def put(self, *args **kw):
return dict(method='PUT', args=kw)
# NOT exposed, for some reason
def delete(self, *args, **kw):
return dict(method='DELETE', args=kw)
also, see ticket #1883 for more information.
Note: See
TracTickets for help on using
tickets.