Hello,

Currently implementing a method dispatcher (e.g. a single URL that
goes to different views based on HTTP method) is not feasible because
it will break decorators.

For example:
https://djangosnippets.org/snippets/2041/

In theory you could use middleware to store the request object inside
the view callback using process_view, or use frame/locals inspection
on __getattr__ from your dispatcher, but these are all very nasty
hacks.

It would be nice if Django either had a built in way to do method
based dispatching, or if base.py:get_response() was modified to pass
over the request object somehow to the callback (although that doesn't
feel particular clean either).

The use case for this would be a REST API, in theory I could move the
routing functionality into a view and decorate those methods, but then
the decorators aren't really in the right place and routing logic is
moved away from urls.py, which also feels unclean.

I'm not sure what my proposal would be at this stage, if anyone else
is interested lets get a dialog going,

Cal

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAHKQagE4RLvhLeJg%2BZPctd7FLv799mQnOgKFQEb2dTEfryheng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to