[web2py] Re: Form self-submit broken after redirection
It works like this: # index controller def index(): # some preamble if session.state == 'a': redirect(URL('thiscontoller', 'myfunc1.load', user_signature=True)) # some more states and redirects #later on def myfunc1(): form = SQLFORM.factory(Field(...the usual stuff, nothing fancy...),Field (...), Field(...)) if form.process().accepted: # process form elif form.errors: response.flash = 'error' return dict(html=form) If myfunc1 is called directly it self-submits fine. But if is reached via the index function, it doesn't self submit. Hope that clarifies. Must be something really dumb-a** simple but I'm not seeing it. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Form self-submit broken after redirection
I tried your code and it works fine for me. Maybe we need to see more of the code and understand the workflow better. On Friday, November 22, 2013 7:55:50 AM UTC-5, weheh wrote: > > It works like this: > > # index controller > def index(): > # some preamble > if session.state == 'a': > redirect(URL('thiscontoller', 'myfunc1.load', user_signature=True > )) > # some more states and redirects > > #later on > @auth.requires_signature() > def myfunc1(): > form = SQLFORM.factory(Field(...the usual stuff, nothing fancy...), > Field(...), Field(...)) > if form.process().accepted: > # process form > elif form.errors: > response.flash = 'error' > return dict(html=form) > > > If myfunc1 is called directly it self-submits fine. But if is reached via > the index function, which is triggered by a page reload, the form won't > self submit. Hope that clarifies. Must be something really dumb-a** simple > but I'm not seeing it. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Form self-submit broken after redirection
Sorry for the slow response. From within my main view, at the end, I do this: $(document).ready(function() { {{if auth.is_logged_in() and session.state:}} $("#mydialog").dialog("open"); web2py_component("{{= URL('mycontroller', 'index')}}", "mydialog"); {{pass}} }); As I write this, I'm remembering how I once wondered why web2py_component doesn't have a user_signature parameter? But that maybe is unrelated to this discussion ('tho if you have an answer to that question, too, it would be nice to know). So basically, if a dialog is open to a particular form and the user hits reload, the main page sees that there's a state variable so it opens a dialog and squirts the appropriate form back into the dialog. But then, the form won't self-submit. On Friday, November 22, 2013 10:05:19 PM UTC+8, Anthony wrote: > > I tried your code and it works fine for me. Maybe we need to see more of > the code and understand the workflow better. > > On Friday, November 22, 2013 7:55:50 AM UTC-5, weheh wrote: >> >> It works like this: >> >> # index controller >> def index(): >> # some preamble >> if session.state == 'a': >> redirect(URL('thiscontoller', 'myfunc1.load', user_signature=True >> )) >> # some more states and redirects >> >> #later on >> @auth.requires_signature() >> def myfunc1(): >> form = SQLFORM.factory(Field(...the usual stuff, nothing fancy...), >> Field(...), Field(...)) >> if form.process().accepted: >> # process form >> elif form.errors: >> response.flash = 'error' >> return dict(html=form) >> >> >> If myfunc1 is called directly it self-submits fine. But if is reached via >> the index function, which is triggered by a page reload, the form won't >> self submit. Hope that clarifies. Must be something really dumb-a** simple >> but I'm not seeing it. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Form self-submit broken after redirection
if you want to "port" the code that does the signature in python to javascript, feel free to submit it :D However, you should pass along the hmac_key, and doing so, you're exposing what you're trying hard to mask. However, it's kinda of a non-question as per the markup you posted. if your javascript is embedded in the view, you don't need the javascript to generate the signed url... any code in {{}} gets rendered by python. Anyhow, if your javascript is not embedded in the view, if needed you can still define a function in your assets that takes the url and then use var url = "{{=URL(., user_signature=True)}}" myfunction(url) bonus points for NOT embedding in static assets absolute urls (that you may need later to be "translated" by a rewrite rule) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Form self-submit broken after redirection
@Niphlod -- thanks for your insights. Sorry, I have not enough juice to dig deep enough into the web2py_component to see how it's done and then port signature into it. But if I did I would definitely submit it as web2py_component is about the single most cool thing in all of web2py. That said, the core question of why self-submit fails after the web2py_component() call remains an open mystery to me. On Thursday, November 28, 2013 3:35:45 AM UTC+8, Niphlod wrote: > > if you want to "port" the code that does the signature in python to > javascript, feel free to submit it :D > However, you should pass along the hmac_key, and doing so, you're exposing > what you're trying hard to mask. > > However, it's kinda of a non-question as per the markup you posted. if > your javascript is embedded in the view, you don't need the javascript to > generate the signed url... any code in {{}} gets rendered by python. > > Anyhow, if your javascript is not embedded in the view, if needed you can > still define a function in your assets that takes the url and then use > > var url = "{{=URL(., user_signature=True)}}" > myfunction(url) > > bonus points for NOT embedding in static assets absolute urls (that you > may need later to be "translated" by a rewrite rule) > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Form self-submit broken after redirection
Can you attach a minimal app that reproduces the problem? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.