Ticket #1925 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Create REST controller and add dispatch hooks for it.

Reported by: mramm Assigned to: 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

11/14/08 22:19:35 changed by mramm

  • milestone changed from 1.9.7a4 to 1.9.7b2.

12/10/08 12:43:24 changed by mramm

  • milestone changed from 1.9.7b2 to 2.0.

This may be a duplicate.

01/11/09 17:14:21 changed 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.

01/11/09 19:26:07 changed by percious

  • status changed from new to closed.
  • resolution set to fixed.

fixed in r6081. Documented in r6082.

01/12/09 12:30:44 changed by mramm

  • milestone changed from 2.0 to 2.0b3.