John_Nowlan wrote:
> Sorry. I butchered the code when I was trying to make it an example.
> It was self.login() . I'm saying this does not work, but I think it is a
> fairly common case, i.e. some logic within a method causes you to want to
> goto/call/transfer to a different method (usually based on user inputs). I
> understand it is not considered a good idea (esp. with foo.html being
> rendered under bar), but I'm not sure I buy the arguments. It is not supposed
> to be specifically a 'login' example.
>
> So trying to clean up my braindamaged pseudocode:
>
> class AController(BaseController):
> def foo(self):
> #do stuff
> print 'in foo'
> return render("/foo.html")
>
> def bar(self):
> 'v' in request.params or self.foo() # foo should not return, it
> is calling render
> print 'what am i doing here?'
> v = request.params['v'] #attribute error if I visit
> http://localhost/pylons/a/bar/. Why doesn't it render foo?
> #continue doing stuff
>
> However this code prints 'in foo' then 'what am I doing here?' and I think
> its because the request cycle is getting things confused (kind of jumping
> into another one before finishing first). While perhaps not a bug (but I'm
> not sure of that, it is indeterminate what will happen), it could be handled
> better and would be if I could throw out the response so far and restart with
> the new method (be more performant as well).
>
> But I'm no expert.
> And thanks for responses. Muchos appreciated but still wondering.
I think what you're looking for is a workflow which allows the user to be
redirected to perform an action before they can continue further. Here's a
helpful blog post which shows how something like this could be done:
http://jjinux.blogspot.com/2009/11/web-redirecting-user-back-after-some.html
In essence you have to redirect and save some context which allows you to come
back to the place from where you redirected.
- Shailesh
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.