ron_m
2011-03-03 18:08:09 UTC
I tested my app with version 1.92.1 and it works. I then copied it to trunk
and I can no longer connect to the PostgreSQL database I use.
I looked at the code in dal.py for the PostgreSQL adapter and driver_args
defaults to empty dict {}, adding some debug print code shows it is set on
the class construction to be {'check_same_thread': False} and when this is
passed to the driver an invalid keyword argument error occurs
Here is a traceback from the ticket.
web2py⢠Version 1.92.1 (2011-03-03 08:26:32) Python Python 2.6.5:
/usr/bin/python Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Traceback (most recent call last):
File "/home/camcentral/Dev/web2py-hg/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py" <http://127.0.0.1:8000/admin/default/edit/ccims/models/A_db.py>, line 22, in <module>
db = DAL('postgres://user:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
File "/home/camcentral/Dev/web2py-hg/gluon/dal.py", line 3529, in __init__
raise RuntimeError, "Failure to connect, tried 5 times:\n%s" % error
RuntimeError: Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function
Error snapshot [image: help] Detailed traceback description
<type 'exceptions.RuntimeError'>(Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function)
Frames
-
*File /home/camcentral/Dev/web2py-hg/gluon/restricted.py in restricted at
line 188* code arguments variables
Function argument list
(code='# -*- coding: utf-8 -*- \n# this file is
released...sion.table_name.requires = IS_IN_SET(db.tables)\n\n',
environment={'A': <class 'gluon.html.A'>, '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'>, 'COUPLE_MENUS': True, 'CRYPT': <class
'gluon.validators.CRYPT'>, ...},
layer='/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py')
Code listing
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
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'>, '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'>, 'COUPLE_MENUS': True, 'CRYPT': <class
'gluon.validators.CRYPT'>, ...} ccode <code object <module> at
0x30bda08, file "/home/...py-hg/applications/ccims/models/A_db.py", line 8>
-
*File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py in
<module> at line 22* code arguments variables
Function argument list
()
Code listing
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
# else use a normal relational database
#*** Add customization
# db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB
# CamCentral IMS configuration database
# db = DAL('mysql://root:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
db = DAL('postgres://user:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
## if no need for session
# session.forget()
#########################################################################
Variables DAL <class 'gluon.dal.DAL'> check_reserved undefined
POOL_SIZE 0 db undefined check_reserved_value ['all']
-
*File /home/camcentral/Dev/web2py-hg/gluon/dal.py in __init__ at line
3529* code arguments variables
Function argument list
(self=<DAL {'_lastsql': '', '_db_codec': 'UTF-8', '_ur...cc_ims',
'_pool_size': 0, '_dbname': 'postgres'}>,
uri='postgres://user:***@localhost/cc_ims', pool_size=0, folder=None,
db_codec='UTF-8', check_reserved=['all'], migrate=True, fake_migrate=False,
decode_credentials=False, driver_args={'check_same_thread': False})
and I can no longer connect to the PostgreSQL database I use.
I looked at the code in dal.py for the PostgreSQL adapter and driver_args
defaults to empty dict {}, adding some debug print code shows it is set on
the class construction to be {'check_same_thread': False} and when this is
passed to the driver an invalid keyword argument error occurs
Here is a traceback from the ticket.
web2py⢠Version 1.92.1 (2011-03-03 08:26:32) Python Python 2.6.5:
/usr/bin/python Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Traceback (most recent call last):
File "/home/camcentral/Dev/web2py-hg/gluon/restricted.py", line 188, in restricted
exec ccode in environment
File "/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py" <http://127.0.0.1:8000/admin/default/edit/ccims/models/A_db.py>, line 22, in <module>
db = DAL('postgres://user:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
File "/home/camcentral/Dev/web2py-hg/gluon/dal.py", line 3529, in __init__
raise RuntimeError, "Failure to connect, tried 5 times:\n%s" % error
RuntimeError: Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function
Error snapshot [image: help] Detailed traceback description
<type 'exceptions.RuntimeError'>(Failure to connect, tried 5 times:
'check_same_thread' is an invalid keyword argument for this function)
Frames
-
*File /home/camcentral/Dev/web2py-hg/gluon/restricted.py in restricted at
line 188* code arguments variables
Function argument list
(code='# -*- coding: utf-8 -*- \n# this file is
released...sion.table_name.requires = IS_IN_SET(db.tables)\n\n',
environment={'A': <class 'gluon.html.A'>, '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'>, 'COUPLE_MENUS': True, 'CRYPT': <class
'gluon.validators.CRYPT'>, ...},
layer='/home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py')
Code listing
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
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'>, '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'>, 'COUPLE_MENUS': True, 'CRYPT': <class
'gluon.validators.CRYPT'>, ...} ccode <code object <module> at
0x30bda08, file "/home/...py-hg/applications/ccims/models/A_db.py", line 8>
-
*File /home/camcentral/Dev/web2py-hg/applications/ccims/models/A_db.py in
<module> at line 22* code arguments variables
Function argument list
()
Code listing
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
# else use a normal relational database
#*** Add customization
# db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB
# CamCentral IMS configuration database
# db = DAL('mysql://root:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
db = DAL('postgres://user:***@localhost/cc_ims', POOL_SIZE, check_reserved=check_reserved_value)
## if no need for session
# session.forget()
#########################################################################
Variables DAL <class 'gluon.dal.DAL'> check_reserved undefined
POOL_SIZE 0 db undefined check_reserved_value ['all']
-
*File /home/camcentral/Dev/web2py-hg/gluon/dal.py in __init__ at line
3529* code arguments variables
Function argument list
(self=<DAL {'_lastsql': '', '_db_codec': 'UTF-8', '_ur...cc_ims',
'_pool_size': 0, '_dbname': 'postgres'}>,
uri='postgres://user:***@localhost/cc_ims', pool_size=0, folder=None,
db_codec='UTF-8', check_reserved=['all'], migrate=True, fake_migrate=False,
decode_credentials=False, driver_args={'check_same_thread': False})