[Pywikipedia-l] SVN: [5475] trunk/pywikipedia

nicdumz at svn.wikimedia.org nicdumz at svn.wikimedia.org
Fri May 30 13:27:17 UTC 2008


Revision: 5475
Author:   nicdumz
Date:     2008-05-30 13:27:17 +0000 (Fri, 30 May 2008)

Log Message:
-----------
Adding the possibility to use prefixes for our diskcache objects. 
Our messages are now stored in the form : msg-%family-%lang-%16letters

Modified Paths:
--------------
    trunk/pywikipedia/diskcache.py
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/diskcache.py
===================================================================
--- trunk/pywikipedia/diskcache.py	2008-05-30 12:51:10 UTC (rev 5474)
+++ trunk/pywikipedia/diskcache.py	2008-05-30 13:27:17 UTC (rev 5475)
@@ -13,10 +13,10 @@
 
 class CachedReadOnlyDictI(object):
     """A cached readonly dict with case insensitive keys."""
-    def __init__(self, data, max_size = 10, cache_base = 'cache'):
+    def __init__(self, data, prefix = "", max_size = 10, cache_base = 'cache'):
         self.max_size = max_size
         while True:
-            self.cache_path = os.path.join(cache_base, ''.join(
+            self.cache_path = os.path.join(cache_base, prefix + ''.join(
                 [random.choice('abcdefghijklmnopqrstuvwxyz') 
                     for i in xrange(16)]))
             if not os.path.exists(self.cache_path): break

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-05-30 12:51:10 UTC (rev 5474)
+++ trunk/pywikipedia/wikipedia.py	2008-05-30 13:27:17 UTC (rev 5475)
@@ -4482,7 +4482,8 @@
                 elementtree = False
 
             if config.use_diskcache:
-                _dict = diskcache.CachedReadOnlyDictI
+                import functools
+                _dict = lambda x : diskcache.CachedReadOnlyDictI(x, prefix = "msg-%s-%s-" % (self.family.name, self.lang))
             else:
                 _dict = dict
 





More information about the Pywikipedia-l mailing list