I played with the cache more. If I pass current session to the object
loaded from cache, it works OK, I mean the times returned are equal:

class Blah:
    def sessiontime(self, session):
        globals()['session'] = session
        return session.ctime

def cache_test():
    import time
    session.ctime = time.ctime()
    def blah():
        return Blah()
    b = cache.ram('blah',blah,30)
    return dict(cached=b.sessiontime(session), current=session.ctime)

Of course, this is not a solution, just a dirty hack.

Moreover the problem is not with session object only. It seems that
whole globals at the time of storage are being attached to the object,
including request, result etc. E.g.:

class Blah2:
    def req_function(self):
        return request.function

def cache_test_2():
    b = cache.ram('blah',Blah2,30)
    return dict(function=b.req_function())

def cache_test_other():
    b = cache.ram('blah',Blah2,30)
    return dict(function=b.req_function())

I would anticipate that it will return the name of request function
from which it is being called,
but blah pulled from cache prints name of function from the time of
construction :-(

David

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to