Mercurial > public > src > moin > 1.9
diff MoinMoin/user.py @ 1637:47a173ae5401
caching module: use_pickle argument for .content() and .update()
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sun, 22 Oct 2006 20:31:37 +0200 |
parents | ae56d79ae076 |
children | 5070d0358544 |
line wrap: on
line diff
--- a/MoinMoin/user.py Sun Oct 22 19:06:15 2006 +0200 +++ b/MoinMoin/user.py Sun Oct 22 20:31:37 2006 +0200 @@ -11,14 +11,6 @@ import os, time, sha, codecs -try: - import cPickle as pickle -except ImportError: - import pickle - -# Set pickle protocol, see http://docs.python.org/lib/node64.html -PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL - from MoinMoin import config, caching, wikiutil, i18n from MoinMoin.util import filesys, timefuncs @@ -62,8 +54,8 @@ key = 'name2id' cache = caching.CacheEntry(request, arena, key, scope='wiki') try: - _name2id = pickle.loads(cache.content()) - except (pickle.UnpicklingError, IOError, EOFError, ValueError): + _name2id = cache.content(use_pickle=True) + except caching.CacheError: _name2id = {} cfg.cache.name2id = _name2id id = _name2id.get(searchName, None) @@ -75,7 +67,10 @@ arena = 'user' key = 'name2id' cache = caching.CacheEntry(request, arena, key, scope='wiki') - cache.update(pickle.dumps(_name2id, PICKLE_PROTOCOL)) + try: + cache.update(_name2id, use_pickle=True) + except caching.CacheError: + pass id = _name2id.get(searchName, None) return id