Tuesday, December 28, 2010

Re: Replace URLResolver?

On 28 December 2010 22:43, Martin <martinskou@gmail.com> wrote:
> Hi.
>
> I would like to use subdomains in my URL-dispatch. Thats not supported
> by Django.
>
> Is it possible to replace Django URLResolver with my own? Must this be
> done as a Middleware class?

No, you can't really replace the default URLResolver without changing
any code in Django - lines 100-101 in django/core/handlers/base.py
(http://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py).
And even if you did, you would only be given the path_info of the
request, not the entire request object itself.

Your only option is middleware.

> (Why is Django URL resolver not implemented as a Middleware class?)

Besides what Brian said, it is probably for the same reason why regex
is the only way to specify URLs - there wasn't a need for anything
else when it was first designed, and given the current solution works
for nearly all cases, there have been minimal attempts to change it.

At some point, I'm considering rewriting the entire URL
resolution/reversal system to make it more modular, and submitting it
as a patch. (I bumped up against another limitation of it and had to
hack around it by changing Django code.) Don't hold your breath for
inclusion in a Django release any time soon though; as such a critical
part of Django, it'll probably be a while before it makes it into
trunk.

> Input appreciated.
>
> Thanks.
>
> /Martin
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment