[Twisted-web] Redirect with deferred
Vicky Lupien
vlupien at drummonddesigns.com
Wed Oct 27 11:57:40 MDT 2004
I tried this and it doesn't work
On Oct 27, 2004, at 1:50 PM, Tommi Virtanen wrote:
> Vicky Lupien wrote:
>
>> I have a little problem. I have a deferred and I want to
>> redirect after the defered is done. But it seems that my page is
>> rendered and my redirect is never done. Can someone help me.
>
> ...
>
>> class HousesQuickSearch(pagelib.QuebecPage, sqlQueries):
>>
>> def render_content(self, context, data):
>> request = context.locate(inevow.IRequest)
>> def _(data):
>> print data
>> ses = request.getSession()
>> self.houseSR =
>> sessions.ISessionPrefs(ses).get('houseSR')
>> sessions.ISessionPrefs(ses).set(self.houseSR[0], data)
>> sessions.ISessionPrefs(ses).set(self.houseSR[4], 0)
>> lengthPage =
>> sessions.ISessionPrefs(ses).get(self.houseSR[2])
>> widthPage =
>> sessions.ISessionPrefs(ses).get(self.houseSR[3])
>> currentPage, pageBatchItems = self.nextPage(data,
>> lengthPage, widthPage, 0)
>> sessions.ISessionPrefs(ses).set(self.houseSR[4],
>> currentPage)
>> sessions.ISessionPrefs(ses).set(self.houseSR[1],
>> pageBatchItems)
>> dir = '/'.join(['', '/'.join(request.prepath[0:-1]),
>> "search", "results"])
>> #this is not done
>> return request.redirect(dir)
>>
>> conditions = " where 1"
>> if request.args.get('plan_number')[0]:
>> conditions += " and
>> plan_number='"+str(request.args.get('plan_number')[0])+"'"
>> sql = self.getHouseSearchResultsInfo(conditions)
>> dbpool =
>> request.getSession().guard.resource.portal.realm.dbpool
>> searchResults = dbpool.runQueryDict(sql)
>> searchResults.addCallback(_)
>
> Your indentation seems to be really all over the place, I'm assuming
> your "return request.redirect(dir)" is inside def _. Try adding a
> "return searchResults" at the bottom of render_content.
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
More information about the Twisted-web
mailing list