[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Massimo DiPierro
I am not sure. Please open a ticket do it gets tracked.

On Sep 13, 2012, at 9:03 AM, Bruno Rocha wrote:

> I noted that this happens with memcached too.
> 
>  'list' object has no attribute 'find'
> 
> My cached .select(cache=(cache.memcache, 1200)) is retrived as a list.
> 
> Function argument list
> (menus=[ 21), 'modified_by': 1, 'id': 2}>,  'title': 'Co...2, 6, 3, 18, 20, 41), 'modified_by': 1, 'id': 3}>,  {'show_order': 0, 'parent': None, 'title': ...2, 6, 4, 19, 48, 10), 
> 'modified_by': 1, 'id': 1}>,  'Pa...12, 6, 8, 6, 50, 55), 'modified_by': 1, 'id': 4}>,  0, 'parent': 1, 'title': 'Ne...12, 6, 8, 6, 51, 25), 'modified_by': 1, 'id': 
> 5}>], visibility=1, parent=None, place='top')
> 
> Code listing
> 
> 
> 148.
> 149.
> 150.
> 151.
> 152.
> 153.
> 
> 154.
> 155.
> 156.
> 157.
> 
> 
> def get_menu(menus, visibility=1, parent=None, place="top"):
> 
> 
> ret = []
> if not parent:
> 
> 
> ret = menus.find(lambda row: (row.parent == 0 or row.parent == None) 
> and row.visibility == visibility and row.place == place)
> 
> 
> 
> else:
> ret = menus.find(lambda row: row.parent == parent and row.visibility 
> == visibility and row.place == place)
> 
> 
> return ret
> 
> 
> and I cannot use .find or other methods, this does not happens when using 
> internal cache.ram.
> 
> Is that the expected behavior?
> 
> 
> 
> -- 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-develop...@googlegroups.com
> unsubscribe: web2py-developers+unsubscr...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>  
>  

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Niphlod
a little pointer. find(), exclude(), etc are methods of a "rows" 
object. Can you please try to cache using cache.disk ?
If the error is the same, this is the "unfair" difference from cache.ram 
(that can cache pointers to a functions, objects, singletons, etc) vs all 
the other methods that have to pass through pickle.

On Thursday, September 13, 2012 4:09:17 PM UTC+2, Massimo Di Pierro wrote:
>
> I am not sure. Please open a ticket do it gets tracked.
>
> On Sep 13, 2012, at 9:03 AM, Bruno Rocha wrote:
>
> I noted that this happens with memcached too.
>
>  'list' object has no attribute 'find'
>
> My cached .select(cache=(cache.memcache, 1200)) is retrived as a list.
>
>  Function argument list
>
> (menus=[ 20, 21), 'modified_by': 1, 'id': 2}>,  'title': 'Co...2, 6, 3, 18, 20, 41), 'modified_by': 1, 'id': 3}>,  {'show_order': 0, 'parent': None, 'title': ...2, 6, 4, 19, 48, 10), 
> 'modified_by': 1, 'id': 1}>,  'Pa...12, 6, 8, 6, 50, 55), 'modified_by': 1, 'id': 4}>,  {'show_order': 0, 'parent': 1, 'title': 'Ne...12, 6, 8, 6, 51, 25), 
> 'modified_by': 1, 'id': 5}>], visibility=1, parent=None, place='top')
>  Code listing
>
>
> 148.
> 149.
> 150.
> 151.
> 152.
> 153.
>
> 154.
> 155.
> 156.
> 157.
>
>
>
> def get_menu(menus, visibility=1, parent=None, place="top"):
>
>
> ret = []
> if not parent:
>
> ret = menus.find(lambda row: (row.parent == 0 or row.parent == None) 
> and row.visibility == visibility and row.place == place)
>
>
> else:
> ret = menus.find(lambda row: row.parent == parent and row.visibility 
> == visibility and row.place == place)
>
>
> return ret
>
>
>
> and I cannot use .find or other methods, this does not happens when using 
> internal cache.ram.
>
> Is that the expected behavior?
>
>
>
> -- 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-d...@googlegroups.com 
> unsubscribe: web2py-develop...@googlegroups.com 
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>  
>  
>
>
>

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
Yes, it raises the same error when using cache.disk, so I think for now we
should include a note on /book.

and I will try to emulate the .find .exclude and .sort externally using
listcomprehension or map.

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Niphlod
I'm getting weird behaviours trying to reproduce if you remove 
cacheable=True will the find() method work or not ?

On Thursday, September 13, 2012 8:53:16 PM UTC+2, rochacbruno wrote:
>
> Yes, it raises the same error when using cache.disk, so I think for now we 
> should include a note on /book.
>
> and I will try to emulate the .find .exclude and .sort externally using 
> listcomprehension or map.
>

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
The same problem without cacheable

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Niphlod
uhm. web2py 2.0.8 ... this works 

rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
print rows.find(lambda row: row.id == 1)

this don't

rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
print rows.find(lambda row: row.id == 1)

the same exact thing is happening using cache.redis (cacheable=True doesn't 
work, the other works)

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Massimo DiPierro
try pickle and unpickle this:
rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)

perhaps something is failing there?


On Sep 13, 2012, at 2:14 PM, Niphlod wrote:

> uhm. web2py 2.0.8 ... this works
> 
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
> print rows.find(lambda row: row.id == 1)
> 
> this don't
> 
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
> print rows.find(lambda row: row.id == 1)
> 
> the same exact thing is happening using cache.redis (cacheable=True doesn't 
> work, the other works)
> 
> -- 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-develop...@googlegroups.com
> unsubscribe: web2py-developers+unsubscr...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>  
>  

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Bruno Rocha
Ok, changing all my selects to cacheable=False it works on .disk, redis and
memcache.

Even on the rows where I am not using the .find() and .exclude() methods
the cache are failing.

If do

{{for row in cached_rows:}}

{{pass}}

it gives me nothing..

Also {{if cached_rows:}} returns always False.

It works good on cache.ram with cacheble=True|False

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Niphlod
no errors but both (cacheable and not cacheable) are gluon.dal.Rows before 
pickling and list after pickle.dumps()

On Thursday, September 13, 2012 9:18:59 PM UTC+2, Massimo Di Pierro wrote:
>
> try pickle and unpickle this:
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>
> perhaps something is failing there?
>
>
> On Sep 13, 2012, at 2:14 PM, Niphlod wrote:
>
> uhm. web2py 2.0.8 ... this works 
>
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
> print rows.find(lambda row: row.id == 1)
>
> this don't
>
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
> print rows.find(lambda row: row.id == 1)
>
> the same exact thing is happening using cache.redis (cacheable=True 
> doesn't work, the other works)
>
> -- 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-d...@googlegroups.com 
> unsubscribe: web2py-develop...@googlegroups.com 
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>  
>  
>
>
>

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Niphlod
doh. found!
maybe it's better to put it in the book.

cacheable makes the select return a "stripped" Rows object. When you use 
cache, if cacheable is False, you store the list of the results, that are 
turned into a Rows object "filling" a new empty copy.
So, cacheable=False cached results are then transformed to a full Rows 
object (find() works) ... cacheable=False returns a Rows object, that 
cached (pickled) returns a list, but it's not "transformed back" to a full 
Rows object.

On Thursday, September 13, 2012 9:33:27 PM UTC+2, Niphlod wrote:
>
> no errors but both (cacheable and not cacheable) are gluon.dal.Rows before 
> pickling and list after pickle.dumps()
>
> On Thursday, September 13, 2012 9:18:59 PM UTC+2, Massimo Di Pierro wrote:
>>
>> try pickle and unpickle this:
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>>
>> perhaps something is failing there?
>>
>>
>> On Sep 13, 2012, at 2:14 PM, Niphlod wrote:
>>
>> uhm. web2py 2.0.8 ... this works 
>>
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
>> print rows.find(lambda row: row.id == 1)
>>
>> this don't
>>
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>> print rows.find(lambda row: row.id == 1)
>>
>> the same exact thing is happening using cache.redis (cacheable=True 
>> doesn't work, the other works)
>>
>> -- 
>> -- mail from:GoogleGroups "web2py-developers" mailing list
>> make speech: web2py-d...@googlegroups.com
>> unsubscribe: web2py-develop...@googlegroups.com
>> details : http://groups.google.com/group/web2py-developers
>> the project: http://code.google.com/p/web2py/
>> official : http://www.web2py.com/
>>  
>>  
>>
>>
>>

-- 





[web2py] Re: [web2py-dev] on Redis Rows turns in to list() ?

2012-09-13 Thread Massimo DiPierro
"Rows object, that cached (pickled) returns a list, but it's not "transformed 
back" to a full Rows object." this is because of legacy pickling code. We can 
fix it.

On Sep 13, 2012, at 2:44 PM, Niphlod wrote:

> doh. found!
> maybe it's better to put it in the book.
> 
> cacheable makes the select return a "stripped" Rows object. When you use 
> cache, if cacheable is False, you store the list of the results, that are 
> turned into a Rows object "filling" a new empty copy.
> So, cacheable=False cached results are then transformed to a full Rows object 
> (find() works) ... cacheable=False returns a Rows object, that cached 
> (pickled) returns a list, but it's not "transformed back" to a full Rows 
> object.
> 
> On Thursday, September 13, 2012 9:33:27 PM UTC+2, Niphlod wrote:
> no errors but both (cacheable and not cacheable) are gluon.dal.Rows before 
> pickling and list after pickle.dumps()
> 
> On Thursday, September 13, 2012 9:18:59 PM UTC+2, Massimo Di Pierro wrote:
> try pickle and unpickle this:
> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
> 
> perhaps something is failing there?
> 
> 
> On Sep 13, 2012, at 2:14 PM, Niphlod wrote:
> 
>> uhm. web2py 2.0.8 ... this works
>> 
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200))
>> print rows.find(lambda row: row.id == 1)
>> 
>> this don't
>> 
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>> rows = db(db.tests.id>0).select(cache=(cache.disk, 200), cacheable=True)
>> print rows.find(lambda row: row.id == 1)
>> 
>> the same exact thing is happening using cache.redis (cacheable=True doesn't 
>> work, the other works)
>> 
>> -- 
>> -- mail from:GoogleGroups "web2py-developers" mailing list
>> make speech: web2py-d...@googlegroups.com
>> unsubscribe: web2py-develop...@googlegroups.com
>> details : http://groups.google.com/group/web2py-developers
>> the project: http://code.google.com/p/web2py/
>> official : http://www.web2py.com/
>>  
>>  
> 
> 
> -- 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-develop...@googlegroups.com
> unsubscribe: web2py-developers+unsubscr...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
>  
>  

--