yes and no. By default

db=DAL(...)

does create a new connection at every request. You can change it with

db=DAL(...,pool_size=100)

and you have a connection pool (ignored by sqlite and gae)

On Sep 1, 10:32 am, MikeEllis <[email protected]> wrote:
> I've got it working now.  The external module contains generators and
> the db access that raised the ProgrammingError was within one of the
> generators. The db reference is passed in a global environment
> dictionary (using cache.ram and the ThreadSafe class recommended in
> another topic in this forum).  I was initializing the 'DB' member of
> the dictionary during the first access to the index page and assuming
> it would remain a valid reference when accessed later.  Apparently
> that's not the case. I'm able to make the problem go away by
> refreshing the value of 'DB' in my environment dictionary just before
> stepping into the generators via the send() method.
>
> So if I'm understanding this correctly, it looks like web2py creates a
> new instance of the db object with every page request.  Is that
> correct?
>
> Thanks for all your help,
> Mike
>
> On Sep 1, 10:25 am, MikeEllis <[email protected]> wrote:
>
> > Hi Massimo,
> > Same outcome with 1.66.2.  I'm testing with web2py unzipped from
> > source and my init app cp'ed from my version controlled 1.64 into the
> > 1.66.2 applications directory.  Seems to run correctly except when I
> > come to the part that tries to insert a record into a table.
> > Thanks,
> > Mike
>
> > On Aug 31, 8:55 pm, mdipierro <[email protected]> wrote:
>
> > > Any chance you can try the current version and see if you can
> > > reproduce this error?.
>
> > > On Aug 31, 5:45 pm, MikeEllis <[email protected]> wrote:
>
> > > > Hi all,
>
> > > > I'm passing the db object into an external module that needs to insert
> > > > some records into a table in the database.  Not sure what the
> > > > following error means.  Looks like web2py closed the db.
>
> > > > I'm running Version 1.64.3 (2009-06-19 07:35:40) on OS X 10.5.8
> > > > (Leopard).  I'm using the built-in SQLite db.
>
> > > > Thanks,
> > > > Mike
>
> > > > Traceback (most recent call last):
> > > >   File "/Users/mellis/trunk/python/web2py/gluon/restricted.py", line
> > > > 107, in restricted
> > > >     exec ccode in environment
> > > >   File "/Users/mellis/trunk/python/web2py/applications/init/
> > > > controllers/default.py", line 189, in <module>
> > > >   File "/Users/mellis/trunk/python/web2py/gluon/globals.py", line 100,
> > > > in <lambda>
> > > >     self._caller = lambda f: f()
> > > >   File "/Users/mellis/trunk/python/web2py/applications/init/
> > > > controllers/default.py", line 120, in pdainterfacehandler
> > > >     response.page = env['STATEMACHINE'].send(env)
> > > >   File "/Users/mellis/xlrn/lib/python2.5/site-packages/
> > > > pdainterface.py", line 960, in statemachine
> > > >     page = psm.send(environ)
> > > >   File "/Users/mellis/xlrn/lib/python2.5/site-packages/
> > > > pdainterface.py", line 478, in devicecontrolPSM
> > > >     body = performwalk.next()
> > > >   File "/Users/mellis/xlrn/lib/python2.5/site-packages/
> > > > pdainterface.py", line 622, in performwalkPSM
> > > >     scriptevent2db
> > > > (shared.db,walkname,'SCRIPT_START',device,shared.location,shared.filename)
> > > >   File "/Users/mellis/xlrn/lib/python2.5/site-packages/
> > > > pdainterface.py", line 221, in scriptevent2db
> > > >     imdfile=imdfile)
> > > >   File "/Users/mellis/trunk/python/web2py/gluon/sql.py", line 1470, in
> > > > insert
> > > >     self._db._execute(query)
> > > >   File "/Users/mellis/trunk/python/web2py/gluon/sql.py", line 697, in
> > > > <lambda>
> > > >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > ProgrammingError: Cannot operate on a closed database.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to