#16139: Pass request object to URL resolvers so custom despatchers can use more
than just path.
-------------------------+------------------------------
 Reporter:  alexsdutton  |          Owner:  nobody
     Type:  New feature  |         Status:  new
Milestone:               |      Component:  Core (Other)
  Version:  1.3          |       Severity:  Normal
 Keywords:  urlresolver  |   Triage Stage:  Unreviewed
Has patch:  0            |  Easy pickings:  0
-------------------------+------------------------------
 I'd like to serve a site on more than one domain using one instance of a
 Django app. To do this I was thinking of writing a custom URL resolver
 that looks at the Host header when despatching.

 At the moment I can't get at the header without trawling the stack (yuck),
 so it would be great if the URL resolver were passed the entire request
 object to play with. In the case of the built-in resolvers it wouldn't be
 used, but it'd allow others to extend the resolving process in new and
 exciting ways.

 WRT backwards compatibility it gets a bit fun, as we really don't want to
 be changing the signature of the resolve method. It might be possible to
 add a new resolve_request method that takes a request object, not a
 string. If this doesn't exist on the resolver it tries the current way.
 Any custom resolvers wouldn't know about the new method, but that would
 only be an issue if they want to use the new functionality.

 This can probably be as simple as replacing the current calls to resolve()
 with:

 {{{
 try:
     callback, callback_args, callback_kwargs =
 resolver.resolve_request(request)
 except (AttributeError, NotImplementedError), e:
     callback, callback_args, callback_kwargs =
 resolver.resolve(request.path_info)
 }}}

 If this is a feature that's looked upon favourably, I'm happy to put a
 patch together.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16139>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to