[Django] #23783: Support lazy redirect_to in HttpResponseRedirectBase

9 views
Skip to first unread message

Django

unread,
Nov 9, 2014, 10:14:53 AM11/9/14
to django-...@googlegroups.com
#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------
Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
`HttpResponseRedirect(reverse_lazy('name'))` fails when this object is
initialized because the reverse_lazy is immediately forced to text. In
some use cases it would be desirable for the object to be created and the
lazy reverse be done only when it's actually needed.

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

Django

unread,
Nov 15, 2014, 10:33:23 AM11/15/14
to django-...@googlegroups.com
#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------------------------

Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by MattBlack85):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

can you add your use case please?

--
Ticket URL: <https://code.djangoproject.com/ticket/23783#comment:1>

Django

unread,
Nov 15, 2014, 11:04:01 AM11/15/14
to django-...@googlegroups.com
#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------------------------

Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by rednaw):

Regardless of the use case, your issue should be able to be solved like
this:

{{{
from django.core.urlresolvers import reverse
from django.http.response import HttpResponseRedirect
from django.utils.functional import SimpleLazyObject

def my_view(request):
SimpleLazyObject(lambda:
HttpResponseRedirect(reverse('core:frontpage')))
}}}

But unfortunately this doesn't work at the moment because `LazyObject`
(which `SimpleLazyObject` implements) doesn't implement `__iter__`. This
is required because the `BaseHandler` of `wsgiref` loops through response
objects, which invokes `__iter__`, but if since `LazyObject` doesn't
implement `__iter__` it falls back to `__getitem__` which won't work.

I opened an issue for this:
https://code.djangoproject.com/ticket/23838

I'll make a pull request for the `__iter__` method, when that will be
merged, the code snipped above will work.

--
Ticket URL: <https://code.djangoproject.com/ticket/23783#comment:2>

Django

unread,
Nov 15, 2014, 11:07:08 AM11/15/14
to django-...@googlegroups.com
#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------------------------

Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by rednaw):

* cc: gitaarik@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23783#comment:3>

Django

unread,
Nov 21, 2014, 4:15:00 PM11/21/14
to django-...@googlegroups.com
#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------------------------
Reporter: Kronuz | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.7
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => needsinfo


Comment:

Closing as "needs info" in absence of a use case and/or confirmation that
the related ticket won't solve this.

--
Ticket URL: <https://code.djangoproject.com/ticket/23783#comment:4>

Reply all
Reply to author
Forward
0 new messages