Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1925 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

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:1 Changed 11 years ago by mramm

  • Milestone changed from 1.9.7a4 to 1.9.7b2

comment:2 Changed 11 years ago by mramm

  • Milestone changed from 1.9.7b2 to 2.0

This may be a duplicate.

comment:3 Changed 11 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.

comment:4 Changed 11 years ago by percious

  • Status changed from new to closed
  • Resolution set to fixed

fixed in r6081. Documented in r6082.

comment:5 Changed 11 years ago by mramm

  • Milestone changed from 2.0 to 2.0b3
Note: See TracTickets for help on using tickets.