I'd say, when cacheable=True and cache!=None, then cache the entire Rows object (new behavior). However, if cacheable=False, then revert to the old caching behavior (which should be the default).
Anthony On Saturday, September 8, 2012 1:22:32 PM UTC-4, Massimo Di Pierro wrote: > > What do other people think? We can make the new behavior optional and only > ckickin when both cache!=None and cacheable=True. > > Massimo > > > > > On Saturday, 8 September 2012 09:20:24 UTC-5, Anthony wrote: >> >> Does this break backward compatibility? If so, should we make caching the >> full Rows object an option (maybe just via the new "cacheable" argument)? >> >> Anthony >> >> On Saturday, September 8, 2012 10:06:56 AM UTC-4, Massimo Di Pierro wrote: >>> >>> Short answer: >>> >>> if you cache the select, subqueries are missing. So you have to replace >>> >>> email = row.emails.select().first() >>> >>> with >>> >>> email = db(db.emails.studio==row.id).select().first() >>> >>> >>> This is probably the only change of behavior and it is due to the need >>> of speedup. before cache was caching value but not the full object. We >>> achieved a 100x speedup by caching the final rows object. The problem is >>> that subselects, update_record and delete_record are methods of the rows >>> and they are not serializable, therefore they are missing when the rows are >>> cached. >>> >>> Massimo >>> >>> >>> On Saturday, 8 September 2012 08:34:46 UTC-5, Jose wrote: >>>> >>>> Hi all >>>> >>>> In Version 2.0.0 (2012-06-04 18:49:33) dev works well >>>> >>>> Model: >>>> >>>> tb_studio = db.define_table('studio', >>>> Field('name', label=T('Name')), >>>> #... >>>> format='%(name)s', >>>> migrate=MIGRATE >>>> ) >>>> >>>> tb_emails = db.define_table('emails', >>>> Field('studio', tb_studio, readable=False, writable=False, >>>> default=1), >>>> Field('email', label=T('Email')), >>>> migrate=MIGRATE >>>> ) >>>> >>>> Controller >>>> >>>> def bg_studio(): >>>> row = db(tb_studio.id==1).select(cache=(cache.ram, 60)).first() >>>> email = row.emails.select().first() >>>> >>>> return dict(row=row, email=email) >>>> >>>> >>>> In Version 2.0.8 (2012-09-07 09:38:35) stable, error occurs: >>>> >>>> File "/usr/home/jose/web2py/applications/dm/controllers/default.py" >>>> <http://127.0.0.1:8000/admin/default/edit/dm/controllers/default.py>, line >>>> 45, in bg_studio >>>> email = row.emails.select().first() >>>> AttributeError: 'Row' object has no attribute 'emails' >>>> >>>> Jose >>>> >>> --