| | 108 | def _handle_custom_get(self, state, remainder): |
| | 109 | method_name = remainder[-1] |
| | 110 | if method_name not in getattr(self, 'custom_actions', []): |
| | 111 | return |
| | 112 | |
| | 113 | current_controller = state.controller |
| | 114 | |
| | 115 | if (self._is_exposed(current_controller, method_name) or |
| | 116 | self._is_exposed(current_controller, 'get_%s' % method_name)): |
| | 117 | method = self._find_first_exposed(current_controller, ('get_%s' % method_name, method_name)) |
| | 118 | new_remainder = remainder[:-1] |
| | 119 | if method and self._method_matches_args(method, state, new_remainder): |
| | 120 | state.add_method(method, new_remainder) |
| | 121 | return state |
| | 122 | |
| | 123 | def _handle_custom_method(self, method, state, remainder): |
| | 124 | current_controller = state.controller |
| | 125 | method_name = method |
| | 126 | method = self._find_first_exposed(current_controller, ('post_%s' % method_name, method_name)) |
| | 127 | |
| | 128 | if method and self._method_matches_args(method, state, remainder): |
| | 129 | state.add_method(method, remainder) |
| | 130 | return state |
| | 131 | |
| | 132 | #you may not send a delete request to a non-delete function |
| | 133 | if remainder and self._is_exposed(current_controller, remainder[0]): |
| | 134 | abort(405) |
| | 135 | |
| | 136 | # there might be a sub-controller with a delete method, let's go see |
| | 137 | if remainder: |
| | 138 | sub_controller = getattr(current_controller, remainder[0], None) |
| | 139 | if sub_controller: |
| | 140 | remainder = remainder[1:] |
| | 141 | state.current_controller = sub_controller |
| | 142 | state.url_path = '/'.join(remainder) |
| | 143 | r = self._dispatch_controller(state.url_path, sub_controller, state, remainder) |
| | 144 | if r: |
| | 145 | return r |
| | 146 | return self._dispatch_first_found_default_or_lookup(state, remainder) |
| | 147 | |