ProgrammingError: Cannot operate on a closed database.
it's sufficient to comment out the property unique=True and no errors
occurs.
Here under you can find the complete traceback.
Any suggestion??
Thanks a lot
Manuele
Traceback (most recent call last):
File
"/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/restricted.py", line
192, in restricted
exec ccode in environment
File
"/home/manuele/Dropbox/sviluppo/web2py-1.96.4/applications/wind2pow2/controllers/appadmin.py",
line 410, in <module>
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/globals.py",
line 137, in <lambda>
self._caller = lambda f: f()
File
"/home/manuele/Dropbox/sviluppo/web2py-1.96.4/applications/wind2pow2/controllers/appadmin.py",
line 126, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/sqlhtml.py",
line 817, in __init__
inp = self.widgets.options.widget(field, default)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/sqlhtml.py",
line 206, in widget
options = requires[0].options()
File
"/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/validators.py", line
438, in options
self.build_set()
File
"/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/validators.py", line
426, in build_set
records = self.dbset.select(*fields, **dd)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.py",
line 5382, in select
return self.db._adapter.select(self.query,fields,attributes)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.py",
line 1159, in select
rows = response(sql)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.py",
line 1149, in response
self.execute(sql)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.py",
line 1234, in execute
return self.log_execute(*a, **b)
File "/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.py",
line 1229, in log_execute
ret = self.cursor.execute(*a,**b)
ProgrammingError: Cannot operate on a closed database.
yes, it was sqlite. At the moment I solved using postgres witrh
pool_size=100 but I didn't try if this parameter is really necessary.
what's the difference between the two db in this case??
Manuele
everything in the databases directory...
Manuele
thanks a lot
I got it now :)
Manuele
# modules/myobjects.py
from gluon import *
request,session,response,T,cache = current.request,current.session,current.response,current.T,current.cache
and then use some class method :
if form.accepts(request, session):
if form.accepts(current.request, current.session):
the problem is that the latter statement is done at top leve thereforit is only executed once when the module is imported by the first httprequest. The module is then cached in ram and that line is no longerexecuted. Therefore db is not the current thread local databaseobject but it is a reference to the db object of the first httprequest which by now may be closed. You cannot extract objects fromthe thread local "current" when you import the module, you have to doit inside functions called when a controller is executed.