Closed sileht closed 11 years ago
This will force a specific coding style for custom actions that is not enforced by pecan. I don't think we want that restriction just for the sake of the documentation. What is the motivation behind this patch? Maybe we can find another solution.
Hum, github have hidden some chars from my commit message...
My use case is : I want to generate the documentation, when I implement the following endpoint :
PUT .../alarm/
with :
class Alarm(RestController): _custom_actions = {'state' : ['GET', 'PUT']} def get_state(self): pass def put_state(self): pass
Actually this both endpoint are not introspected.
If I understand your remark, It seems when I declare VERB_ACTION method I don't need to define it in custom_actions ? If yes, I can propose a other change that dig into methods beginning http verb, instead of using custom_actions.
Cheers.
I have made some tests, _custom_actions is required in this case to have the endpoint working.
You have separate methods for each verb. Does Pecan actually call them in the way you have defined them? The docs only show using one method for each custom action.
On Mon, Sep 23, 2013 at 06:24:59AM -0700, Doug Hellmann wrote:
You have separate methods for each verb. Does Pecan actually call them in the way you have defined them? The docs only show using one method for each custom action.
Multiple method works fine.
I use it here: http://git.openstack.org/cgit/openstack/ceilometer/tree/ceilometer/api/controllers/v2.py#n1210
Mehdi Abaakouk mail: sileht@sileht.net irc: sileht
So the multiple method support for custom actions you've referenced does seem to work, though it's very poorly documented (I'll work to improve this). Here's how it's implemented in Pecan's RestController implementation:
https://github.com/stackforge/pecan/blob/master/pecan/rest.py#L184 https://github.com/stackforge/pecan/blob/master/pecan/rest.py#L234
Basically, for a custom action, it first looks for an @expose
d method named <method_name>_<path_name>
, e.g., get_state
, and falls back to just the path name, e.g., state
.
Hi
When a custom action use multiple verb, each verb look for a method named_.
Cheers,