On Dec 15, 4:35 am, Ivan Sagalaev <man...@softwaremaniacs.org> wrote:
> Mike Malone wrote:
> > Well, not really. It's making a way to generate a URL based on the
> > request object global. I agree that it's not ideal, but it's not the
> > same as just making the request object global.
>
> My main gripe is not globalness of a request object itself (I agree with
> "not ideal" here) but the very idea of constructing a URL from request.
>
> > You wouldn't have any trouble in a standalone script unless you tried
> > to call the get_absolute_url() function.
>
> But I kinda want that. Here's two more usecases where using current
> request for creating URLs is broken:
>
> - If I have an API part of the service and human-readable part of the
> service on different hosts and I want to construct a reference to API
> when serving user pages.
> - If have several machines behind a load-balancing proxy that's not
> under my control and that's not telling me its hostname I don't want to
> construct URLs with internal hostnames of individual machines in cluster.
>
> In other words there are legitimate real-world cases when "current"
> requests has nothing to do the URL I want to cnstruct.

With these cases (the former more so than the latter) you are creating
URLs for an entirely separate project, not your own, essentially.  You
aren't creating URLs for that particular project, which is where a
request-aware URL creation resource is intensely useful.

We pass around request objects all over the place in order to get this
functionality.  request.build_absolute_uri is great, but it does
require that request object and passing it around - which sucks.

I am 100% with Mike on this.

> > I will reiterate that, in practice, this is a huge pain in the ass.
>
> Can you provide an example? My experience doesn't match this. My only
> minor complaint is that I sometimes forget to update default
> "example.com" generated for Site model on new installation (which should
> be fixed differently, IMO).

--

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


Reply via email to