many thanks - a great help as always! Andy
On Wednesday, February 20, 2013 2:43:31 AM UTC+4, howesc wrote: > > sorry about my typo. i can never remember as_dict! > > for my views i generally access the objects as dictionaries, using the > ['key'] notation. if you like you may cast the items back to web2py > Storage objects, which will then have accessors like the Row object they > were (Row is an extension of Storage i believe) > > there was some attempt not too long ago to try and make cacheable work for > GAE as documented here: > http://web2py.com/books/default/chapter/29/06?search=cacheable#Caching-selects > > i'm not sure if that is yet in a stable release, or if it has been fully > tested. > > cfh > > On Tuesday, February 19, 2013 7:55:25 AM UTC-8, Andy W wrote: >> >> Thanks for the input. >> >> Niphlod: I tried cacheable=True but seemed to make no difference on GAE >> SDK >> >> Christian: adding ".as_dict()" rather than the suggested ".to_dict" on >> the select statement does seem to work. The caching code then becomes: >> >> students = cache.ram('students', >> lambda:db(db.student.id>0).select(db.student.id, >> db.student.family_name, >> ... >> db.student.student_age).as_dict(), >> 3600) >> >> This seems to read to/from memcache correctly, but students is now a >> dictionary rather than a row object, which seems to break my views. In the >> past I iterated through the row objects to list them on screen using >> something like: >> >> {{for student in students:}} >> <tr> >> <td>{{=student.family_name}}</td> >> ... >> <td>{{=student.student_age}}</td> >> </tr> >> {{pass}} >> >> This doesn't seem to work now that students is a dictionary object. >> No idea how I need to change this! >> >> Thanks again, >> >> Andy >> >> On Tuesday, February 19, 2013 3:07:20 AM UTC+4, howesc wrote: >>> >>> cacheable=True is a newish option to selects right? i've not yet used >>> it....and had forgotten about it. >>> >>> cfh >>> >>> On Monday, February 18, 2013 7:17:02 AM UTC-8, Niphlod wrote: >>>> >>>> cacheable=True does not help ? >>>> >>>> On Monday, February 18, 2013 4:11:13 PM UTC+1, howesc wrote: >>>>> >>>>> ah yes.... >>>>> >>>>> the Rows() object returned from a select is not pickable. >>>>> >>>>> i do this a lot: >>>>> >>>>> students = cache.ram('students', >>>>> lambda:db(db.student.id>0).select( >>>>> db.student.id, >>>>> db.student.family_name, >>>>> ... >>>>> db.student.student_age).to_dict(), >>>>> 3600) >>>>> >>>>> >>>>> On Sunday, February 17, 2013 10:09:18 PM UTC-8, Andy W wrote: >>>>>> >>>>>> Thanks for the feedback Christian. >>>>>> >>>>>> It seems to be this that causes the problem on GAE but works on >>>>>> sqlite: >>>>>> >>>>>> students = cache.ram('students', >>>>>> lambda:db(db.student.id>0).select( >>>>>> db.student.id, >>>>>> db.student.family_name, >>>>>> ... >>>>>> db.student.student_age), >>>>>> 3600) >>>>>> >>>>>> Any ideas? >>>>>> >>>>>> Thanks, >>>>>> Andy >>>>>> >>>>>>> >>>>>>>> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.