I'm trying to figure out why I get an error with the following code:

def index():
    ids=[]
    form=SQLFORM.factory(
        Field('employees', 'list:integer'),
    )
    if form.process().accepts:
        if form.vars.employees:
            for v in form.vars.employees:
                ids.append(v)


Generally gives me a typerror: 
<type 'exceptions.ValueError'> invalid literal for int() with base 10: ''
which is pointing to: web2py/gluon/dal.py, line 1779, in represent


172.16.180.10.2013-06-19.21-09-19.05836ac3-19f9-486a-9cae-a121a7c19593
<type 'exceptions.ValueError'> invalid literal for int() with base 10: ''
VERSIONweb2py™(2, 4, 2, 'stable', datetime.datetime(2013, 3, 4, 3, 26, 21))
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)TRACEBACK

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 212, in restricted
    exec ccode in environment
  File "/home/www-data/web2py/applications/experiment/controllers/default.py" 
<https://172.16.180.11/admin/default/edit/experiment/controllers/default.py>, 
line 193, in <module>
  File "/home/www-data/web2py/gluon/globals.py", line 193, in <lambda>
    self._caller = lambda f: f()
  File "/home/www-data/web2py/applications/experiment/controllers/default.py" 
<https://172.16.180.11/admin/default/edit/experiment/controllers/default.py>, 
line 128, in index
    if form.accepts(request.vars):
  File "/home/www-data/web2py/gluon/sqlhtml.py", line 1528, in accepts
    self.vars.id = self.table.insert(**fields)
  File "/home/www-data/web2py/gluon/dal.py", line 8442, in insert
    ret =  self._db._adapter.insert(self, self._listify(fields))
  File "/home/www-data/web2py/gluon/dal.py", line 1199, in insert
    query = self._insert(table,fields)
  File "/home/www-data/web2py/gluon/dal.py", line 1190, in _insert
    values = ','.join(self.expand(v, f.type) for f, v in fields)
  File "/home/www-data/web2py/gluon/dal.py", line 1190, in <genexpr>
    values = ','.join(self.expand(v, f.type) for f, v in fields)
  File "/home/www-data/web2py/gluon/dal.py", line 1366, in expand
    return str(self.represent(expression,field_type))
  File "/home/www-data/web2py/gluon/dal.py", line 1779, in represent
    obj = map(int,obj)
ValueError: invalid literal for int() with base 10: ''

ERROR SNAPSHOT [image: help]

<type 'exceptions.ValueError'>(invalid literal for int() with base 10: '')

inspect attributes
Frames
   
   - 
   
   *File /home/www-data/web2py/gluon/restricted.py in restricted at line 212
   * code arguments variables
   - 
   
   *File 
   /home/www-data/web2py/applications/experiment/controllers/default.py in 
   <module> at line 193* code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/globals.py in <lambda> at line 193* 
   code arguments variables
   - 
   
   *File 
   /home/www-data/web2py/applications/experiment/controllers/default.py in 
   index at line 128* code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/sqlhtml.py in accepts at line 1528* 
   code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in insert at line 8442* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in insert at line 1199* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in _insert at line 1190* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in <genexpr> at line 1190* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in expand at line 1366* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in represent at line 1779* code 
   arguments variables
   Function argument list
   
   (self=<gluon.dal.BaseAdapter object>, obj=['4004', ''], 
   fieldtype='list:integer')
   Code listing
   
   1774.
   1775.
   1776.
   1777.
   1778.
   1779.
   
   1780.
   1781.
   1782.
   1783.
   
               elif not isinstance(obj, (list, tuple)):
                   obj = [obj]
               if field_is_type('list:string'):
                   obj = map(str,obj)
               else:
                   obj = map(int,obj)
   
           # we don't want to bar_encode json objects
           if isinstance(obj, (list, tuple)) and (not fieldtype == "json"):
               obj = bar_encode(obj)
           if obj is None:
   
   Variablesbuiltinint<type 'int'>obj['4004', '']builtinmap<built-in 
   function map>
   

-- 

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