In my views, I have:
{{=A('click for more information', _href=URL("myCallback", args=[1]))}}
When the anchor button is clicked, my callback will do some lookup and
processing in the db, and then will redirect to a new page populated with
the new information:
def search_results():
resultSet = request.args(0)
# Build HTML helpers using resultSet
div = DIV(.....)
return dict(div=div)
def myButton():
# Figure out the id from the request
someId = request.args(0)
# get some data from db using the id
resultSet = db(....)
# want to redirect to another page with the new data in the resultSet
redirect(URL('search_results', args=resultSet))
But doing the redirect with the resultSet args will screw up the URL and
I'll end up with an invalid request.
I've thought of two ways around this:
1) Create a temporary session variable and store the resultSet there. Once
I'm done with the data, I'll explicitly clear it.
2) Instead of doing the database logic in the callback, pass the id to the
search_results() and do the database logic there.
I'm hesitant to adopt the first option because it seems messy to create a
bunch of session variables for temporary things (unless this is standard
practice?).
The second option seems okay, but I'm afraid that the code will become too
specific to that particular anchor tag. That is, if I create a new anchor
tag to do some other search, the database logic may be different than the
one inside the search_results(). For this, I guess the better question
should be if the database logic code should live in the callback function
or in the target redirect controller function?
In spite of this, what would be the clean or proper way of sending data
with a redirect from a callback function?
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.