Attachment 'cache1.6.patch'

Download

   1 --- moin-1.6.orig/MoinMoin/user.py	2007-12-01 02:09:09.000000000 +0200
   2 +++ moin-1.6/MoinMoin/user.py	2007-12-04 12:34:45.000000000 +0200
   3 @@ -58,33 +58,45 @@
   4      if not searchName:
   5          return None
   6      cfg = request.cfg
   7 +    cache = caching.CacheEntry(request, 'user', 'name2id', scope='wiki', use_pickle=True)
   8 +
   9      try:
  10          _name2id = cfg.cache.name2id
  11 +        _name2id_mtime = cfg.cache.name2id_mtime
  12      except AttributeError:
  13 -        arena = 'user'
  14 -        key = 'name2id'
  15 -        cache = caching.CacheEntry(request, arena, key, scope='wiki', use_pickle=True)
  16          try:
  17              _name2id = cache.content()
  18 +            _name2id_mtime = cache.mtime()
  19          except caching.CacheError:
  20              _name2id = {}
  21 +            _name2id_mtime = 0
  22          cfg.cache.name2id = _name2id
  23 +        cfg.cache.name2id_mtime = _name2id_mtime
  24 +
  25 +    try:
  26 +        _name2id_mtime = cache.mtime()
  27 +        if cfg.cache.name2id_mtime != _name2id_mtime:
  28 +            _name2id = cache.content()
  29 +            cfg.cache.name2id = _name2id
  30 +            cfg.cache.name2id_mtime = _name2id_mtime
  31 +    except caching.CacheError:
  32 +        cfg.cache.name2id_mtime = 0
  33 +
  34      uid = _name2id.get(searchName, None)
  35 -    if uid is None:
  36 +    if uid is None or cfg.cache.name2id_mtime == 0:
  37 +        _name2id = {}
  38          for userid in getUserList(request):
  39              name = User(request, id=userid).name
  40              _name2id[name] = userid
  41          cfg.cache.name2id = _name2id
  42 -        arena = 'user'
  43 -        key = 'name2id'
  44 -        cache = caching.CacheEntry(request, arena, key, scope='wiki', use_pickle=True)
  45          try:
  46              cache.update(_name2id)
  47 +            cfg.cache.name2id_mtime = cache.mtime()
  48          except caching.CacheError:
  49              pass
  50          uid = _name2id.get(searchName, None)
  51      return uid
  52 -
  53 +    
  54  
  55  def getUserIdentification(request, username=None):
  56      """ Return user name or IP or '<unknown>' indicator.
  57 --- moin-1.6.orig/MoinMoin/userform.py	2007-12-01 02:09:09.000000000 +0200
  58 +++ moin-1.6/MoinMoin/userform.py	2007-12-04 12:35:05.000000000 +0200
  59 @@ -7,8 +7,8 @@
  60      @license: GNU GPL, see COPYING for details.
  61  """
  62  
  63 -import time
  64 -from MoinMoin import user, util, wikiutil
  65 +import time, logging
  66 +from MoinMoin import user, util, wikiutil, caching
  67  from MoinMoin.widget import html
  68  
  69  _debug = 0
  70 @@ -338,6 +338,11 @@
  71  
  72              # save data
  73              theuser.save()
  74 +			
  75 +            # update file cache
  76 +            cache = caching.CacheEntry(self.request, 'user', 'name2id', scope='wiki', use_pickle=True)
  77 +            cache.remove()
  78 +
  79              self.request.user = theuser
  80  
  81              result = _("User preferences saved!", formatted=False)

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.