ids = [1, 2, 3]
redirect(URL(c='test', f='side_by_side', args=(request.args(0)),
vars=dict(ids=ids)))

ids = request.vars.ids

Work as well...

The url look like that :

test/side_by_side/table?ids=1&ids=2&ids=3

I have use session.ids before, but I need to pass a list of id by the url
in order to not have to write a big infrastructure to store each "report"
constructed by user... Having everything in the url let call the same
report again and again (constructed once by selecting the differents
records with a form that than redirect on the url of the report). Then the
only thing I have to manage is a bunch of links that user can keep in a
table of report or something. The user as only to copy url and send it by
email to colleague...

:)

Richard


On Thu, Aug 8, 2013 at 5:24 PM, Kyle Flanagan <kyleflana...@gmail.com>wrote:

> This worked well. Thanks.
>
>
> On Thursday, July 18, 2013 11:18:23 AM UTC-5, Ykä Marjanen wrote:
>>
>> Hi,
>>
>> If I understood correctly, you could use 'session' to save the list, so
>> you don't have to pass it back and forth to the controller.
>>
>> E.g. session.serials = [] and then session.serials.append(x)
>>
>> Ykä
>>
>> On Thursday, July 18, 2013 6:55:52 PM UTC+3, Kyle Flanagan wrote:
>>>
>>> What's the best way to pass a Python list back to the controller, i.e.
>>> keep the list object persistent between calls? The list could get quite
>>> large so I'm not sure if request.args or request.vars is appropriate for it
>>> (well the items in the list)? The code below is a mockup of what I'm trying
>>> to achieve. The list in question is 'serials.'
>>>
>>> @auth.requires_login()
>>> def send():
>>>     """
>>>     Method for 'sending'an IBC tote to a location.
>>>     """
>>>     try:
>>>         if serials:
>>>             pass
>>>     except:
>>>         serials = list()
>>>
>>>     if request.vars["location_id"]:
>>>         if request.vars["serial_number"]:
>>>             # update the location
>>>             serials.append(request.vars["**serial_number"])
>>>
>>>         # start accepting input to update IBC's to this location
>>>         status = "Location: " + db.MyLocation[request.vars['**
>>> location_id']].name
>>>         form = SQLFORM.factory(Field('Object_**serial_number', requires=
>>> IS_IN_DB(db, 'Object.serial_number', '%(serial_number)s', orderby=db.
>>> Object.serial_**number)))
>>>         if form.process().accepted:
>>>             response.flash = form.vars.Object_serial_number
>>>             redirect(URL('send', vars=dict(location_id=request.**vars[
>>> "location_id"], serial_number=form.vars.Object**_serial_number)))
>>>     else:
>>>         # we need to pick a location
>>>         form = SQLFORM.factory(Field('send_**location', requires=
>>> IS_IN_DB(db, 'MyLocation.id', '%(name)s', orderby=db.MyLocation.name)))
>>>         if form.process().accepted:
>>>             response.flash = form.vars.send_location
>>>             redirect(URL('send', vars=dict(location_id=form.var**s.
>>> send_location)))
>>>         status = "No location"
>>>
>>>     return dict(grid=form, status=status, serials=serials, count=len(
>>> serials))
>>>
>>> Basically, the user goes to the 'send' controller, picks a location,
>>> then enters serial numbers. I'd like to keep a list going so that the user
>>> can remove a serial number from the list if they added one in error and
>>> then submit them for updating all at once.
>>>
>>  --
>
> ---
> 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.
>
>
>

-- 

--- 
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.

Reply via email to