I agree that there is a need for this -- it has come up several times for
me now -- however, I prefer my proposal (pretty printed here:
https://gist.github.com/1957251 , code below...) mentioned in the topic
"Class based views: A standard hook for http-method-independent code"
(https://groups.google.com/d/topic/django-developers/7c7aI-slGNc/discussion).
Instead of separating the handler, I proposed a prepare_view method.
def dispatch(self, request, *args, **kwargs):
if request.method.lower() in self.http_method_names:
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
self.prepare_view(request, handler, *args, **kwargs)
return handler(request, *args, **kwargs)
def prepare_view(self, request, handler, *args, **kwargs):
"""Set local variables before the dispatch handler is called."""
self.request = request
self.args = args
self.kwargs = kwargs
On Wednesday, April 11, 2012 7:12:51 AM UTC+1, schinckel wrote:
I agree: but this means that the actual dispatcher (that, according to the
comments,
"dispatch[es] to the right method", is called handle(), rather than
dispatch.
Perhaps the assignation of request/args/kwargs could happen before dispatch
is
called?
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-developers/-/yMkwcy8ehnkJ.
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/django-developers?hl=en.