On Fri, Feb 11, 2011 at 5:00 AM, He Shiming <[email protected]> wrote:
> Dear Community,
>
> I'm wondering how to add a custom action to a rest controller?
>
> I used `paster restcontroller user users` to create UsersController.
> Besides rest-style actions, I would like to add a custom one, so I
> put:
>
> def validate(self):
>    return 'some stuff'
>
> However, /users/validate is always an empty page. There are also no
> error messages. Do I need a custom route to make this work?

map.resource("user", "users",
    collection={"validate": "GET"})

Or "POST", depending on what you want to use the URL for. To add a
method to a specific member, such as /users/1/ask_delete :

map.resource("user", "users",
    member={"ask_delete": "GET"})

Documentation here:
http://routes.groovie.org/restful.html#resource-options

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to