Given the table :
db.define_table('form1',
Field('field1, 'string'),
Field('field2', 'string'),
Field('field3', 'integer'),
Field('form1_file', 'upload', compute=fpost))
If a user is starting a form session and enter the value 2, they submit
values for:
field1_0, field2_0, field3_0
field1_1, field2_1, field3_1
and the function fpost within models looks like:
def fpost(row):
print row.values()
This will print the entered values like this:
['value1', 'value2', 'value3']
['value4', 'value5', 'value6']
These are seperate..so I need to create a dynamic array which is filled
based on the session so that the row values results in: ['value1',
'value2', 'value3', 'value4', 'value5', 'value6']
Therefore I try making a class, but I'll either get an attribute error or
something of the sort and cannot access anything using keyword row within
it.. Here is what the models looks like with this implementation:
*db1.py*
class fpost(object):
form_list=[]
def __init__(self):
fpost.form_list.append(self)
def disp_arr():
for i in fpost.form_list:
print i
disp_arr()
db.define_table('form1',
Field('field1, 'string'),
Field('field2', 'string'),
Field('field3', 'integer'),
Field('form1_file', 'upload', compute=fpost()))
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.