Michael Bayer wrote:
> has_key passes unit tests added in rev 70, using DBM files like your
> example, im fairly certain this worked in older versions so you might
> want to double check your cache expiry/etc. and/or upgrade to beaker
> trunk; fixed/added support for unicode keys in rev 71.
I've updated to the Beaker-0.7dev_r71-py2.4.egg. I had to change some
import statments in "pylons/wsgiapp.py" because SessionMiddleware and
CacheMiddleware were moved over in "beaker/middleware.py".
Then start the Pylons' command-line shell:
paster shell development.ini
So the unicode fix works fine now. But I'm still having trouble with the
has_key, eventhough, the behaviour has changed a bit:
>>> cache.get_cache("users").set_value("anonymous", "bla")
>>> cache.get_cache("users").get_value("anonymous")
'bla'
>>> cache.get_cache("users").has_key("anonymous")
False
>>> cache.get_cache("users").has_key("foo") # was previously returning 0
False
>>> "anonymous" in cache.get_cache("users")
False
>>> "foo" in cache.get_cache("users")
False
This is raw from the command line. There's no expire set anywhere. And
it all returns `False` even if a key really exists.
[... much later ...]
I have found out where my problem came from. It turns out that if I do
the following, it works fine (inspired from your unit tests):
>>> _cache = cache.get_cache("users")
>>> _cache.set_value("anonymous", "bla")
>>> _cache.get_value("anonymous")
'bla'
>>> _cache.has_key("anonymous")
True
>>> _cache.has_key("foo")
False
>>> "anonymous" in _cache
True
>>> "foo" in _cache
False
I noticed that pylons "cache" object (beaker.cache.CacheManager) returns
a different "beaker.cache.Cache" object everytime:
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x12543d0>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x1244410>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x1254490>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x1254410>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x1244410>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x12543d0>
>>> cache.get_cache("users")
<beaker.cache.Cache object at 0x1254490>
Actually, it seems to randomly return a previously returned object. It's
pretty confusing. Doing a .get_value("anonymous") always returns the
correct information, but the .has_key() method doesn't work.
Am I missing something ?
Regards,
--
Alexandre CONRAD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---