changeset 68:0bbc39b09f95

optimize backup by sorting, refactor some easy stuff to use redirectedOutput imported from: moin--main--1.5--patch-70
author Thomas Waldmann <tw@waldmann-edv.de>
date Mon, 03 Oct 2005 08:41:37 +0000
parents 24ec4c3430cf
children 1cfa2e49377e
files MoinMoin/PageGraphicalEditor.py MoinMoin/action/WikiBackup.py MoinMoin/macro/LikePages.py MoinMoin/macro/RandomQuote.py MoinMoin/scripts/moin_dump.py MoinMoin/stats/hitcounts.py MoinMoin/stats/useragents.py MoinMoin/xmlrpc/UpdateGroup.py
diffstat 8 files changed, 12 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/PageGraphicalEditor.py	Mon Oct 03 08:41:37 2005 +0000
@@ -290,12 +290,8 @@
         from MoinMoin.formatter.text_gedit import Formatter
         self.formatter = Formatter(request)
         self.formatter.page = self
-
-        output = StringIO()
-        request.redirect(output)
-        self.send_page_content(request, Parser, raw_body, do_cache=False)
-        request.redirect()
-        output = repr(output.getvalue())
+        output = request.redirectedOutput(self.send_page_content, request, Parser, raw_body, do_cache=False)
+        output = repr(output)
         if output[0] == 'u':
             output = output[1:]
         request.write(output)
--- a/MoinMoin/action/WikiBackup.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/action/WikiBackup.py	Mon Oct 03 08:41:37 2005 +0000
@@ -21,6 +21,7 @@
 def addFiles(path, tar, exclude):
     """ Add files in path to tar """
     for root, dirs, files in os.walk(path):
+        files.sort() # sorted page revs may compress better
         for name in files:
             path = os.path.join(root, name)
             if exclude.search(path):
--- a/MoinMoin/macro/LikePages.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/macro/LikePages.py	Mon Oct 03 08:41:37 2005 +0000
@@ -19,10 +19,6 @@
 
     # Render matches
     if matches and not isinstance(matches, (str, unicode)):
-        import StringIO
-        out = StringIO.StringIO()
-        request.redirect(out)
-        LikePages.showMatches(pagename, request, start, end, matches, False)
-        request.redirect()
-        return out.getvalue()
+        return request.redirectedOutput(LikePages.showMatches, pagename, request, start, end, matches, False)
+
     return args
--- a/MoinMoin/macro/RandomQuote.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/macro/RandomQuote.py	Mon Oct 03 08:41:37 2005 +0000
@@ -47,11 +47,8 @@
                 
     quote = random.choice(quotes)
     page.set_raw_body(quote, 1)
-    out = StringIO.StringIO()
-    macro.request.redirect(out)
-    page.send_page(macro.request, content_only=1, content_id="RandomQuote_%s" % wikiutil.quoteWikinameFS(page.page_name) )
-    quote = out.getvalue()
-    macro.request.redirect()
-    
+    quote = macro.request.redirectedOutput(page.send_page,
+        macro.request, content_only=1, content_id="RandomQuote_%s" % wikiutil.quoteWikinameFS(page.page_name) )
+
     return quote
 
--- a/MoinMoin/scripts/moin_dump.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/scripts/moin_dump.py	Mon Oct 03 08:41:37 2005 +0000
@@ -139,11 +139,7 @@
                 request.page = page
                 try:
                     request.reset()
-                    out = StringIO.StringIO()
-                    request.redirect(out)
-                    page.send_page(request, count_hit=0, content_only=1)
-                    pagehtml = out.getvalue()
-                    request.redirect()
+                    pagehtml = request.redirectedOutput(page.send_page, request, count_hit=0, content_only=1)
                 except:
                     errcnt = errcnt + 1
                     print >>sys.stderr, "*** Caught exception while writing page!"
--- a/MoinMoin/stats/hitcounts.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/stats/hitcounts.py	Mon Oct 03 08:41:37 2005 +0000
@@ -136,7 +136,6 @@
 def text(pagename, request, params=''):
     from MoinMoin.util.dataset import TupleDataset, Column
     from MoinMoin.widget.browser import DataBrowserWidget
-    from cStringIO import StringIO
     _ = request.getText
 
     # check params
@@ -182,14 +181,9 @@
             se = 0.0
             sd = 0.0
 
-    buffer = StringIO()
-    request.redirect(buffer)
     table = DataBrowserWidget(request)
     table.setData(hits)
-    table.render()
-    request.redirect()
-
-    return buffer.getvalue()
+    return table.toHTML()
 
 
 def draw(pagename, request):
--- a/MoinMoin/stats/useragents.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/stats/useragents.py	Mon Oct 03 08:41:37 2005 +0000
@@ -88,7 +88,6 @@
 def text(pagename, request):
     from MoinMoin.util.dataset import TupleDataset, Column
     from MoinMoin.widget.browser import DataBrowserWidget
-    from cStringIO import StringIO
 
     fmt = request.formatter
     _ = request.getText
@@ -115,14 +114,9 @@
             pass
     agents.addRow((_('Others'), "%.2f" % (100*(sum-cnt_printed)/sum)))
 
-    buffer = StringIO()
-    request.redirect(buffer)
     table = DataBrowserWidget(request)
     table.setData(agents)
-    table.render()
-    request.redirect()
-
-    return buffer.getvalue()
+    return table.toHTML()
     
 
 def draw(pagename, request):
--- a/MoinMoin/xmlrpc/UpdateGroup.py	Sun Oct 02 06:39:02 2005 +0000
+++ b/MoinMoin/xmlrpc/UpdateGroup.py	Mon Oct 03 08:41:37 2005 +0000
@@ -66,12 +66,8 @@
         sys.stderr.write("Msg: %s\n" % msg)
 
     #we need this to update pagelinks cache:
-    import StringIO
-    out = StringIO.StringIO()
-    self.request.redirect(out)
     self.request.args = self.request.form = self.request.setup_args({})
-    page.send_page(self.request, content_only=1)
-    self.request.redirect()
+    self.request.redirectedOutput(page.send_page, self.request, content_only=1)
 
     return xmlrpclib.Boolean(1)