changeset 904:14c71dafc9dd

Merge with main.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 07 Jul 2006 21:29:10 +0200
parents 8166d766c440 (current diff) 6cc24670fd0f (diff)
children e670f6cabb84 7cf99d3ddb26
files
diffstat 4 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri Jul 07 21:28:40 2006 +0200
+++ b/Makefile	Fri Jul 07 21:29:10 2006 +0200
@@ -78,6 +78,11 @@
 	@python tests/maketestwiki.py
 	@python tests/runtests.py
 
+coverage:
+	@python tests/maketestwiki.py
+	@python -u -m trace --count --coverdir=cover --missing tests/runtests.py
+
+
 clean: clean-testwiki clean-pyc
 	rm -rf build
 
--- a/MoinMoin/Page.py	Fri Jul 07 21:28:40 2006 +0200
+++ b/MoinMoin/Page.py	Fri Jul 07 21:29:10 2006 +0200
@@ -1535,7 +1535,7 @@
         """
         if not self.exists():
             return []
-        cache = caching.CacheEntry(request, self, 'pagelinks', scope='item')
+        cache = caching.CacheEntry(request, self, 'pagelinks', scope='item', do_locking=False)
         if cache.needsUpdate(self._text_filename()):
             links = self.parsePageLinks(request)
             cache.update('\n'.join(links) + '\n', True)
--- a/MoinMoin/caching.py	Fri Jul 07 21:28:40 2006 +0200
+++ b/MoinMoin/caching.py	Fri Jul 07 21:29:10 2006 +0200
@@ -15,12 +15,13 @@
     from MoinMoin.util import lock
     
 class CacheEntry:
-    def __init__(self, request, arena, key, scope='page_or_wiki'):
+    def __init__(self, request, arena, key, scope='page_or_wiki', do_locking=True):
         """ init a cache entry
             @param request: the request object
             @param arena: either a string or a page object, when we want to use
                           page local cache area
             @param key: under which key we access the cache content
+            @param lock: if there should be a lock, normally True
             @param scope: the scope where we are caching:
                           'item' - an item local cache
                           'wiki' - a wiki local cache
@@ -43,7 +44,8 @@
             self.arena_dir = os.path.join(request.cfg.cache_dir, '__common__', arena)
             filesys.makeDirs(self.arena_dir)
         self.key = key
-        if locking:
+        self.locking = do_locking and locking
+        if self.locking:
             self.lock_dir = os.path.join(self.arena_dir, '__lock__')
             self.rlock = lock.ReadLock(self.lock_dir, 60.0)
             self.wlock = lock.WriteLock(self.lock_dir, 60.0)
@@ -84,7 +86,7 @@
 
     def copyto(self, filename):
         import shutil
-        if not locking or locking and self.wlock.acquire(1.0):
+        if not self.locking or self.locking and self.wlock.acquire(1.0):
             try:
                 shutil.copyfile(filename, self._filename())
                 try:
@@ -92,7 +94,7 @@
                 except OSError:
                     pass
             finally:
-                if locking:
+                if self.locking:
                     self.wlock.release()
         else:
             self.request.log("Can't acquire write lock in %s" % self.lock_dir)
@@ -100,7 +102,7 @@
     def update(self, content, encode=False):
         if encode:
             content = content.encode(config.charset)
-        if not locking or locking and self.wlock.acquire(1.0):
+        if not self.locking or self.locking and self.wlock.acquire(1.0):
             try:
                 f = open(self._filename(), 'wb')
                 f.write(content)
@@ -110,7 +112,7 @@
                 except OSError:
                     pass
             finally:
-                if locking:
+                if self.locking:
                     self.wlock.release()
         else:
             self.request.log("Can't acquire write lock in %s" % self.lock_dir)
@@ -122,13 +124,13 @@
             pass
 
     def content(self, decode=False):
-        if not locking or locking and self.rlock.acquire(1.0):
+        if not self.locking or self.locking and self.rlock.acquire(1.0):
             try:
                 f = open(self._filename(), 'rb')
                 data = f.read()
                 f.close()
             finally:
-                if locking:
+                if self.locking:
                     self.rlock.release()
         else:
             self.request.log("Can't acquire read lock in %s" % self.lock_dir)
--- a/docs/CHANGES	Fri Jul 07 21:28:40 2006 +0200
+++ b/docs/CHANGES	Fri Jul 07 21:29:10 2006 +0200
@@ -158,6 +158,7 @@
     * Included EmbedObject macro for embedding shockwave flash, mp3, visio, ...
     * @SIG@ etc. generate local time stamps now, no difference visible on page
       view.
+    * Speeded up linkto search by avoiding read locks on the pagelinks file.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page