Ticket #1883 (closed defect: duplicate)

Opened 1 year ago

Last modified 6 months ago

extend object dispatch to use HTTP verb info

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

07/06/08 11:41:03 changed by mramm

  • version changed from 1.0.4.4 to trunk.
  • milestone set to 2.0-preview-2.

07/06/08 20:55:06 changed by mramm

  • milestone changed from 2.0-preview-2 to 2.0.

12/12/08 15:56:19 changed 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

01/11/09 17:06:54 changed by percious

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

See ticket #1925 . This is closest to the solution we will go with.

01/12/09 12:31:15 changed by mramm

  • milestone changed from 2.0 to 2.0b3.