Any thoughts about this one?

Kenneth

Aapche 2, wsgi, MySQL 5.0, web2py 1.91.4, python 2.6.5

I have defined in my model:
Field('f_total_sum_all', type='decimal',
label=T('Total Sum')),

Even float gives the same error. Only integer works.



Version
web2py™ Version 1.91.4 (2010-12-22 17:31:23)
Python Python 2.6.5: /usr/bin/python

Traceback (most recent call last):
File "/web2py/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/web2py/applications/kenneths/models/db_wizard.py", line 70, in <module>
migrate=settings.migrate)
File "/web2py/gluon/dal.py", line 3321, in define_table
polymodel=polymodel)
File "/web2py/gluon/dal.py", line 444, in create_table
precision, scale = [int(x) for x in field.type[8:-1].split(',')]
ValueError: invalid literal for int() with base 10: ''

Error snapshot help Detailed traceback description

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

inspect attributes
Exception instance attributes
__setattr__ <method-wrapper '__setattr__' of exceptions.ValueError object> __reduce_ex__ <built-in method __reduce_ex__ of exceptions.ValueError object> __getslice__ <method-wrapper '__getslice__' of exceptions.ValueError object> __getitem__ <method-wrapper '__getitem__' of exceptions.ValueError object> __setstate__ <built-in method __setstate__ of exceptions.ValueError object> __getattribute__ <method-wrapper '__getattribute__' of exceptions.ValueError object>
__str__ <method-wrapper '__str__' of exceptions.ValueError object>
args ("invalid literal for int() with base 10: ''",)
__reduce__ <built-in method __reduce__ of exceptions.ValueError object>
__format__ <built-in method __format__ of exceptions.ValueError object>
__class__ <type 'exceptions.ValueError'>
__dict__ {}
__delattr__ <method-wrapper '__delattr__' of exceptions.ValueError object>
__subclasshook__ <built-in method __subclasshook__ of type object>
__repr__ <method-wrapper '__repr__' of exceptions.ValueError object>
__init__ <method-wrapper '__init__' of exceptions.ValueError object>
__hash__ <method-wrapper '__hash__' of exceptions.ValueError object>
__sizeof__ <built-in method __sizeof__ of exceptions.ValueError object>
__doc__ 'Inappropriate argument value (of correct type).'
__unicode__ <built-in method __unicode__ of exceptions.ValueError object>
__new__ <built-in method __new__ of type object>
Frames

File /web2py/gluon/restricted.py in restricted at line 188 code arguments variables
Function argument list

(code="### we prepend t_ to tablenames and f_ to fieldn...Field('current_record','reference t_bill_item'))\n", environment={'A': <class 'gluon.html.A'>, 'Auth': <class 'gluon.tools.Auth'>, 'B': <class 'gluon.html.B'>, 'BEAUTIFY': <class 'gluon.html.BEAUTIFY'>, 'BODY': <class 'gluon.html.BODY'>, 'BR': <class 'gluon.html.BR'>, 'CENTER': <class 'gluon.html.CENTER'>, 'CLEANUP': <class 'gluon.validators.CLEANUP'>, 'CODE': <class 'gluon.html.CODE'>, 'CRYPT': <class 'gluon.validators.CRYPT'>, ...}, layer='/web2py/applications/kenneths/models/db_wizard.py')
Code listing

if type(code) == types.CodeType:
ccode = code
else:
ccode = compile2(code,layer)

exec ccode in environment

except HTTP:
raise
except Exception:
# XXX Show exception in Wing IDE if running in debugger

Variables
environment {'A': <class 'gluon.html.A'>, 'Auth': <class 'gluon.tools.Auth'>, 'B': <class 'gluon.html.B'>, 'BEAUTIFY': <class 'gluon.html.BEAUTIFY'>, 'BODY': <class 'gluon.html.BODY'>, 'BR': <class 'gluon.html.BR'>, 'CENTER': <class 'gluon.html.CENTER'>, 'CLEANUP': <class 'gluon.validators.CLEANUP'>, 'CODE': <class 'gluon.html.CODE'>, 'CRYPT': <class 'gluon.validators.CRYPT'>, ...} ccode <code object <module> at 0x2aaab001f6c0, file "/...plications/kenneths/models/db_wizard.py", line 5>
*

File /web2py/applications/kenneths/models/db_wizard.py in <module> at line 70 code arguments variables
Function argument list

()
Code listing


label=T('Created By'),writable=False,readable=False),
Field('modified_by',db.auth_user,default=auth.user_id,
label=T('Modified By'),writable=False,readable=False,
update=auth.user_id),
format='%(f_name)s',
migrate=settings.migrate)


db.define_table('t_receipt_archive',db.t_receipt,Field('current_record','reference t_receipt'))

########################################

Variables
migrate undefined
settings.migrate True
settings <Storage {'layout_theme': 'Clicker', 'subtitle':...l_server': 'localhost', 'login_method': 'local'}>
*

File /web2py/gluon/dal.py in define_table at line 3321 code arguments variables
Function argument list

(self=<DAL {'auth_permission': <Table {'ALL': <gluon.d...ab0014c90>}>, '_migrate': True, '_pool_size': 0}>, tablename='t_receipt', *fields=(<gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>, <gluon.dal.Field object>), **args={'format': '%(f_name)s', 'migrate': True})
Code listing


if migrate or self._uri=='gae':
try:
sql_locker.acquire()
self._adapter.create_table(t,migrate=migrate,
fake_migrate=fake_migrate,
polymodel=polymodel)

finally:
sql_locker.release()
else:
t._dbt = None

Variables
polymodel None
*

File /web2py/gluon/dal.py in create_table at line 444 code arguments variables
Function argument list

(self=<gluon.dal.MySQLAdapter object>, table=<Table {'to_be_paid': <gluon.dal.Field object at...by': <gluon.dal.Field object at 0x2aaab0039690>}>, migrate=True, fake_migrate=False, polymodel=None)
Code listing

foreign_key=referenced + ('(%s)' % table._db[referenced].fields[0]),
on_delete_action=field.ondelete)
elif field.type.startswith('list:reference'):
ftype = self.types[field.type[:14]]
elif field.type.startswith('decimal'):
precision, scale = [int(x) for x in field.type[8:-1].split(',')]

ftype = self.types[field.type[:7]] % \
dict(precision=precision,scale=scale)
elif not field.type in self.types:
raise SyntaxError, 'Field: unknown field type: %s for %s' % \

Variables
scale undefined
field.type 'decimal'
precision undefined
field <gluon.dal.Field object>
x ''
builtinint <type 'int'>
].split <built-in method split of str object>

Context

locals request session response
locals
TFK :
{}
constraint_name :
't_receipt_f_purchased_by__constraint'
fake_migrate :
False
field :
<gluon.dal.Field object>
fields :
['id INT AUTO_INCREMENT NOT NULL', 'f_name VARCHAR(255)', 'f_purchased_by INT, INDEX f_purchased_by__idx (f...ed_by) REFERENCES auth_user(id) ON DELETE CASCADE', 'f_purchased DATETIME', 'f_paid DATETIME', 'to_be_paid CHAR(1)']
ftype :
'CHAR(1)'
k :
'f_total_sum_all'
migrate :
True
not_null :
"NOT NULL DEFAULT 'F'"
polymodel :
None
referenced :
'auth_user'
self :
<gluon.dal.MySQLAdapter object>
sql_fields :
{'f_name': 'VARCHAR(255)', 'f_paid': 'DATETIME', 'f_purchased': 'DATETIME', 'f_purchased_by': 'INT, INDEX f_purchased_by__idx (f_purchased_by),...ed_by) REFERENCES auth_user(id) ON DELETE CASCADE', 'id': 'INT AUTO_INCREMENT NOT NULL', 'to_be_paid': 'CHAR(1)'}
sql_fields_aux :
{'f_name': 'VARCHAR(255)', 'f_paid': 'DATETIME', 'f_purchased': 'DATETIME', 'f_purchased_by': 'INT, INDEX f_purchased_by__idx (f_purchased_by),...ed_by) REFERENCES auth_user(id) ON DELETE CASCADE', 'id': 'INT AUTO_INCREMENT NOT NULL', 'to_be_paid': 'CHAR(1)'}
table :
<Table {'to_be_paid': <gluon.dal.Field object at...by': <gluon.dal.Field object at 0x2aaab0039690>}>
tablename :
't_receipt'
x :
''
request
ajax :
False
application :
'kenneths'
args :
[]
body :
<cStringIO.StringO object>
cid :
None
controller :
'default'
cookies :
<SimpleCookie: __utma='14303153.1210700238.12899...-a86975c4-95eb-4143-8375-3c535bfedb04'>
env :
<Storage {'mod_wsgi_listener_host': '', 'script_...s/web2py/', 'mod_wsgi_process_group': 'web2pys'}>
extension :
'html'
folder :
'/web2py/applications/kenneths/'
function :
'receipt_create'
get_vars :
<Storage {}>
now :
datetime.datetime(2010, 12, 27, 7, 27, 11, 841782)
post_vars :
<Storage {}>
raw_args :
None
url :
<gluon.html.XML object>
vars :
<Storage {}>
wsgi :
<Storage {'start_response': <function <lambda> a...PATH_INFO': '/kenneths/default/receipt_create'}}>
session
auth :
<Storage {'expiration': 3600, 'last_visit': date...c17a9c95', 'registration_key': None, 'id': 1L}>}>
flash :
None
response
body :
<cStringIO.StringO object>
cookies :
<SimpleCookie: session_id_kenneths='a307b89f-4f94-4789-a21e-c5505aa678ac'>
files :
[]
flash :
''
headers :
<Storage {'Expires': 'Mon, 27 Dec 2010 05:27:11 ...he, must-revalidate, post-check=0, pre-check=0'}>
menu :
[]
meta :
<Storage {}>
postprocessing :
[]
session_file :
<open file '/web2py/applications/ke...307b89f-4f94-4789-a21e-c5505aa678ac', mode 'rb+'>
session_filename :
'/web2py/applications/kenneths/sessi...-a307b89f-4f94-4789-a21e-c5505aa678ac'
session_id :
'81.17.193.228-a307b89f-4f94-4789-a21e-c5505aa678ac'
session_id_name :
'session_id_kenneths'
status :
200
view :
'default/receipt_create.html'
In file: /web2py/applications/kenneths/models/db_wizard.py



########################################
db.define_table('t_receipt',
Field('id','id',
represent=lambda id:SPAN(id,' ',A('view',_href=URL('receipt_read',args=id)))),
Field('f_name', type='string',
label=T('Name')),
# Field('f_submitted', type='datetime',
# label=T('Submitted')),
Field('f_purchased_by', type='reference auth_user',default=auth.user_id,
label=T('Purchased By')),
Field('f_purchased', type='datetime',
label=T('Purchased')),
Field('f_paid', type='datetime',
label=T('Paid')),
Field('to_be_paid','boolean',default=False,
label=T('To be paid')),
# Field('f_total_sum', type='decimal',
# label=T('Total Sum')),
Field('f_total_sum_all', type='decimal',
label=T('Total Sum')),
Field('active','boolean',default=True,
label=T('Active'),writable=False,readable=False),
Field('created_on','datetime',default=request.now,
label=T('Created On'),writable=False,readable=False),
Field('modified_on','datetime',default=request.now,
label=T('Modified On'),writable=False,readable=False,
update=request.now),
Field('created_by',db.auth_user,default=auth.user_id,
label=T('Created By'),writable=False,readable=False),
Field('modified_by',db.auth_user,default=auth.user_id,
label=T('Modified By'),writable=False,readable=False,
update=auth.user_id),
format='%(f_name)s',
migrate=settings.migrate)

db.define_table('t_receipt_archive',db.t_receipt,Field('current_record','reference t_receipt'))



Reply via email to