this one with the errors

  File "gluon/sql.py", line 1184, in select
    r=response(query)
  File "gluon/sql.py", line 1180, in response
    self._db._execute(query)
  File "/home/web2py/applications/cychurch/models/db.py", line 255, in
<lambda>
    db['_execute']=lambda f=db._execute,*a,**b: timer(db,lambda:f
(*a,**b))
  File "/home/web2py/applications/cychurch/models/db.py", line 248, in
timer
    f()
  File "/home/web2py/applications/cychurch/models/db.py", line 255, in
<lambda>
    db['_execute']=lambda f=db._execute,*a,**b: timer(db,lambda:f
(*a,**b))
TypeError: 'str' object is not callable


On Dec 23, 2:39 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> try this
>
> db['_execute']=lambda f=db._execute,*a,**b: timer(db,lambda:f(*a,**b))
>
> On Dec 22, 9:50 am, vince <lapcc...@gmail.com> wrote:
>
> > it freezed and i tried debugging. it seems to be a recursive dead lock
> > problem.
>
> > def timer(db,f):
> >       import time,os
> >       import gluon.portalocker
> >       myfile=open(os.path.join
> > (request.folder,'databases','sql.log'),'a')
> >       print "locking"
> >       gluon.portalocker.lock(myfile, gluon.portalocker.LOCK_EX)
> >       t0=time.time()
> >       print "pre f()"
> >       f()
> >       t0=time.time()-t0
> >       print "unlocking"
> >       gluon.portalocker.unlock(myfile)
> >       myfile.write('%s: %s\n' % (t0,db._lastsql))
> > db['_execute']=lambda *a,**b: timer(db,lambda:db._execute(*a,**b))
>
> > and the output
>
> > locking
> > pre f()
> > locking
>
> > -vince
>
> > On Dec 22, 6:20 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > grr
>
> > > db['_execute']=lambda *a,**b: timer(db,lambda:db._execute(*a,**b))
>
> > > On Dec 22, 4:17 am, vince <lapcc...@gmail.com> wrote:
>
> > > >     db._execute=lambda *a,**b: timer(db,lambda:db._execute(*a,**b))
> > > >   File "gluon/sql.py", line 305, in __setattr__
> > > >     raise SyntaxError, 'Object exists and cannot be redefined'
> > > > SyntaxError: Object exists and cannot be redefined
>
> > > > On Dec 22, 5:43 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > db=SQLDB(...)
> > > > > def timer(db,f):
> > > > >       import time,os
> > > > >       import gluon.portalocker
> > > > >       myfile=open(os.path.join
> > > > > (request.folder,'databases','sql.log'),'a')
> > > > >       gluon.portalocker,lock(myfile, gluon.portalocker.LOCK_EX)
> > > > >       t0=time.time()
> > > > >       f()
> > > > >       t0=time.time()-t0
> > > > >       gluon.portalocker,unlock(myfile)
> > > > >       myfile.wriite('%s: %s\n' % (t0,db._lastsql)
> > > > > db._execute=lambda *a,**b: timer(db,lambda:db._execute(*a,**b))
>
> > > > > On Dec 22, 2:54 am, vince <lapcc...@gmail.com> wrote:
>
> > > > > > db._lastsql only record the last sql query right? is that any easy 
> > > > > > way
> > > > > > to log all the sql query it's executing to a file like sql.log does
> > > > > > for table update? i think it's really useful for preference fine 
> > > > > > tune.
>
> > > > > > -vince
>
> > > > > > On Dec 22, 4:26 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > Will think about it but for now:
>
> > > > > > > def timer(myfile,db,f):
> > > > > > >       import time
> > > > > > >       t0=time.time()
> > > > > > >       f()
> > > > > > >       t0=time.time()-t0
> > > > > > >       myfile.wriite('%s: %s\n' % (t0,db._lastsql)
>
> > > > > > > myfile=open('mylogfile.log','w')
> > > > > > > rows=timer(myfile,db,lambda:db(db.table.id>0).select())
>
> > > > > > > Massimo
>
> > > > > > > On Dec 22, 1:04 am, Jonathan Benn <jonathan.b...@gmail.com> wrote:
>
> > > > > > > > Hi,
>
> > > > > > > > On Dec 22, 4:52 am, vince <lapcc...@gmail.com> wrote:
>
> > > > > > > > > also is it possible to enable logging for all SQL query 
> > > > > > > > > execution?
>
> > > > > > > > Logging with a timer included would be really handy.
>
> > > > > > > > Sincerely,
>
> > > > > > > > --Jonathan
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to