changeset 3246:b7005f7b69e5

merged main
author Mikko Virkkil? <mvirkkil@cc.hut.fi>
date Thu, 13 Mar 2008 09:27:46 +0100
parents 630e6066c935 (current diff) 886b8969dbc6 (diff)
children c715d62efc50
files
diffstat 20 files changed, 57 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/config/multiconfig.py	Thu Mar 13 09:27:46 2008 +0100
@@ -896,10 +896,10 @@
             if getattr(self, "_event_handlers", None) is None:
                 self._event_handlers = events.get_handlers(self)
             return getattr(self, "_event_handlers")
-        
+
         def setter(self, new_handlers):
             self._event_handlers = new_handlers
-            
+
         return property(getter, setter)
     event_handlers = make_event_handlers_prop()
 
--- a/MoinMoin/macro/AbandonedPages.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/AbandonedPages.py	Thu Mar 13 09:27:46 2008 +0100
@@ -12,6 +12,6 @@
 
 from MoinMoin.macro import RecentChanges
 
-def execute(macro, args):
-    return RecentChanges.execute(macro, args, abandoned=1)
+def macro_AbandonedPages(macro):
+    return RecentChanges.macro_RecentChanges(macro, abandoned=True)
 
--- a/MoinMoin/macro/AttachInfo.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/AttachInfo.py	Thu Mar 13 09:27:46 2008 +0100
@@ -11,10 +11,11 @@
 
 from MoinMoin.action.AttachFile import info
 
-def execute(macro, args):
-    pagename = macro.formatter.page.page_name
-    if args:
-        pagename = args
-    result = info(pagename, macro.request)
-    return result
+def macro_AttachInfo(macro, pagename=None):
+    """ generates info how much attachments stored on a page """
+    if not pagename:
+        pagename = macro.formatter.page.page_name
 
+    return info(pagename, macro.request)
+
+
--- a/MoinMoin/macro/AttachList.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/AttachList.py	Thu Mar 13 09:27:46 2008 +0100
@@ -15,15 +15,10 @@
 
 from MoinMoin.action.AttachFile import _build_filelist
 
-def execute(macro, args):
+def macro_AttachList(macro, pagename=None, mime_type=u'*'):
     # defaults if we don't get anything better
-    pagename = macro.formatter.page.page_name
-    mime_type = '*'
-    if args:
-        args = args.split(',')
-        if args[0].strip():
-            pagename = args[0].strip()
-        if len(args) > 1 and args[1].strip():
-            mime_type = args[1].strip()
+    if not pagename:
+        pagename = macro.formatter.page.page_name
+
     return _build_filelist(macro.request, pagename, 0, 1, mime_type=mime_type)
 
--- a/MoinMoin/macro/EditedSystemPages.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/EditedSystemPages.py	Thu Mar 13 09:27:46 2008 +0100
@@ -8,7 +8,7 @@
 
 class EditedSystemPages:
 
-    def __init__(self, macro, args):
+    def __init__(self, macro):
         self.macro = macro
         self.request = macro.request
         self.formatter = macro.formatter
@@ -48,7 +48,7 @@
         return ''.join(result)
 
 
-def execute(macro, args):
+def macro_EditedSystemPages(macro):
     """ Temporary glue code to use with moin current macro system """
-    return EditedSystemPages(macro, args).renderInPage()
+    return EditedSystemPages(macro).renderInPage()
 
--- a/MoinMoin/macro/FootNote.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/FootNote.py	Thu Mar 13 09:27:46 2008 +0100
@@ -18,7 +18,7 @@
 
 Dependencies = ["time"] # footnote macro cannot be cached
 
-def execute(macro, args):
+def macro_FootNote(macro, text=u''):
     request = macro.request
     formatter = macro.formatter
 
@@ -28,27 +28,27 @@
         request.footnote_ctr = 0
         request.footnote_show_ctr = 0
 
-    if not args:
+    if not text:
         return emit_footnotes(request, formatter)
     else:
         # grab new footnote backref number
         idx = request.footnote_ctr
         request.footnote_ctr += 1
 
-        shahex = sha.new(args.encode(config.charset)).hexdigest()
+        shahex = sha.new(text.encode(config.charset)).hexdigest()
         backlink_id = "fndef-%s-%d" % (shahex, idx)
         fwdlink_id = "fnref-%s" % shahex
 
-        if not args in request.footnotes:
+        if not text in request.footnotes:
             showidx = request.footnote_show_ctr
             request.footnote_show_ctr += 1
-            request.footnotes[args] = ([], fwdlink_id, showidx)
-        flist, dummy, showidx = request.footnotes[args]
-        request.footnotes[args] = (flist + [(backlink_id, idx)], fwdlink_id, showidx)
+            request.footnotes[text] = ([], fwdlink_id, showidx)
+        flist, dummy, showidx = request.footnotes[text]
+        request.footnotes[text] = (flist + [(backlink_id, idx)], fwdlink_id, showidx)
 
         # do index -> text mapping in the same dict, that's fine because
-        # args is always a string and idx alwas a number.
-        request.footnotes[idx] = args
+        # text is always a string and idx alwas a number.
+        request.footnotes[idx] = text
 
         return "%s%s%s%s%s" % (
             formatter.sup(1),
--- a/MoinMoin/macro/FullSearch.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/FullSearch.py	Thu Mar 13 09:27:46 2008 +0100
@@ -81,7 +81,8 @@
     return macro.formatter.rawHTML(html)
 
 
-def execute(macro, needle):
+def macro_FullSearch(macro, needle=None):
+
     request = macro.request
     _ = request.getText
 
--- a/MoinMoin/macro/FullSearchCached.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/FullSearchCached.py	Thu Mar 13 09:27:46 2008 +0100
@@ -9,7 +9,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from MoinMoin.macro.FullSearch import execute
+from MoinMoin.macro.FullSearch import macro_FullSearch
 Dependencies = []
 
 # yes, that's all
--- a/MoinMoin/macro/GetText.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/GetText.py	Thu Mar 13 09:27:46 2008 +0100
@@ -13,9 +13,9 @@
 
 Dependencies = ["language"]
 
-def execute(macro, args):
+def macro_GetText(macro, text=u''):
     """ Return a translation of args, or args as is """
-    translation = macro.request.getText(args)
+    translation = macro.request.getText(text)
 
     return macro.formatter.text(translation)
 
--- a/MoinMoin/macro/LikePages.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/LikePages.py	Thu Mar 13 09:27:46 2008 +0100
@@ -10,7 +10,7 @@
 
 from MoinMoin.action import LikePages
 
-def execute(macro, args):
+def macro_LikePages(macro):
     request = macro.request
     # we don't want to spend much CPU for spiders requesting nonexisting pages
     if not request.isSpiderAgent:
@@ -23,6 +23,5 @@
         if matches and not isinstance(matches, (str, unicode)):
             return request.redirectedOutput(LikePages.showMatches, pagename, request, start, end, matches, False)
 
-        return args
     return ''
 
--- a/MoinMoin/macro/PageHits.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/PageHits.py	Thu Mar 13 09:27:46 2008 +0100
@@ -14,7 +14,7 @@
 
 class PageHits:
 
-    def __init__(self, macro, args):
+    def __init__(self, macro):
         self.macro = macro
         self.request = macro.request
         self.cache = caching.CacheEntry(self.request, 'charts', 'pagehits', scope='wiki', use_pickle=True)
@@ -97,6 +97,6 @@
         return ''.join(result)
 
 
-def execute(macro, args):
-    return PageHits(macro, args).execute()
+def macro_PageHits(macro):
+    return PageHits(macro).execute()
 
--- a/MoinMoin/macro/RandomPage.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/RandomPage.py	Thu Mar 13 09:27:46 2008 +0100
@@ -13,14 +13,9 @@
 
 Dependencies = ["time"]
 
-def execute(macro, args):
+def macro_RandomPage(macro, links=1):
     request = macro.request
-
-    # get number of wanted links
-    try:
-        links = max(int(args), 1)
-    except StandardError:
-        links = 1
+    links = max(links, 1) # at least 1 link
 
     # Get full page unfiltered page list - very fast!
     all_pages = request.rootpage.getPageList(user='', exists=0)
@@ -69,4 +64,3 @@
     result = ''.join(result)
     return result
 
-
--- a/MoinMoin/macro/RandomQuote.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/RandomQuote.py	Thu Mar 13 09:27:46 2008 +0100
@@ -25,10 +25,9 @@
 
 Dependencies = ["time"]
 
-def execute(macro, args):
+def macro_RandomQuote(macro, pagename=u'FortuneCookies'):
     _ = macro.request.getText
 
-    pagename = args or 'FortuneCookies'
     if macro.request.user.may.read(pagename):
         page = Page(macro.request, pagename)
         raw = page.get_raw_body()
--- a/MoinMoin/macro/RecentChanges.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/RecentChanges.py	Thu Mar 13 09:27:46 2008 +0100
@@ -143,7 +143,7 @@
 def cmp_lines(first, second):
     return cmp(first[0], second[0])
 
-def print_abandoned(macro, args, **kw):
+def print_abandoned(macro):
     request = macro.request
     _ = request.getText
     d = {}
@@ -228,10 +228,10 @@
     d['rc_msg'] = msg
     request.write(request.theme.recentchanges_footer(d))
 
-def execute(macro, args, **kw):
+def macro_RecentChanges(macro, abandoned=False):
     # handle abandoned keyword
-    if kw.get('abandoned', 0):
-        print_abandoned(macro, args, **kw)
+    if abandoned:
+        print_abandoned(macro)
         return ''
 
     request = macro.request
--- a/MoinMoin/macro/StatsChart.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/StatsChart.py	Thu Mar 13 09:27:46 2008 +0100
@@ -12,21 +12,21 @@
 
 Dependencies = ["time24:00"]
 
-def execute(macro, args, **kw):
+def macro_StatsChart(macro, chart_type=''):
     _ = macro.request.getText
     formatter = macro.request.formatter
 
-    if not args:
+    if not chart_type:
         return (formatter.sysmsg(1) +
                 formatter.text(_('You need to provide a chart type!')) +
                 formatter.sysmsg(0))
 
     try:
         # stats module without 'linkto' will raise AttributeError
-        func = pysupport.importName("MoinMoin.stats." + args, "linkto")
+        func = pysupport.importName("MoinMoin.stats.%s" % chart_type, "linkto")
     except ImportError:
         return (formatter.sysmsg(1) +
-                formatter.text(_('Bad chart type "%s"!') % args) +
+                formatter.text(_('Bad chart type "%s"!') % chart_type) +
                 formatter.sysmsg(0))
 
     return func(macro.formatter.page.page_name, macro.request)
--- a/MoinMoin/macro/SystemInfo.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/SystemInfo.py	Thu Mar 13 09:27:46 2008 +0100
@@ -4,7 +4,7 @@
 
     This macro shows some info about your wiki, wiki software and your system.
 
-    @copyright: 2006 MoinMoin:ThomasWaldmann,
+    @copyright: 2006-2008 MoinMoin:ThomasWaldmann,
                 2007 MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
@@ -20,11 +20,10 @@
 from MoinMoin.Page import Page
 
 class SystemInfo:
-    def __init__(self, macro, args):
+    def __init__(self, macro):
         self.macro = macro
         self.request = macro.request
         self.formatter = macro.formatter
-        self.args = args
 
     def formatInReadableUnits(self, size):
         size = float(size)
@@ -180,8 +179,8 @@
 
         return buf.getvalue()
 
-def execute(macro, args):
+def macro_SystemInfo(macro):
     if macro.request.isSpiderAgent: # reduce bot cpu usage
         return ''
-    return SystemInfo(macro, args).render()
+    return SystemInfo(macro).render()
 
--- a/MoinMoin/macro/Verbatim.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/Verbatim.py	Thu Mar 13 09:27:46 2008 +0100
@@ -8,5 +8,5 @@
 
 Dependencies = []
 
-def execute(macro, args):
-    return macro.formatter.escapedText(args)
+def macro_Verbatim(macro, text=u''):
+    return macro.formatter.escapedText(text)
--- a/MoinMoin/macro/_tests/test_FootNote.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/macro/_tests/test_FootNote.py	Thu Mar 13 09:27:46 2008 +0100
@@ -48,9 +48,9 @@
         """ module_tested: enumbering of Footnotes"""
         m = self._make_macro()
         text = 'a'
-        FootNote.execute(m, text)
+        FootNote.macro_FootNote(m, text)
         text = 'b'
-        FootNote.execute(m, text)
+        FootNote.macro_FootNote(m, text)
         result = FootNote.emit_footnotes(m.request, m.request.formatter)
 
         assert result.endswith('2</a>)</li></ol></div>')
--- a/MoinMoin/parser/_tests/test_text_creole.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/parser/_tests/test_text_creole.py	Thu Mar 13 09:27:46 2008 +0100
@@ -230,7 +230,7 @@
 
     def testEscapeInGetTextMacro(self):
         """ parser.wiki: escape html markup in GetText macro """
-        test = "text <<GetText(<escape-me>)>> text"
+        test = u"text <<GetText(<escape-me>)>> text"
         self._test(test)
 
 # Getting double escaping
--- a/MoinMoin/parser/_tests/test_text_moin_wiki.py	Thu Mar 13 09:27:27 2008 +0100
+++ b/MoinMoin/parser/_tests/test_text_moin_wiki.py	Thu Mar 13 09:27:46 2008 +0100
@@ -301,7 +301,7 @@
 
     def testEscapeInGetTextMacro(self):
         """ parser.wiki: escape html markup in GetText macro """
-        test = "text <<GetText(<escape-me>)>> text"
+        test = u"text <<GetText(<escape-me>)>> text"
         self._test(test)
 
     def testEscapeInGetTextFormatted(self):