I have an idea for the URL dispatcher, and I'd like to know what your thoughts
are.
Often - not always but often - a Django URL will map to a model instance via a
URLconf and a view.
I can think of a few uses for a feature that used Django's URLconfs to return
the model instance, if there is one, mapped to by a particular URL.
In other words, one would feed a URL to the system, which would return a model
instance, if one could be uniquely associated with that URL.
Examples of the utility of this idea:
* applications that handle links to other Django models using generic content
types often make the admin user select the object's class and instance; this
feature would allow them also to enter a URL into a form, and the system would
then select the object's class and instance, if a match can be found
* web server logs and analytics reports list URLs visited, that then have to be
interpreted; from this one could obtain a report listing actual things that
visitors were interested in
* it could be an easy way to get to the admin URL for any model instance from
its URL
Currently, Django's URLconfs are used to call views. But, I think it would be
feasible to amend them so that they could also return an object, using optional
arguments to ask it to do that instead of calling the view.
As I understand it, namespacing like:
(r'^help/', include('apps.help.urls', namespace='foo', app_name='bar')),
already helps map URLs and model instances. Then, if each particular URLconf
had an optional argument:
mapper = some_mapping_function
then as long as there is some way to tell the URL dispatcher that it should not
call the view, but instead call the mapper, it will return the model instance
if it finds one.
So my questions are:
* would this functionality be valuable
* is the concept viable
* and would it be worth the effort to develop it?
I'd certainly have a lot of use for it myself, but I don't know whether it
would be more widely useful, and I don't fully understand what would be
involved in implementing it.
Daniele
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.