changeset 907:d28181736482

merge main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 07 Jul 2006 21:37:22 +0200
parents e4dbe31e3ede (current diff) e670f6cabb84 (diff)
children 75df9c6c20bc
files MoinMoin/formatter/__init__.py MoinMoin/formatter/text_python.py
diffstat 6 files changed, 12 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Fri Jul 07 21:34:21 2006 +0200
+++ b/MoinMoin/Page.py	Fri Jul 07 21:37:22 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:34:21 2006 +0200
+++ b/MoinMoin/caching.py	Fri Jul 07 21:37:22 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/MoinMoin/formatter/__init__.py	Fri Jul 07 21:34:21 2006 +0200
+++ b/MoinMoin/formatter/__init__.py	Fri Jul 07 21:37:22 2006 +0200
@@ -325,14 +325,6 @@
         del p
         return ''
 
-    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={},
-                        returns_content=1):
-        content = parser[callback](*arg_list, **arg_dict)
-        if returns_content:
-            return content
-        else:
-            return ''
-
     # Other ##############################################################
     
     def div(self, on, **kw):
--- a/MoinMoin/formatter/dom_xml.py	Fri Jul 07 21:34:21 2006 +0200
+++ b/MoinMoin/formatter/dom_xml.py	Fri Jul 07 21:37:22 2006 +0200
@@ -217,13 +217,6 @@
                 self.text('\n'.join(lines)) +
                 self._set_tag('parser', False))
 
-    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={}, returns_content=1):
-        content = parser[callback](*arg_list, **arg_dict)
-        if returns_content:
-            return content
-        else:
-            return ''
-
     def url(self, on, url='', css=None, **kw):
         kw['href'] = str(url)
         if css:
--- a/MoinMoin/formatter/text_python.py	Fri Jul 07 21:34:21 2006 +0200
+++ b/MoinMoin/formatter/text_python.py	Fri Jul 07 21:37:22 2006 +0200
@@ -111,16 +111,6 @@
             self.__in_pre = self.formatter.in_pre        
         return result
     
-    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={},
-                            returns_content=1):
-        adjust = self.__adjust_formatter_state()
-        if returns_content:
-            return self.__insert_code('%srequest.write(%s.%s(*%r,**%r))' %
-                        (adjust, self.__parser, callback, arg_list, arg_dict))
-        else:
-            return self.__insert_code('%s%s.%s(*%r,**%r)' %
-                        (adjust, self.__parser, callback, arg_list, arg_dict))
-
     # Public methods ---------------------------------------------------
         
     def pagelink(self, on, pagename='', page=None, **kw):
--- a/docs/CHANGES	Fri Jul 07 21:34:21 2006 +0200
+++ b/docs/CHANGES	Fri Jul 07 21:37:22 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