Re: [web2py] Re: Lazy_tables with virtual fields

2012-09-01 Thread paolo.vall...@gmail.com
Hi Massimo, first of all thank you for spending time on it! The first test ends as the others, namely the first time it works, then it raises an error. The the second test works without any problem :-) To solve the issue, I will change the code to follow what you have suggested in the second test.

Re: [web2py] Re: Lazy_tables with virtual fields

2012-09-01 Thread Massimo Di Pierro
One more test: def getdb(): return db db.reviews.pos = Field.Lazy(lambda row,db=getdb: db()((db().reviews_like.review_id == row.reviews.id) & (db().reviews_like.helpful == True)).count() ) db.reviews.neg = Field.Lazy(lambda row,db=getdb: db()((db().reviews_like.review_id == row.reviews.id) & (

Re: [web2py] Re: Lazy_tables with virtual fields

2012-09-01 Thread paolo.vall...@gmail.com
Hi Massimo, I've just tried both strategies you suggested but I got the same behavior; namely the first time it works, the second rises the error. Paolo 2012/9/1 Massimo Di Pierro : > I do not fully understand this. It mush have something to do with the > scoping of variables in python. > > Can y

Re: [web2py] Re: Lazy_tables with virtual fields

2012-09-01 Thread Massimo Di Pierro
I do not fully understand this. It mush have something to do with the scoping of variables in python. Can you try replace db.reviews.pos = Field.Lazy(lambda row: db((db.reviews_like.review_id == row.reviews.id) & (db.reviews_like.helpful == True)).count() ) db.reviews.neg = Field.Lazy(lambda ro

Re: [web2py] Re: Lazy_tables with virtual fields

2012-09-01 Thread João Saraiva
Hello, Could it be something related to Dropbox's sync mechanism? Have you tried running your app in another folder outside of Dropbox's reach? Would probably explain why your example works fine on other user's machines. Best regards, JS On Saturday, September 1, 2012 6:34:39 AM UTC+1, Paolo

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-31 Thread paolo.vall...@gmail.com
Hi Massimo, the error is: Cannot operate on a closed database. ticket: Traceback (most recent call last): File "/home/paolo/Dropbox/git/pp/web2py/gluon/restricted.py", line 209, in restricted exec ccode in environment File "/home/paolo/Dropbox/git/pp/web2py/applications/test_vf/views/defa

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-31 Thread Massimo Di Pierro
What's the error? Works for me. On Friday, 31 August 2012 16:00:24 UTC-5, Paolo wrote: > > Hi Massimo, > I made a simple app, accordingly this example the error seems related > to the cache, because without the cache all works fine. > > The model: > db.define_table('reviews_like_s', >

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-31 Thread paolo.vall...@gmail.com
Hi Massimo, I made a simple app, accordingly this example the error seems related to the cache, because without the cache all works fine. The model: db.define_table('reviews_like_s', Field('review_id', 'reference reviews'), Field('helpful', 'boolean')) db.define_

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread paolo.vall...@gmail.com
Hi Massimo, no, I do not have multiple models, I have defined the string connection only once in db.py, that's all. I have a few try...except but in other places, I do not thing they are connected. I will try to make a simple app ables to reproduce the problem as soon as possible. Paolo 2012/8/30

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread Massimo Di Pierro
Can you make a simple app to reproduce this? Do you have try except anywhere? Do you have multiple models wich define the same db = DAL(...) connection? On Thursday, 30 August 2012 15:49:01 UTC-5, Paolo wrote: > > Hi Bruno, a simple db with sqlite without modules > > db = DAL('sqlite://sto

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread paolo.vall...@gmail.com
Hi Bruno, a simple db with sqlite without modules db = DAL('sqlite://storage.sqlite', lazy_tables=True ) sorry, but I've just discovered that the same problem is happened even with lazy_tables=False Paolo 2012/8/30 Bruno Rocha : > How are you defining the db connection? are you using models or m

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread Bruno Rocha
How are you defining the db connection? are you using models or modules? which db? --

Re: [web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread paolo.vall...@gmail.com
Hi Massimo, actually I do not know, it seems to be a very odd error; I've just restarted web2py and the problem has seemed gone but unfortunately, after a while it came back in a totally different fashion: Traceback (most recent call last): File "/home/paolo/Dropbox/git/web2py/gluon/restricted.p

[web2py] Re: Lazy_tables with virtual fields

2012-08-30 Thread Massimo Di Pierro
I tried this (2.0.2) and I cannot reproduce the problem: db = DAL(lazy_tables=True) db.define_table('reviews_like', Field('review_id', 'reference reviews'), Field('helpful', 'boolean')) db.define_table('reviews', Field('title')) db.reviews.pos =