Attachment 'cache1.7.patch'

Download

   1 --- moin-1.7.orig/MoinMoin/user.py	2007-12-01 16:50:42.000000000 +0200
   2 +++ moin-1.7/MoinMoin/user.py	2007-12-04 16:48:40.000000000 +0200
   3 @@ -72,18 +72,34 @@
   4          return None
   5      cfg = request.cfg
   6      cachekey = '%s2id' % key
   7 +    cachekey_mtime = '%s2id_mtime' % key
   8 +    cache = caching.CacheEntry(request, 'user', cachekey, scope='wiki', use_pickle=True)
   9 +
  10      try:
  11          _key2id = getattr(cfg.cache, cachekey)
  12 +        _key2id_mtime = getattr(cfg.cache, cachekey_mtime)
  13      except AttributeError:
  14 -        arena = 'user'
  15 -        cache = caching.CacheEntry(request, arena, cachekey, scope='wiki', use_pickle=True)
  16          try:
  17              _key2id = cache.content()
  18 +            _key2id_mtime = cache.mtime()
  19          except caching.CacheError:
  20              _key2id = {}
  21 +            _key2id_mtime = 0
  22          setattr(cfg.cache, cachekey, _key2id)
  23 +        setattr(cfg.cache, cachekey_mtime, _key2id_mtime)
  24 +
  25 +    try:
  26 +        _key2id_mtime = cache.mtime()
  27 +        if getattr(cfg.cache, cachekey_mtime) != _key2id_mtime:
  28 +            _key2id = cache.content()
  29 +            setattr(cfg.cache, cachekey, _key2id)
  30 +            setattr(cfg.cache, cachekey_mtime, _key2id_mtime)
  31 +    except caching.CacheError:
  32 +        setattr(cfg.cache, cachekey_mtime, 0)
  33 +        
  34      uid = _key2id.get(search, None)
  35 -    if uid is None:
  36 +    if uid is None or getattr(cfg.cache, cachekey_mtime) == 0:
  37 +        _key2id = {}
  38          for userid in getUserList(request):
  39              u = User(request, id=userid)
  40              if hasattr(u, key):
  41 @@ -93,10 +109,10 @@
  42                          _key2id[val] = userid
  43                  else:
  44                      _key2id[value] = userid
  45 -        arena = 'user'
  46 -        cache = caching.CacheEntry(request, arena, cachekey, scope='wiki', use_pickle=True)
  47 +
  48          try:
  49              cache.update(_key2id)
  50 +            setattr(cfg.cache, cachekey_mtime, cache.mtime())
  51          except caching.CacheError:
  52              pass
  53          uid = _key2id.get(search, None)
  54 --- moin-1.7.orig/MoinMoin/userprefs/prefs.py	2007-12-01 16:50:42.000000000 +0200
  55 +++ moin-1.7/MoinMoin/userprefs/prefs.py	2007-12-04 16:48:54.000000000 +0200
  56 @@ -8,7 +8,7 @@
  57  """
  58  
  59  import time
  60 -from MoinMoin import user, util, wikiutil, events
  61 +from MoinMoin import user, util, wikiutil, events, caching
  62  from MoinMoin.widget import html
  63  from MoinMoin.userprefs import UserPrefBase
  64  
  65 @@ -200,6 +200,11 @@
  66              # set valid to false so the current request won't
  67              # show the user as logged-in any more
  68              theuser.valid = False
  69 +
  70 +        # update file cache
  71 +        cache = caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki', use_pickle=True)
  72 +        cache.remove()
  73 +
  74          self.request.user = theuser
  75  
  76          result = _("User preferences saved!")

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-12-04 21:39:37, 4.2 KB) [[attachment:cache.test1.6.patch]]
  • [get | view] (2007-12-04 21:38:47, 2.7 KB) [[attachment:cache1.6.patch]]
  • [get | view] (2007-12-04 21:38:57, 2.7 KB) [[attachment:cache1.7.patch]]
  • [get | view] (2007-12-30 21:22:29, 23.1 KB) [[attachment:documentation.patch]]
  • [get | view] (2007-12-11 21:27:01, 10.5 KB) [[attachment:package.patch]]
  • [get | view] (2007-12-11 21:26:48, 3.5 KB) [[attachment:packagetest.patch]]
  • [get | view] (2007-12-04 21:39:22, 3.1 KB) [[attachment:quicklink.patch]]
  • [get | view] (2008-01-29 16:42:22, 171.8 KB) [[attachment:screenschot.png]]
  • [get | view] (2007-12-04 21:42:03, 3.8 KB) [[attachment:subscribe.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.