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 #1883 (closed defect: duplicate)

Opened 11 years ago

Last modified 10 years ago

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

  • Version changed from 1.0.4.4 to trunk
  • Milestone set to 2.0-preview-2

comment:2 Changed 11 years ago by mramm

  • Milestone changed from 2.0-preview-2 to 2.0

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

comment:4 Changed 10 years ago 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.

comment:5 Changed 10 years ago by mramm

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