changeset 1204:9085983fc624

merge with main
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Mon, 24 Jul 2006 11:52:07 +0200
parents 10512e7ca243 (current diff) 6488692b1eb8 (diff)
children 73f576c4bca3
files MoinMoin/config.py MoinMoin/multiconfig.py MoinMoin/util/diff.py
diffstat 28 files changed, 1635 insertions(+), 1577 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/__init__.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/_tests/__init__.py	Mon Jul 24 11:52:07 2006 +0200
@@ -94,9 +94,9 @@
         
         Non existing default will raise an AttributeError.
         """
-        from MoinMoin.multiconfig import DefaultConfig
+        from MoinMoin.config import multiconfig
         for key in defaults:
-            self._setattr(key, getattr(DefaultConfig, key))
+            self._setattr(key, getattr(multiconfig.DefaultConfig, key))
 
     def setCustom(self, **custom):
         """ Set custom values """
--- a/MoinMoin/action/__init__.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/action/__init__.py	Mon Jul 24 11:52:07 2006 +0200
@@ -303,537 +303,11 @@
     pg.send_page(request, msg=savemsg)
     return None
 
-def do_edit(pagename, request):
-    """ edit a page """
-    _ = request.getText
-
-    if not request.user.may.write(pagename):
-        Page(request, pagename).send_page(request,
-            msg=_('You are not allowed to edit this page.'))
-        return
-
-    valideditors = ['text', 'gui', ]
-    editor = ''
-    if request.user.valid:
-        editor = request.user.editor_default
-    if editor not in valideditors:
-        editor = request.cfg.editor_default
-
-    editorparam = request.form.get('editor', [editor])[0]
-    if editorparam == "guipossible":
-        lasteditor = editor
-    elif editorparam == "textonly":
-        editor = lasteditor = 'text'
-    else:
-        editor = lasteditor = editorparam
-
-    if request.cfg.editor_force:
-        editor = request.cfg.editor_default
-
-    # if it is still nothing valid, we just use the text editor
-    if editor not in valideditors:
-        editor = 'text'
-
-    savetext = request.form.get('savetext', [None])[0]
-    rev = int(request.form.get('rev', ['0'])[0])
-    comment = request.form.get('comment', [u''])[0]
-    category = request.form.get('category', [None])[0]
-    rstrip = int(request.form.get('rstrip', ['0'])[0])
-    trivial = int(request.form.get('trivial', ['0'])[0])
-
-    if request.form.has_key('button_switch'):
-        if editor == 'text':
-            editor = 'gui'
-        else: # 'gui'
-            editor = 'text'
-
-    # load right editor class
-    if editor == 'gui':
-        from MoinMoin.PageGraphicalEditor import PageGraphicalEditor
-        pg = PageGraphicalEditor(request, pagename)
-    else: # 'text'
-        from MoinMoin.PageEditor import PageEditor
-        pg = PageEditor(request, pagename)
-
-    # is invoked without savetext start editing
-    if savetext is None:
-        pg.sendEditor()
-        return
-
-    # did user hit cancel button?
-    cancelled = request.form.has_key('button_cancel')
-
-    # convert input from Graphical editor
-    from MoinMoin.converter.text_html_text_moin_wiki import convert, ConvertError
-    try:
-        if lasteditor == 'gui':
-            savetext = convert(request, pagename, savetext)
-
-        # IMPORTANT: normalize text from the form. This should be done in
-        # one place before we manipulate the text.
-        savetext = pg.normalizeText(savetext, stripspaces=rstrip)
-    except ConvertError:
-        # we don't want to throw an exception if user cancelled anyway
-        if not cancelled:
-            raise
-
-    if cancelled:
-        pg.sendCancel(savetext or "", rev)
-        return
-
-    comment = wikiutil.clean_comment(comment)
-
-    # Add category
-
-    # TODO: this code does not work with extended links, and is doing
-    # things behind your back, and in general not needed. Either we have
-    # a full interface for categories (add, delete) or just add them by
-    # markup.
-
-    if category and category != _('<No addition>', formatted=False): # opera 8.5 needs this
-        # strip trailing whitespace
-        savetext = savetext.rstrip()
-
-        # Add category separator if last non-empty line contains
-        # non-categories.
-        lines = filter(None, savetext.splitlines())
-        if lines:
-
-            #TODO: this code is broken, will not work for extended links
-            #categories, e.g ["category hebrew"]
-            categories = lines[-1].split()
-
-            if categories:
-                confirmed = wikiutil.filterCategoryPages(request, categories)
-                if len(confirmed) < len(categories):
-                    # This was not a categories line, add separator
-                    savetext += u'\n----\n'
-
-        # Add new category
-        if savetext and savetext[-1] != u'\n':
-            savetext += ' '
-        savetext += category + u'\n' # Should end with newline!
-
-    # Preview, spellcheck or spellcheck add new words
-    if (request.form.has_key('button_preview') or
-        request.form.has_key('button_spellcheck') or
-        request.form.has_key('button_newwords')):
-        pg.sendEditor(preview=savetext, comment=comment)
-
-    # Preview with mode switch
-    elif request.form.has_key('button_switch'):
-        pg.sendEditor(preview=savetext, comment=comment, staytop=1)
-
-    # Save new text
-    else:
-        try:
-            still_conflict = wikiutil.containsConflictMarker(savetext)
-            pg.setConflict(still_conflict)
-            savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment)
-        except pg.EditConflict, e:
-            msg = e.message
-
-            # Handle conflict and send editor
-            pg.set_raw_body(savetext, modified=1)
-
-            pg.mergeEditConflict(rev)
-            # We don't send preview when we do merge conflict
-            pg.sendEditor(msg=msg, comment=comment)
-            return
-
-        except pg.SaveError, msg:
-            # msg contain a unicode string
-            savemsg = unicode(msg)
-
-        # Send new page after save or after unsuccessful conflict merge.
-        request.reset()
-        backto = request.form.get('backto', [None])[0]
-        if backto:
-            pg = Page(request, backto)
-
-        pg.send_page(request, msg=savemsg)
-
 def do_goto(pagename, request):
     """ redirect to another page """
     target = request.form.get('target', [''])[0]
     request.http_redirect(Page(request, target).url(request))
 
-def do_diff(pagename, request):
-    """ Handle "action=diff"
-        checking for either a "rev=formerrevision" parameter
-        or rev1 and rev2 parameters
-    """
-    if not request.user.may.read(pagename):
-        Page(request, pagename).send_page(request)
-        return
-
-    try:
-        date = request.form['date'][0]
-        try:
-            date = long(date) # must be long for py 2.2.x
-        except StandardError:
-            date = 0
-    except KeyError:
-        date = 0
-
-    try:
-        rev1 = int(request.form.get('rev1', [-1])[0])
-    except StandardError:
-        rev1 = 0
-    try:
-        rev2 = int(request.form.get('rev2', [0])[0])
-    except StandardError:
-        rev1 = 0
-
-    if rev1 == -1 and rev2 == 0:
-        try:
-            rev1 = int(request.form.get('rev', [-1])[0])
-        except StandardError:
-            rev1 = -1
-
-    # spacing flag?
-    ignorews = int(request.form.get('ignorews', [0])[0])
-
-    _ = request.getText
-
-    # get a list of old revisions, and back out if none are available
-    currentpage = Page(request, pagename)
-    revisions = currentpage.getRevList()
-    if len(revisions) < 2:
-        currentpage.send_page(request, msg=_("No older revisions available!"))
-        return
-
-    if date: # this is how we get called from RecentChanges
-        rev1 = 0
-        log = editlog.EditLog(request, rootpagename=pagename)
-        for line in log.reverse():
-            if date >= line.ed_time_usecs and int(line.rev) != 99999999:
-                rev1 = int(line.rev)
-                break
-        else:
-            rev1 = 1
-        rev2 = 0
-
-    # Start output
-    # This action generate content in the user language
-    request.setContentLanguage(request.lang)
-
-    request.http_headers()
-    request.theme.send_title(_('Diff for "%s"') % (pagename,), pagename=pagename, allow_doubleclick=1)
-
-    if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
-        rev1, rev2 = rev2, rev1
-
-    oldrev1, oldcount1 = None, 0
-    oldrev2, oldcount2 = None, 0
-
-    # get the filename of the version to compare to
-    edit_count = 0
-    for rev in revisions:
-        edit_count += 1
-        if rev <= rev1:
-            oldrev1, oldcount1 = rev, edit_count
-        if rev2 and rev >= rev2:
-            oldrev2, oldcount2 = rev, edit_count
-        if oldrev1 and oldrev2 or oldrev1 and not rev2:
-            break
-
-    if rev1 == -1:
-        oldpage = Page(request, pagename, rev=revisions[1])
-        oldcount1 -= 1
-    elif rev1 == 0:
-        oldpage = currentpage
-        # oldcount1 is still on init value 0
-    else:
-        if oldrev1:
-            oldpage = Page(request, pagename, rev=oldrev1)
-        else:
-            oldpage = Page(request, "$EmptyPage$") # hack
-            oldpage.set_raw_body("")    # avoid loading from disk
-            oldrev1 = 0 # XXX
-
-    if rev2 == 0:
-        newpage = currentpage
-        # oldcount2 is still on init value 0
-    else:
-        if oldrev2:
-            newpage = Page(request, pagename, rev=oldrev2)
-        else:
-            newpage = Page(request, "$EmptyPage$") # hack
-            newpage.set_raw_body("")    # avoid loading from disk
-            oldrev2 = 0 # XXX
-
-    edit_count = abs(oldcount1 - oldcount2)
-
-    # this should use the formatter, but there is none?
-    request.write('<div id="content">\n') # start content div
-    request.write('<p class="diff-header">')
-    request.write(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_rev()))
-    if edit_count > 1:
-        request.write(' ' + _('(spanning %d versions)') % (edit_count,))
-    request.write('</p>')
-
-    if request.user.show_fancy_diff:
-        from MoinMoin.util.diff import diff
-        request.write(diff(request, oldpage.get_raw_body(), newpage.get_raw_body()))
-        newpage.send_page(request, count_hit=0, content_only=1, content_id="content-below-diff")
-    else:
-        lines = wikiutil.linediff(oldpage.getlines(), newpage.getlines())
-        if not lines:
-            msg = _("No differences found!")
-            if edit_count > 1:
-                msg = msg + '<p>' + _('The page was saved %(count)d times, though!') % {
-                    'count': edit_count}
-            request.write(msg)
-        else:
-            if ignorews:
-                request.write(_('(ignoring whitespace)') + '<br>')
-            else:
-                qstr = 'action=diff&ignorews=1'
-                if rev1: qstr = '%s&rev1=%s' % (qstr, rev1)
-                if rev2: qstr = '%s&rev2=%s' % (qstr, rev2)
-                request.write(Page(request, pagename).link_to(request,
-                    text=_('Ignore changes in the amount of whitespace'),
-                    querystr=qstr, rel='nofollow') + '<p>')
-
-            request.write('<pre>')
-            for line in lines:
-                if line[0] == "@":
-                    request.write('<hr>')
-                request.write(wikiutil.escape(line)+'\n')
-            request.write('</pre>')
-
-    request.write('</div>\n') # end content div
-    request.theme.send_footer(pagename)
-    request.theme.send_closing_html()
-
-def do_info(pagename, request):
-    """ show misc. infos about a page """
-    if not request.user.may.read(pagename):
-        Page(request, pagename).send_page(request)
-        return
-
-    def general(page, pagename, request):
-        _ = request.getText
-
-        request.write('<h2>%s</h2>\n' % _('General Information'))
-
-        # show page size
-        request.write(("<p>%s</p>" % _("Page size: %d")) % page.size())
-
-        # show SHA digest fingerprint
-        import sha
-        digest = sha.new(page.get_raw_body().encode(config.charset)).hexdigest().upper()
-        request.write('<p>%(label)s <tt>%(value)s</tt></p>' % {
-            'label': _("SHA digest of this page's content is:"),
-            'value': digest,
-            })
-
-        # show attachments (if allowed)
-        attachment_info = getHandler(request, 'AttachFile', 'info')
-        if attachment_info:
-            request.write(attachment_info(pagename, request))
-
-        # show subscribers
-        subscribers = page.getSubscribers(request, include_self=1, return_users=1)
-        if subscribers:
-            request.write('<p>', _('The following users subscribed to this page:'))
-            for lang in subscribers.keys():
-                request.write('<br>[%s] ' % lang)
-                for user in subscribers[lang]:
-                    # do NOT disclose email addr, only WikiName
-                    userhomepage = Page(request, user.name)
-                    if userhomepage.exists():
-                        request.write(userhomepage.link_to(request) + ' ')
-                    else:
-                        request.write(user.name + ' ')
-            request.write('</p>')
-
-        # show links
-        links = page.getPageLinks(request)
-        if links:
-            request.write('<p>', _('This page links to the following pages:'), '<br>')
-            for linkedpage in links:
-                request.write("%s%s " % (Page(request, linkedpage).link_to(request), ",."[linkedpage == links[-1]]))
-            request.write("</p>")
-
-    def history(page, pagename, request):
-        # show history as default
-        _ = request.getText
-
-        # open log for this page
-        from MoinMoin.util.dataset import TupleDataset, Column
-
-        history = TupleDataset()
-        history.columns = [
-            Column('rev', label='#', align='right'),
-            Column('mtime', label=_('Date'), align='right'),
-            Column('size', label=_('Size'), align='right'),
-            Column('diff', label='<input type="submit" value="%s">' % (_("Diff"))),
-            Column('editor', label=_('Editor'), hidden=not request.cfg.show_names),
-            Column('comment', label=_('Comment')),
-            Column('action', label=_('Action')),
-            ]
-
-        # generate history list
-        revisions = page.getRevList()
-        versions = len(revisions)
-
-        may_revert = request.user.may.revert(pagename)
-
-        # read in the complete log of this page
-        log = editlog.EditLog(request, rootpagename=pagename)
-        count = 0
-        for line in log.reverse():
-            rev = int(line.rev)
-            actions = ""
-            if line.action in ['SAVE', 'SAVENEW', 'SAVE/REVERT', ]:
-                size = page.size(rev=rev)
-                if count == 0: # latest page
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('view'),
-                        querystr=''))
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('raw'),
-                        querystr='action=raw', rel='nofollow'))
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('print'),
-                        querystr='action=print', rel='nofollow'))
-                else:
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('view'),
-                        querystr='action=recall&rev=%d' % rev, rel='nofollow'))
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('raw'),
-                        querystr='action=raw&rev=%d' % rev, rel='nofollow'))
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('print'),
-                        querystr='action=print&rev=%d' % rev, rel='nofollow'))
-                    if may_revert and size: # you can only revert to nonempty revisions
-                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                            text=_('revert'),
-                            querystr='action=revert&rev=%d' % rev, rel='nofollow'))
-                if count == 0:
-                    rchecked = ' checked="checked"'
-                    lchecked = ''
-                elif count == 1:
-                    lchecked = ' checked="checked"'
-                    rchecked = ''
-                else:
-                    lchecked = rchecked = ''
-                diff = '<input type="radio" name="rev1" value="%d"%s><input type="radio" name="rev2" value="%d"%s>' % (rev, lchecked, rev, rchecked)
-                comment = line.comment
-                if not comment and '/REVERT' in line.action:
-                        comment = _("Revert to revision %(rev)d.") % {'rev': int(line.extra)}
-            else: # ATT*
-                rev = '-'
-                diff = '-'
-
-                filename = wikiutil.url_unquote(line.extra)
-                comment = "%s: %s %s" % (line.action, filename, line.comment)
-                size = 0
-                if line.action != 'ATTDEL':
-                    from MoinMoin.action import AttachFile
-                    page_dir = AttachFile.getAttachDir(request, pagename)
-                    filepath = os.path.join(page_dir, filename)
-                    try:
-                        # FIXME, wrong path on non-std names
-                        size = os.path.getsize(filepath)
-                    except:
-                        pass
-                    if line.action == 'ATTNEW':
-                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                            text=_('view'),
-                            querystr='action=AttachFile&do=view&target=%s' % filename, rel='nofollow'))
-                    elif line.action == 'ATTDRW':
-                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                            text=_('edit'),
-                            querystr='action=AttachFile&drawing=%s' % filename.replace(".draw", ""), rel='nofollow'))
-
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('get'),
-                        querystr='action=AttachFile&do=get&target=%s' % filename, rel='nofollow'))
-                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
-                        text=_('del'),
-                        querystr='action=AttachFile&do=del&target=%s' % filename, rel='nofollow'))
-                    # XXX use?: wikiutil.escape(filename)
-
-            history.addRow((
-                rev,
-                request.user.getFormattedDateTime(wikiutil.version2timestamp(line.ed_time_usecs)),
-                str(size),
-                diff,
-                line.getEditor(request) or _("N/A"),
-                wikiutil.escape(comment) or '&nbsp;',
-                actions,
-            ))
-            count += 1
-            if count >= 100:
-                break
-
-        # print version history
-        from MoinMoin.widget.browser import DataBrowserWidget
-
-        request.write('<h2>%s</h2>\n' % _('Revision History'))
-
-        if not count: # there was no entry in logfile
-            request.write(_('No log entries found.'))
-            return
-
-        # TODO: this form activates revert, which should use POST, but
-        # other actions should use get. Maybe we should put the revert
-        # into the page view itself, and not in this form.
-        request.write('<form method="GET" action="">\n')
-        request.write('<div id="page-history">\n')
-        request.write('<input type="hidden" name="action" value="diff">\n')
-
-        history_table = DataBrowserWidget(request)
-        history_table.setData(history)
-        history_table.render()
-        request.write('</div>\n')
-        request.write('</form>\n')
-
-    # main function
-    _ = request.getText
-    page = Page(request, pagename)
-    qpagename = wikiutil.quoteWikinameURL(pagename)
-    title = page.split_title(request)
-
-    request.http_headers()
-
-    # This action uses page or wiki language TODO: currently
-    # page.language is broken and not available now, when we fix it,
-    # this will be automatically fixed.
-    lang = page.language or request.cfg.language_default
-    request.setContentLanguage(lang)
-
-    request.theme.send_title(_('Info for "%s"') % (title,), pagename=pagename)
-
-    historylink = wikiutil.link_tag(request, '%s?action=info' % qpagename,
-        _('Show "%(title)s"') % {'title': _('Revision History')}, request.formatter, rel='nofollow')
-    generallink = wikiutil.link_tag(request, '%s?action=info&amp;general=1' % qpagename,
-        _('Show "%(title)s"') % {'title': _('General Page Infos')}, request.formatter, rel='nofollow')
-    hitcountlink = wikiutil.link_tag(request, '%s?action=info&amp;hitcounts=1' % qpagename,
-        _('Show chart "%(title)s"') % {'title': _('Page hits and edits')}, request.formatter, rel='nofollow')
-
-    request.write('<div id="content">\n') # start content div
-    request.write("<p>[%s]  [%s]  [%s]</p>" % (historylink, generallink, hitcountlink))
-
-    show_hitcounts = int(request.form.get('hitcounts', [0])[0]) != 0
-    show_general = int(request.form.get('general', [0])[0]) != 0
-
-    if show_hitcounts:
-        from MoinMoin.stats import hitcounts
-        request.write(hitcounts.linkto(pagename, request, 'page=' + wikiutil.url_quote_plus(pagename)))
-    elif show_general:
-        general(page, pagename, request)
-    else:
-        history(page, pagename, request)
-
-    request.write('</div>\n') # end content div
-    request.theme.send_footer(pagename)
-    request.theme.send_closing_html()
-
 def do_quicklink(pagename, request):
     """ Add the current wiki page to the user quicklinks 
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/diff.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,163 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - show diff between 2 page revisions
+
+    @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
+                2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin import wikiutil
+from MoinMoin.logfile import editlog
+from MoinMoin.Page import Page
+
+def execute(pagename, request):
+    """ Handle "action=diff"
+        checking for either a "rev=formerrevision" parameter
+        or rev1 and rev2 parameters
+    """
+    if not request.user.may.read(pagename):
+        Page(request, pagename).send_page(request)
+        return
+
+    try:
+        date = request.form['date'][0]
+        try:
+            date = long(date) # must be long for py 2.2.x
+        except StandardError:
+            date = 0
+    except KeyError:
+        date = 0
+
+    try:
+        rev1 = int(request.form.get('rev1', [-1])[0])
+    except StandardError:
+        rev1 = 0
+    try:
+        rev2 = int(request.form.get('rev2', [0])[0])
+    except StandardError:
+        rev1 = 0
+
+    if rev1 == -1 and rev2 == 0:
+        try:
+            rev1 = int(request.form.get('rev', [-1])[0])
+        except StandardError:
+            rev1 = -1
+
+    # spacing flag?
+    ignorews = int(request.form.get('ignorews', [0])[0])
+
+    _ = request.getText
+
+    # get a list of old revisions, and back out if none are available
+    currentpage = Page(request, pagename)
+    revisions = currentpage.getRevList()
+    if len(revisions) < 2:
+        currentpage.send_page(request, msg=_("No older revisions available!"))
+        return
+
+    if date: # this is how we get called from RecentChanges
+        rev1 = 0
+        log = editlog.EditLog(request, rootpagename=pagename)
+        for line in log.reverse():
+            if date >= line.ed_time_usecs and int(line.rev) != 99999999:
+                rev1 = int(line.rev)
+                break
+        else:
+            rev1 = 1
+        rev2 = 0
+
+    # Start output
+    # This action generate content in the user language
+    request.setContentLanguage(request.lang)
+
+    request.http_headers()
+    request.theme.send_title(_('Diff for "%s"') % (pagename,), pagename=pagename, allow_doubleclick=1)
+
+    if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
+        rev1, rev2 = rev2, rev1
+
+    oldrev1, oldcount1 = None, 0
+    oldrev2, oldcount2 = None, 0
+
+    # get the filename of the version to compare to
+    edit_count = 0
+    for rev in revisions:
+        edit_count += 1
+        if rev <= rev1:
+            oldrev1, oldcount1 = rev, edit_count
+        if rev2 and rev >= rev2:
+            oldrev2, oldcount2 = rev, edit_count
+        if oldrev1 and oldrev2 or oldrev1 and not rev2:
+            break
+
+    if rev1 == -1:
+        oldpage = Page(request, pagename, rev=revisions[1])
+        oldcount1 -= 1
+    elif rev1 == 0:
+        oldpage = currentpage
+        # oldcount1 is still on init value 0
+    else:
+        if oldrev1:
+            oldpage = Page(request, pagename, rev=oldrev1)
+        else:
+            oldpage = Page(request, "$EmptyPage$") # hack
+            oldpage.set_raw_body("")    # avoid loading from disk
+            oldrev1 = 0 # XXX
+
+    if rev2 == 0:
+        newpage = currentpage
+        # oldcount2 is still on init value 0
+    else:
+        if oldrev2:
+            newpage = Page(request, pagename, rev=oldrev2)
+        else:
+            newpage = Page(request, "$EmptyPage$") # hack
+            newpage.set_raw_body("")    # avoid loading from disk
+            oldrev2 = 0 # XXX
+
+    edit_count = abs(oldcount1 - oldcount2)
+
+    # this should use the formatter, but there is none?
+    request.write('<div id="content">\n') # start content div
+    request.write('<p class="diff-header">')
+    request.write(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_rev()))
+    if edit_count > 1:
+        request.write(' ' + _('(spanning %d versions)') % (edit_count,))
+    request.write('</p>')
+
+    if request.user.show_fancy_diff:
+        from MoinMoin.util import diff_html
+        request.write(diff_html.diff(request, oldpage.get_raw_body(), newpage.get_raw_body()))
+        newpage.send_page(request, count_hit=0, content_only=1, content_id="content-below-diff")
+    else:
+        from MoinMoin.util import diff_text
+        lines = diff_text.diff(oldpage.getlines(), newpage.getlines())
+        if not lines:
+            msg = _("No differences found!")
+            if edit_count > 1:
+                msg = msg + '<p>' + _('The page was saved %(count)d times, though!') % {
+                    'count': edit_count}
+            request.write(msg)
+        else:
+            if ignorews:
+                request.write(_('(ignoring whitespace)') + '<br>')
+            else:
+                qstr = 'action=diff&ignorews=1'
+                if rev1: qstr = '%s&rev1=%s' % (qstr, rev1)
+                if rev2: qstr = '%s&rev2=%s' % (qstr, rev2)
+                request.write(Page(request, pagename).link_to(request,
+                    text=_('Ignore changes in the amount of whitespace'),
+                    querystr=qstr, rel='nofollow') + '<p>')
+
+            request.write('<pre>')
+            for line in lines:
+                if line[0] == "@":
+                    request.write('<hr>')
+                request.write(wikiutil.escape(line)+'\n')
+            request.write('</pre>')
+
+    request.write('</div>\n') # end content div
+    request.theme.send_footer(pagename)
+    request.theme.send_closing_html()
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/edit.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,164 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - edit a page
+
+    This either calls the text or the GUI page editor.
+
+    @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
+                2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+from MoinMoin import wikiutil
+from MoinMoin.Page import Page
+
+def execute(pagename, request):
+    """ edit a page """
+    _ = request.getText
+
+    if not request.user.may.write(pagename):
+        Page(request, pagename).send_page(request,
+            msg=_('You are not allowed to edit this page.'))
+        return
+
+    valideditors = ['text', 'gui', ]
+    editor = ''
+    if request.user.valid:
+        editor = request.user.editor_default
+    if editor not in valideditors:
+        editor = request.cfg.editor_default
+
+    editorparam = request.form.get('editor', [editor])[0]
+    if editorparam == "guipossible":
+        lasteditor = editor
+    elif editorparam == "textonly":
+        editor = lasteditor = 'text'
+    else:
+        editor = lasteditor = editorparam
+
+    if request.cfg.editor_force:
+        editor = request.cfg.editor_default
+
+    # if it is still nothing valid, we just use the text editor
+    if editor not in valideditors:
+        editor = 'text'
+
+    savetext = request.form.get('savetext', [None])[0]
+    rev = int(request.form.get('rev', ['0'])[0])
+    comment = request.form.get('comment', [u''])[0]
+    category = request.form.get('category', [None])[0]
+    rstrip = int(request.form.get('rstrip', ['0'])[0])
+    trivial = int(request.form.get('trivial', ['0'])[0])
+
+    if request.form.has_key('button_switch'):
+        if editor == 'text':
+            editor = 'gui'
+        else: # 'gui'
+            editor = 'text'
+
+    # load right editor class
+    if editor == 'gui':
+        from MoinMoin.PageGraphicalEditor import PageGraphicalEditor
+        pg = PageGraphicalEditor(request, pagename)
+    else: # 'text'
+        from MoinMoin.PageEditor import PageEditor
+        pg = PageEditor(request, pagename)
+
+    # is invoked without savetext start editing
+    if savetext is None:
+        pg.sendEditor()
+        return
+
+    # did user hit cancel button?
+    cancelled = request.form.has_key('button_cancel')
+
+    # convert input from Graphical editor
+    from MoinMoin.converter.text_html_text_moin_wiki import convert, ConvertError
+    try:
+        if lasteditor == 'gui':
+            savetext = convert(request, pagename, savetext)
+
+        # IMPORTANT: normalize text from the form. This should be done in
+        # one place before we manipulate the text.
+        savetext = pg.normalizeText(savetext, stripspaces=rstrip)
+    except ConvertError:
+        # we don't want to throw an exception if user cancelled anyway
+        if not cancelled:
+            raise
+
+    if cancelled:
+        pg.sendCancel(savetext or "", rev)
+        return
+
+    comment = wikiutil.clean_comment(comment)
+
+    # Add category
+
+    # TODO: this code does not work with extended links, and is doing
+    # things behind your back, and in general not needed. Either we have
+    # a full interface for categories (add, delete) or just add them by
+    # markup.
+
+    if category and category != _('<No addition>', formatted=False): # opera 8.5 needs this
+        # strip trailing whitespace
+        savetext = savetext.rstrip()
+
+        # Add category separator if last non-empty line contains
+        # non-categories.
+        lines = filter(None, savetext.splitlines())
+        if lines:
+
+            #TODO: this code is broken, will not work for extended links
+            #categories, e.g ["category hebrew"]
+            categories = lines[-1].split()
+
+            if categories:
+                confirmed = wikiutil.filterCategoryPages(request, categories)
+                if len(confirmed) < len(categories):
+                    # This was not a categories line, add separator
+                    savetext += u'\n----\n'
+
+        # Add new category
+        if savetext and savetext[-1] != u'\n':
+            savetext += ' '
+        savetext += category + u'\n' # Should end with newline!
+
+    # Preview, spellcheck or spellcheck add new words
+    if (request.form.has_key('button_preview') or
+        request.form.has_key('button_spellcheck') or
+        request.form.has_key('button_newwords')):
+        pg.sendEditor(preview=savetext, comment=comment)
+
+    # Preview with mode switch
+    elif request.form.has_key('button_switch'):
+        pg.sendEditor(preview=savetext, comment=comment, staytop=1)
+
+    # Save new text
+    else:
+        try:
+            still_conflict = wikiutil.containsConflictMarker(savetext)
+            pg.setConflict(still_conflict)
+            request.http_headers() # XXX WHY? XXX
+            savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment)
+        except pg.EditConflict, e:
+            msg = e.message
+
+            # Handle conflict and send editor
+            pg.set_raw_body(savetext, modified=1)
+
+            pg.mergeEditConflict(rev)
+            # We don't send preview when we do merge conflict
+            pg.sendEditor(msg=msg, comment=comment)
+            return
+
+        except pg.SaveError, msg:
+            # msg contains a unicode string
+            savemsg = unicode(msg)
+
+        # Send new page after save or after unsuccessful conflict merge.
+        request.reset()
+        backto = request.form.get('backto', [None])[0]
+        if backto:
+            pg = Page(request, backto)
+
+        pg.send_page(request, msg=savemsg)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/info.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,245 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - info action
+
+    Displays page history, some general page infos and statistics.
+
+    @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
+                2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin import config, wikiutil, action
+from MoinMoin.Page import Page
+from MoinMoin.logfile import editlog
+
+def execute(pagename, request):
+    """ show misc. infos about a page """
+    if not request.user.may.read(pagename):
+        Page(request, pagename).send_page(request)
+        return
+
+    def general(page, pagename, request):
+        _ = request.getText
+
+        request.write('<h2>%s</h2>\n' % _('General Information'))
+
+        # show page size
+        request.write(("<p>%s</p>" % _("Page size: %d")) % page.size())
+
+        # show SHA digest fingerprint
+        import sha
+        digest = sha.new(page.get_raw_body().encode(config.charset)).hexdigest().upper()
+        request.write('<p>%(label)s <tt>%(value)s</tt></p>' % {
+            'label': _("SHA digest of this page's content is:"),
+            'value': digest,
+            })
+
+        # show attachments (if allowed)
+        attachment_info = action.getHandler(request, 'AttachFile', 'info')
+        if attachment_info:
+            request.write(attachment_info(pagename, request))
+
+        # show subscribers
+        subscribers = page.getSubscribers(request, include_self=1, return_users=1)
+        if subscribers:
+            request.write('<p>', _('The following users subscribed to this page:'))
+            for lang in subscribers.keys():
+                request.write('<br>[%s] ' % lang)
+                for user in subscribers[lang]:
+                    # do NOT disclose email addr, only WikiName
+                    userhomepage = Page(request, user.name)
+                    if userhomepage.exists():
+                        request.write(userhomepage.link_to(request) + ' ')
+                    else:
+                        request.write(user.name + ' ')
+            request.write('</p>')
+
+        # show links
+        links = page.getPageLinks(request)
+        if links:
+            request.write('<p>', _('This page links to the following pages:'), '<br>')
+            for linkedpage in links:
+                request.write("%s%s " % (Page(request, linkedpage).link_to(request), ",."[linkedpage == links[-1]]))
+            request.write("</p>")
+
+    def history(page, pagename, request):
+        # show history as default
+        _ = request.getText
+
+        # open log for this page
+        from MoinMoin.util.dataset import TupleDataset, Column
+
+        history = TupleDataset()
+        history.columns = [
+            Column('rev', label='#', align='right'),
+            Column('mtime', label=_('Date'), align='right'),
+            Column('size', label=_('Size'), align='right'),
+            Column('diff', label='<input type="submit" value="%s">' % (_("Diff"))),
+            Column('editor', label=_('Editor'), hidden=not request.cfg.show_names),
+            Column('comment', label=_('Comment')),
+            Column('action', label=_('Action')),
+            ]
+
+        # generate history list
+        revisions = page.getRevList()
+        versions = len(revisions)
+
+        may_revert = request.user.may.revert(pagename)
+
+        # read in the complete log of this page
+        log = editlog.EditLog(request, rootpagename=pagename)
+        count = 0
+        for line in log.reverse():
+            rev = int(line.rev)
+            actions = ""
+            if line.action in ['SAVE', 'SAVENEW', 'SAVE/REVERT', ]:
+                size = page.size(rev=rev)
+                if count == 0: # latest page
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('view'),
+                        querystr=''))
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('raw'),
+                        querystr='action=raw', rel='nofollow'))
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('print'),
+                        querystr='action=print', rel='nofollow'))
+                else:
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('view'),
+                        querystr='action=recall&rev=%d' % rev, rel='nofollow'))
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('raw'),
+                        querystr='action=raw&rev=%d' % rev, rel='nofollow'))
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('print'),
+                        querystr='action=print&rev=%d' % rev, rel='nofollow'))
+                    if may_revert and size: # you can only revert to nonempty revisions
+                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                            text=_('revert'),
+                            querystr='action=revert&rev=%d' % rev, rel='nofollow'))
+                if count == 0:
+                    rchecked = ' checked="checked"'
+                    lchecked = ''
+                elif count == 1:
+                    lchecked = ' checked="checked"'
+                    rchecked = ''
+                else:
+                    lchecked = rchecked = ''
+                diff = '<input type="radio" name="rev1" value="%d"%s><input type="radio" name="rev2" value="%d"%s>' % (rev, lchecked, rev, rchecked)
+                comment = line.comment
+                if not comment and '/REVERT' in line.action:
+                        comment = _("Revert to revision %(rev)d.") % {'rev': int(line.extra)}
+            else: # ATT*
+                rev = '-'
+                diff = '-'
+
+                filename = wikiutil.url_unquote(line.extra)
+                comment = "%s: %s %s" % (line.action, filename, line.comment)
+                size = 0
+                if line.action != 'ATTDEL':
+                    from MoinMoin.action import AttachFile
+                    page_dir = AttachFile.getAttachDir(request, pagename)
+                    filepath = os.path.join(page_dir, filename)
+                    try:
+                        # FIXME, wrong path on non-std names
+                        size = os.path.getsize(filepath)
+                    except:
+                        pass
+                    if line.action == 'ATTNEW':
+                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                            text=_('view'),
+                            querystr='action=AttachFile&do=view&target=%s' % filename, rel='nofollow'))
+                    elif line.action == 'ATTDRW':
+                        actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                            text=_('edit'),
+                            querystr='action=AttachFile&drawing=%s' % filename.replace(".draw", ""), rel='nofollow'))
+
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('get'),
+                        querystr='action=AttachFile&do=get&target=%s' % filename, rel='nofollow'))
+                    actions = '%s&nbsp;%s' % (actions, page.link_to(request,
+                        text=_('del'),
+                        querystr='action=AttachFile&do=del&target=%s' % filename, rel='nofollow'))
+                    # XXX use?: wikiutil.escape(filename)
+
+            history.addRow((
+                rev,
+                request.user.getFormattedDateTime(wikiutil.version2timestamp(line.ed_time_usecs)),
+                str(size),
+                diff,
+                line.getEditor(request) or _("N/A"),
+                wikiutil.escape(comment) or '&nbsp;',
+                actions,
+            ))
+            count += 1
+            if count >= 100:
+                break
+
+        # print version history
+        from MoinMoin.widget.browser import DataBrowserWidget
+
+        request.write('<h2>%s</h2>\n' % _('Revision History'))
+
+        if not count: # there was no entry in logfile
+            request.write(_('No log entries found.'))
+            return
+
+        # TODO: this form activates revert, which should use POST, but
+        # other actions should use get. Maybe we should put the revert
+        # into the page view itself, and not in this form.
+        request.write('<form method="GET" action="">\n')
+        request.write('<div id="page-history">\n')
+        request.write('<input type="hidden" name="action" value="diff">\n')
+
+        history_table = DataBrowserWidget(request)
+        history_table.setData(history)
+        history_table.render()
+        request.write('</div>\n')
+        request.write('</form>\n')
+
+    # main function
+    _ = request.getText
+    page = Page(request, pagename)
+    qpagename = wikiutil.quoteWikinameURL(pagename)
+    title = page.split_title(request)
+
+    request.http_headers()
+
+    # This action uses page or wiki language TODO: currently
+    # page.language is broken and not available now, when we fix it,
+    # this will be automatically fixed.
+    lang = page.language or request.cfg.language_default
+    request.setContentLanguage(lang)
+
+    request.theme.send_title(_('Info for "%s"') % (title,), pagename=pagename)
+    menu_items = [
+        (_('Show "%(title)s"') % {'title': _('Revision History')},
+         {'action': 'info'}),
+        (_('Show "%(title)s"') % {'title': _('General Page Infos')},
+         {'action': 'info', 'general': '1'}),
+        (_('Show "%(title)s"') % {'title': _('Page hits and edits')},
+         {'action': 'info', 'hitcounts': '1'}),
+    ]
+    request.write('<div id="content">\n') # start content div
+    request.write("<p>")
+    for text, querystr in menu_items:
+        request.write("[%s] " % page.link_to(request, text=text, querystr=querystr, rel='nofollow'))
+    request.write("</p>")
+
+    show_hitcounts = int(request.form.get('hitcounts', [0])[0]) != 0
+    show_general = int(request.form.get('general', [0])[0]) != 0
+
+    if show_hitcounts:
+        from MoinMoin.stats import hitcounts
+        request.write(hitcounts.linkto(pagename, request, 'page=' + wikiutil.url_quote_plus(pagename)))
+    elif show_general:
+        general(page, pagename, request)
+    else:
+        history(page, pagename, request)
+
+    request.write('</div>\n') # end content div
+    request.theme.send_footer(pagename)
+    request.theme.send_closing_html()
+
--- a/MoinMoin/config.py	Mon Jul 24 01:19:18 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - site-wide configuration defaults (NOT per single wiki!)
-
-    @copyright: 2005-2006 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
-    @license: GNU GPL, see COPYING for details.
-"""
-import re
-
-# Threads flag - if you write a moin server that use threads, import
-# config in the server and set this flag to True.
-use_threads = False
-
-# Charset - we support only 'utf-8'. While older encodings might work,
-# we don't have the resources to test them, and there is no real
-# benefit for the user. IMPORTANT: use only lowercase 'utf-8'!
-charset = 'utf-8'
-
-# Invalid characters - invisible characters that should not be in page
-# names. Prevent user confusion and wiki abuse, e.g u'\u202aFrontPage'.
-page_invalid_chars_regex = re.compile(
-    ur"""
-    \u0000 | # NULL
-
-    # Bidi control characters
-    \u202A | # LRE
-    \u202B | # RLE
-    \u202C | # PDF
-    \u202D | # LRM
-    \u202E   # RLM
-    """,
-    re.UNICODE | re.VERBOSE
-    )
-
-# Other stuff
-umask = 0770
-url_schemas = []
-
-smileys = (r"X-( :D <:( :o :( :) B) :)) ;) /!\ <!> (!) :-? :\ >:> |) " +
-           r":-( :-) B-) :-)) ;-) |-) (./) {OK} {X} {i} {1} {2} {3} {*} {o}").split()
-
-# unicode: set the char types (upper, lower, digits, spaces)
-from MoinMoin.util.chartypes import _chartypes
-for key, val in _chartypes.items():
-    if not vars().has_key(key):
-        vars()[key] = val
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/config/__init__.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,50 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - site-wide configuration defaults (NOT per single wiki!)
+
+    @copyright: 2005-2006 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
+    @license: GNU GPL, see COPYING for details.
+"""
+import re
+
+# Threads flag - if you write a moin server that use threads, import
+# config in the server and set this flag to True.
+use_threads = False
+
+# Charset - we support only 'utf-8'. While older encodings might work,
+# we don't have the resources to test them, and there is no real
+# benefit for the user. IMPORTANT: use only lowercase 'utf-8'!
+charset = 'utf-8'
+
+# When creating files, we use e.g. 0666 & config.umask for the mode:
+umask = 0770
+
+# Invalid characters - invisible characters that should not be in page
+# names. Prevent user confusion and wiki abuse, e.g u'\u202aFrontPage'.
+page_invalid_chars_regex = re.compile(
+    ur"""
+    \u0000 | # NULL
+
+    # Bidi control characters
+    \u202A | # LRE
+    \u202B | # RLE
+    \u202C | # PDF
+    \u202D | # LRM
+    \u202E   # RLM
+    """,
+    re.UNICODE | re.VERBOSE
+    )
+
+# Other stuff
+url_schemas = []
+
+smileys = (r"X-( :D <:( :o :( :) B) :)) ;) /!\ <!> (!) :-? :\ >:> |) " +
+           r":-( :-) B-) :-)) ;-) |-) (./) {OK} {X} {i} {1} {2} {3} {*} {o}").split()
+
+# unicode: set the char types (upper, lower, digits, spaces)
+from MoinMoin.util.chartypes import _chartypes
+for key, val in _chartypes.items():
+    if not vars().has_key(key):
+        vars()[key] = val
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/config/multiconfig.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,716 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Multiple configuration handler and Configuration defaults class
+
+    @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
+                2005-2006 by MoinMoin:ThomasWaldmann.
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import re, os, sys
+from MoinMoin import error
+import MoinMoin.auth as authmodule
+
+_url_re_cache = None
+_farmconfig_mtime = None
+_config_cache = {}
+
+
+def _importConfigModule(name):
+    """ Import and return configuration module and its modification time
+    
+    Handle all errors except ImportError, because missing file is not
+    always an error.
+    
+    @param name: module name
+    @rtype: tuple
+    @return: module, modification time
+    """
+    try:
+        module = __import__(name, globals(), {})
+        mtime = os.path.getmtime(module.__file__)
+    except ImportError:
+        raise
+    except IndentationError, err:
+        msg = '''IndentationError: %(err)s
+
+The configuration files are python modules. Therefore, whitespace is
+important. Make sure that you use only spaces, no tabs are allowed here!
+You have to use four spaces at the beginning of the line mostly.
+''' % {
+    'err': err,
+}
+        raise error.ConfigurationError(msg)
+    except Exception, err:
+        msg = '%s: %s' % (err.__class__.__name__, str(err))
+        raise error.ConfigurationError(msg)
+    return module, mtime
+
+
+def _url_re_list():
+    """ Return url matching regular expression
+
+    Import wikis list from farmconfig on the first call and compile the
+    regexes. Later then return the cached regex list.
+
+    @rtype: list of tuples of (name, compiled re object)
+    @return: url to wiki config name matching list
+    """
+    global _url_re_cache, _farmconfig_mtime
+    if _url_re_cache is None:
+        try:
+            farmconfig, _farmconfig_mtime = _importConfigModule('farmconfig')
+        except ImportError:
+            # Default to wikiconfig for all urls.
+            _farmconfig_mtime = 0
+            _url_re_cache = [('wikiconfig', re.compile(r'.')), ] # matches everything
+        else:
+            try:
+                cache = []
+                for name, regex in farmconfig.wikis:
+                    cache.append((name, re.compile(regex)))
+                _url_re_cache = cache
+            except AttributeError:
+                msg = """
+Missing required 'wikis' list in 'farmconfig.py'.
+
+If you run a single wiki you do not need farmconfig.py. Delete it and
+use wikiconfig.py.
+"""
+                raise error.ConfigurationError(msg)
+    return _url_re_cache
+
+
+def _makeConfig(name):
+    """ Create and return a config instance 
+
+    Timestamp config with either module mtime or farmconfig mtime. This
+    mtime can be used later to invalidate older caches.
+
+    @param name: module name
+    @rtype: DefaultConfig sub class instance
+    @return: new configuration instance
+    """
+    global _farmconfig_mtime
+    try:
+        module, mtime = _importConfigModule(name)
+        configClass = getattr(module, 'Config')
+        cfg = configClass(name)
+        cfg.cfg_mtime = max(mtime, _farmconfig_mtime)
+    except ImportError, err:
+        msg = '''ImportError: %(err)s
+
+Check that the file is in the same directory as the server script. If
+it is not, you must add the path of the directory where the file is
+located to the python path in the server script. See the comments at
+the top of the server script.
+
+Check that the configuration file name is either "wikiconfig.py" or the
+module name specified in the wikis list in farmconfig.py. Note that the
+module name does not include the ".py" suffix.
+''' % {
+    'err': err,
+}
+        raise error.ConfigurationError(msg)
+    except AttributeError, err:
+        msg = '''AttributeError: %(err)s
+
+Could not find required "Config" class in "%(name)s.py".
+
+This might happen if you are trying to use a pre 1.3 configuration file, or
+made a syntax or spelling error.
+
+Another reason for this could be a name clash. It is not possible to have
+config names like e.g. stats.py - because that colides with MoinMoin/stats/ -
+have a look into your MoinMoin code directory what other names are NOT
+possible.
+
+Please check your configuration file. As an example for correct syntax,
+use the wikiconfig.py file from the distribution.
+''' % {
+    'name': name,
+    'err': err,
+}
+        raise error.ConfigurationError(msg)
+    return cfg
+
+
+def _getConfigName(url):
+    """ Return config name for url or raise """
+    for name, regex in _url_re_list():
+        match = regex.match(url)
+        if match:
+            return name
+    # nothing matched
+    msg = '''
+Could not find a match for url: "%(url)s".
+
+Check your URL regular expressions in the "wikis" list in
+"farmconfig.py". 
+''' % {
+    'url': url,
+}
+    raise error.ConfigurationError(msg)
+
+
+def getConfig(url):
+    """ Return cached config instance for url or create new one
+
+    If called by many threads in the same time multiple config
+    instances might be created. The first created item will be
+    returned, using dict.setdefault.
+
+    @param url: the url from request, possibly matching specific wiki
+    @rtype: DefaultConfig subclass instance
+    @return: config object for specific wiki
+    """
+    configName = _getConfigName(url)
+    try:
+        config = _config_cache[configName]
+    except KeyError:
+        config = _makeConfig(configName)
+        config = _config_cache.setdefault(configName, config)
+    return config
+
+
+# This is a way to mark some text for the gettext tools so that they don't
+# get orphaned. See http://www.python.org/doc/current/lib/node278.html.
+def _(text): return text
+
+
+class DefaultConfig:
+    """ default config values """
+
+    # All acl_rights_* lines must use unicode!
+    acl_rights_default = u"Trusted:read,write,delete,revert Known:read,write,delete,revert All:read,write"
+    acl_rights_before = u""
+    acl_rights_after = u""
+    acl_rights_valid = ['read', 'write', 'delete', 'revert', 'admin']
+
+    actions_excluded = [] # ['DeletePage', 'AttachFile', 'RenamePage', 'test', ]
+    allow_xslt = 0
+    attachments = None # {'dir': path, 'url': url-prefix}
+    auth = [authmodule.moin_login, authmodule.moin_session, ]
+
+    backup_compression = 'gz'
+    backup_users = []
+    backup_include = []
+    backup_exclude = [
+        r"(.+\.py(c|o)$)",
+        r"%(cache_dir)s",
+        r"%(/)spages%(/)s.+%(/)scache%(/)s[^%(/)s]+$" % {'/': os.sep},
+        r"%(/)s(edit-lock|event-log|\.DS_Store)$" % {'/': os.sep},
+        ]
+    backup_storage_dir = '/tmp'
+    backup_restore_target_dir = '/tmp'
+
+    bang_meta = 1
+    caching_formats = ['text_html']
+    changed_time_fmt = '%H:%M'
+
+    # chars_{upper,lower,digits,spaces} see MoinMoin/util/chartypes.py
+
+    # if you have gdchart, add something like
+    # chart_options = {'width = 720, 'height': 540}
+    chart_options = None
+
+    config_check_enabled = 0
+
+    cookie_domain = None # use '.domain.tld" for a farm with hosts in that domain
+    cookie_path = None   # use '/wikifarm" for a farm with pathes below that path
+    cookie_lifetime = 12 # 12 hours from now
+    cookie_secret = '1234' # secret value for crypting session cookie - you should change this :)
+
+    data_dir = './data/'
+    data_underlay_dir = './underlay/'
+
+    date_fmt = '%Y-%m-%d'
+    datetime_fmt = '%Y-%m-%d %H:%M:%S'
+
+    default_markup = 'wiki'
+    docbook_html_dir = r"/usr/share/xml/docbook/stylesheet/nwalsh/html/" # correct for debian sarge
+
+    editor_default = 'text' # which editor is called when nothing is specified
+    editor_ui = 'freechoice' # which editor links are shown on user interface
+    editor_force = False
+    editor_quickhelp = {# editor markup hints quickhelp 
+        'wiki': _("""\
+ Emphasis:: [[Verbatim('')]]''italics''[[Verbatim('')]]; [[Verbatim(''')]]'''bold'''[[Verbatim(''')]]; [[Verbatim(''''')]]'''''bold italics'''''[[Verbatim(''''')]]; [[Verbatim('')]]''mixed ''[[Verbatim(''')]]'''''bold'''[[Verbatim(''')]] and italics''[[Verbatim('')]]; [[Verbatim(----)]] horizontal rule.
+ Headings:: [[Verbatim(=)]] Title 1 [[Verbatim(=)]]; [[Verbatim(==)]] Title 2 [[Verbatim(==)]]; [[Verbatim(===)]] Title 3 [[Verbatim(===)]];   [[Verbatim(====)]] Title 4 [[Verbatim(====)]]; [[Verbatim(=====)]] Title 5 [[Verbatim(=====)]].
+ Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
+ Links:: [[Verbatim(JoinCapitalizedWords)]]; [[Verbatim(["brackets and double quotes"])]]; url; [url]; [url label].
+ Tables:: || cell text |||| cell text spanning 2 columns ||;    no trailing white space allowed after tables or titles.
+
+(!) For more help, see HelpOnEditing or SyntaxReference.
+"""),
+        'rst': _("""\
+Emphasis: <i>*italic*</i> <b>**bold**</b> ``monospace``<br/>
+<br/><pre>
+Headings: Heading 1  Heading 2  Heading 3
+          =========  ---------  ~~~~~~~~~
+
+Horizontal rule: ---- 
+Links: TrailingUnderscore_ `multi word with backticks`_ external_ 
+
+.. _external: http://external-site.net/foo/
+
+Lists: * bullets; 1., a. numbered items.
+</pre>
+<br/>
+(!) For more help, see the 
+<a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">
+reStructuredText Quick Reference
+</a>.
+"""),
+    }
+    edit_locking = 'warn 10' # None, 'warn <timeout mins>', 'lock <timeout mins>'
+    edit_rows = 20
+
+    hacks = {} # { 'feature1': value1, ... }
+               # Configuration for features still in development.
+               # For boolean stuff just use config like this:
+               #   hacks = { 'feature': True, ...}
+               # and in the code use:
+               #   if cfg.hacks.get('feature', False): <doit>
+               # A non-existing hack key should ever mean False, None, "", [] or {}!
+
+    hosts_deny = []
+
+    html_head = ''
+    html_head_queries = '''<meta name="robots" content="noindex,nofollow">\n'''
+    html_head_posts   = '''<meta name="robots" content="noindex,nofollow">\n'''
+    html_head_index   = '''<meta name="robots" content="index,follow">\n'''
+    html_head_normal  = '''<meta name="robots" content="index,nofollow">\n'''
+    html_pagetitle = None
+
+    interwiki_preferred = [] # list of wiki names to show at top of interwiki list
+
+    language_default = 'en'
+    language_ignore_browser = False # ignore browser settings, use language_default
+                                    # or user prefs
+
+    log_reverse_dns_lookups = True  # if we do reverse dns lookups for logging hostnames
+                                    # instead of just IPs
+
+    xapian_search = False # disabled until xapian is finished
+    xapian_index_dir = None
+    xapian_stemming = True
+
+    mail_login = None # or "user pwd" if you need to use SMTP AUTH
+    mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
+    mail_smarthost = None
+    mail_from = None # u'Juergen Wiki <noreply@jhwiki.org>'
+
+    mail_import_subpage_template = u"$from-$date-$subject" # used for mail import
+    mail_import_wiki_address = None # the e-mail address for e-mails that should go into the wiki
+    mail_import_secret = ""
+
+    navi_bar = [u'RecentChanges', u'FindPage', u'HelpContents', ]
+    nonexist_qm = 0
+
+    page_credits = [
+        '<a href="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a>',
+        '<a href="http://www.python.org/">Python Powered</a>',
+        '<a href="http://validator.w3.org/check?uri=referer">Valid HTML 4.01</a>',
+        ]
+    page_footer1 = ''
+    page_footer2 = ''
+
+    page_header1 = ''
+    page_header2 = ''
+
+    page_front_page = u'HelpOnLanguages' # this will make people choose a sane config
+    page_local_spelling_words = u'LocalSpellingWords'
+    page_category_regex = u'^Category[A-Z]'
+    page_dict_regex = u'[a-z0-9]Dict$'
+    page_group_regex = u'[a-z0-9]Group$'
+    page_template_regex = u'[a-z0-9]Template$'
+
+    page_license_enabled = 0
+    page_license_page = u'WikiLicense'
+
+    # These icons will show in this order in the iconbar, unless they
+    # are not relevant, e.g email icon when the wiki is not configured
+    # for email.
+    page_iconbar = ["up", "edit", "view", "diff", "info", "subscribe", "raw", "print", ]
+
+    # Standard buttons in the iconbar
+    page_icons_table = {
+        # key           last part of url, title, icon-key
+        'help':        ("%(q_page_help_contents)s", "%(page_help_contents)s", "help"),
+        'find':        ("%(q_page_find_page)s?value=%(q_page_name)s", "%(page_find_page)s", "find"),
+        'diff':        ("%(q_page_name)s?action=diff", _("Diffs"), "diff"),
+        'info':        ("%(q_page_name)s?action=info", _("Info"), "info"),
+        'edit':        ("%(q_page_name)s?action=edit", _("Edit"), "edit"),
+        'unsubscribe': ("%(q_page_name)s?action=subscribe", _("UnSubscribe"), "unsubscribe"),
+        'subscribe':   ("%(q_page_name)s?action=subscribe", _("Subscribe"), "subscribe"),
+        'raw':         ("%(q_page_name)s?action=raw", _("Raw"), "raw"),
+        'xml':         ("%(q_page_name)s?action=show&amp;mimetype=text/xml", _("XML"), "xml"),
+        'print':       ("%(q_page_name)s?action=print", _("Print"), "print"),
+        'view':        ("%(q_page_name)s", _("View"), "view"),
+        'up':          ("%(q_page_parent_page)s", _("Up"), "up"),
+        }
+
+    refresh = None # (minimum_delay, type), e.g.: (2, 'internal')
+    rss_cache = 60 # suggested caching time for RecentChanges RSS, in seconds
+    shared_intermap = None # can be string or list of strings (filenames)
+    show_hosts = 1
+    show_interwiki = 0
+    show_login = 1
+    show_names = True
+    show_section_numbers = 0
+    show_timings = 0
+    show_version = 0
+    siteid = 'default'
+    stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
+    superuser = [] # list of unicode user names that have super powers :)
+
+    surge_action_limits = {# allow max. <count> <action> requests per <dt> secs
+        # action: (count, dt)
+        'all': (30, 30),
+        'show': (30, 60),
+        'recall': (5, 60),
+        'raw': (20, 40),  # some people use this for css
+        'AttachFile': (90, 60),
+        'diff': (30, 60),
+        'fullsearch': (5, 60),
+        'edit': (10, 120),
+        'rss_rc': (1, 60),
+        'default': (30, 60),
+    }
+    surge_lockout_time = 3600 # secs you get locked out when you ignore warnings
+
+    theme_default = 'modern'
+    theme_force = False
+
+    trail_size = 5
+    tz_offset = 0.0 # default time zone offset in hours from UTC
+
+    user_autocreate = False # do we auto-create user profiles
+    user_email_unique = True # do we check whether a user's email is unique?
+
+    # a regex of HTTP_USER_AGENTS that should be excluded from logging
+    # and receive a FORBIDDEN for anything except viewing a page
+    ua_spiders = ('archiver|cfetch|crawler|curl|gigabot|googlebot|holmes|htdig|httrack|httpunit|jeeves|larbin|leech|'
+                  'linkbot|linkmap|linkwalk|mercator|mirror|msnbot|nutbot|omniexplorer|puf|robot|scooter|'
+                  'sherlock|slurp|sitecheck|spider|teleport|voyager|webreaper|wget')
+
+    # Wiki identity
+    sitename = u'Untitled Wiki'
+    url_prefix = '/wiki'
+    logo_string = None
+    interwikiname = None
+
+    url_mappings = {}
+
+    user_checkbox_fields = [
+        ('mailto_author', lambda _: _('Publish my email (not my wiki homepage) in author info')),
+        ('edit_on_doubleclick', lambda _: _('Open editor on double click')),
+        ('remember_last_visit', lambda _: _('After login, jump to last visited page')),
+        ('show_nonexist_qm', lambda _: _('Show question mark for non-existing pagelinks')),
+        ('show_page_trail', lambda _: _('Show page trail')),
+        ('show_toolbar', lambda _: _('Show icon toolbar')),
+        ('show_topbottom', lambda _: _('Show top/bottom links in headings')),
+        ('show_fancy_diff', lambda _: _('Show fancy diffs')),
+        ('wikiname_add_spaces', lambda _: _('Add spaces to displayed wiki names')),
+        ('remember_me', lambda _: _('Remember login information')),
+        ('want_trivial', lambda _: _('Subscribe to trivial changes')),
+
+        ('disabled', lambda _: _('Disable this account forever')),
+        # if an account is disabled, it may be used for looking up
+        # id -> username for page info and recent changes, but it
+        # is not usable for the user any more:
+    ]
+
+    user_checkbox_defaults = {'mailto_author':       0,
+                              'edit_on_doubleclick': 0,
+                              'remember_last_visit': 0,
+                              'show_nonexist_qm':    nonexist_qm,
+                              'show_page_trail':     1,
+                              'show_toolbar':        1,
+                              'show_topbottom':      0,
+                              'show_fancy_diff':     1,
+                              'wikiname_add_spaces': 0,
+                              'remember_me':         1,
+                              'want_trivial':        0,
+                             }
+
+    # don't let the user change those
+    # user_checkbox_disable = ['disabled', 'want_trivial']
+    user_checkbox_disable = []
+
+    # remove those checkboxes:
+    #user_checkbox_remove = ['edit_on_doubleclick', 'show_nonexist_qm', 'show_toolbar', 'show_topbottom',
+    #                        'show_fancy_diff', 'wikiname_add_spaces', 'remember_me', 'disabled',]
+    user_checkbox_remove = []
+
+    user_form_fields = [
+        ('name', _('Name'), "text", "36", _("(Use Firstname''''''Lastname)")),
+        ('aliasname', _('Alias-Name'), "text", "36", ''),
+        ('password', _('Password'), "password", "36", ''),
+        ('password2', _('Password repeat'), "password", "36", _('(Only for password change or new account)')),
+        ('email', _('Email'), "text", "36", ''),
+        ('css_url', _('User CSS URL'), "text", "40", _('(Leave it empty for disabling user CSS)')),
+        ('edit_rows', _('Editor size'), "text", "3", ''),
+    ]
+
+    user_form_defaults = {# key: default - do NOT remove keys from here!
+        'name': '',
+        'aliasname': '',
+        'password': '',
+        'password2': '',
+        'email': '',
+        'css_url': '',
+        'edit_rows': "20",
+    }
+
+    # don't let the user change those, but show them:
+    #user_form_disable = ['name', 'aliasname', 'email',]
+    user_form_disable = []
+
+    # remove those completely:
+    #user_form_remove = ['password', 'password2', 'css_url', 'logout', 'create', 'account_sendmail',]
+    user_form_remove = []
+
+    # attributes we do NOT save to the userpref file
+    user_transient_fields = ['id', 'valid', 'may', 'auth_username', 'trusted', 'password', 'password2', 'auth_method', 'auth_attribs', ]
+
+    user_homewiki = 'Self' # interwiki name for where user homepages are located
+
+    unzip_single_file_size = 2.0 * 1000**2
+    unzip_attachments_space = 200.0 * 1000**2
+    unzip_attachments_count = 51 # 1 zip file + 50 files contained in it
+
+    xmlrpc_putpage_enabled = 0 # if 0, putpage will write to a test page only
+    xmlrpc_putpage_trusted_only = 1 # if 1, you will need to be http auth authenticated
+
+    SecurityPolicy = None
+
+    def __init__(self, siteid):
+        """ Init Config instance """
+        self.siteid = siteid
+        if self.config_check_enabled:
+            self._config_check()
+
+        # define directories
+        self.moinmoin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
+        data_dir = os.path.normpath(self.data_dir)
+        self.data_dir = data_dir
+        for dirname in ('user', 'cache', 'plugin'):
+            name = dirname + '_dir'
+            if not getattr(self, name, None):
+                setattr(self, name, os.path.join(data_dir, dirname))
+
+        # Try to decode certain names which allow unicode
+        self._decode()
+
+        self._check_directories()
+
+        if not isinstance(self.superuser, list):
+            msg = """The superuser setting in your wiki configuration is not a list
+                     (e.g. ['Sample User', 'AnotherUser']).
+                     Please change it in your wiki configuration and try again."""
+            raise error.ConfigurationError(msg)
+
+        self._loadPluginModule()
+
+        # Preparse user dicts
+        self._fillDicts()
+
+        # Normalize values
+        self.language_default = self.language_default.lower()
+
+        # Use site name as default name-logo
+        if self.logo_string is None:
+            self.logo_string = self.sitename
+
+        # Check for needed modules
+
+        # FIXME: maybe we should do this check later, just before a
+        # chart is needed, maybe in the chart module, instead doing it
+        # for each request. But this require a large refactoring of
+        # current code.
+        if self.chart_options:
+            try:
+                import gdchart
+            except ImportError:
+                self.chart_options = None
+
+        # post process
+        # we replace any string placeholders with config values
+        # e.g u'%(page_front_page)s' % self
+        self.navi_bar = [elem % self for elem in self.navi_bar]
+        self.backup_exclude = [elem % self for elem in self.backup_exclude]
+
+        # list to cache xapian searcher objects
+        self.xapian_searchers = []
+
+        # check if mail is possible and set flag:
+        self.mail_enabled = (self.mail_smarthost is not None or self.mail_sendmail is not None) and self.mail_from
+
+    def _config_check(self):
+        """ Check namespace and warn about unknown names
+        
+        Warn about names which are not used by DefaultConfig, except
+        modules, classes, _private or __magic__ names.
+
+        This check is disabled by default, when enabled, it will show an
+        error message with unknown names.
+        """
+        unknown = ['"%s"' % name for name in dir(self)
+                  if not name.startswith('_') and
+                  not DefaultConfig.__dict__.has_key(name) and
+                  not isinstance(getattr(self, name), (type(sys), type(DefaultConfig)))]
+        if unknown:
+            msg = """
+Unknown configuration options: %s.
+
+For more information, visit HelpOnConfiguration. Please check your
+configuration for typos before requesting support or reporting a bug.
+""" % ', '.join(unknown)
+            raise error.ConfigurationError(msg)
+
+    def _decode(self):
+        """ Try to decode certain names, ignore unicode values
+        
+        Try to decode str using utf-8. If the decode fail, raise FatalError. 
+
+        Certain config variables should contain unicode values, and
+        should be defined with u'text' syntax. Python decode these if
+        the file have a 'coding' line.
+        
+        This will allow utf-8 users to use simple strings using, without
+        using u'string'. Other users will have to use u'string' for
+        these names, because we don't know what is the charset of the
+        config files.
+        """
+        charset = 'utf-8'
+        message = u'''
+"%(name)s" configuration variable is a string, but should be
+unicode. Use %(name)s = u"value" syntax for unicode variables.
+
+Also check your "-*- coding -*-" line at the top of your configuration
+file. It should match the actual charset of the configuration file.
+'''
+
+        decode_names = (
+            'sitename', 'logo_string', 'navi_bar', 'page_front_page',
+            'page_category_regex', 'page_dict_regex',
+            'page_group_regex', 'page_template_regex', 'page_license_page',
+            'page_local_spelling_words', 'acl_rights_default',
+            'acl_rights_before', 'acl_rights_after', 'mail_from'
+            )
+
+        for name in decode_names:
+            attr = getattr(self, name, None)
+            if attr:
+                # Try to decode strings
+                if isinstance(attr, str):
+                    try:
+                        setattr(self, name, unicode(attr, charset))
+                    except UnicodeError:
+                        raise error.ConfigurationError(message %
+                                                       {'name': name})
+                # Look into lists and try to decode strings inside them
+                elif isinstance(attr, list):
+                    for i in xrange(len(attr)):
+                        item = attr[i]
+                        if isinstance(item, str):
+                            try:
+                                attr[i] = unicode(item, charset)
+                            except UnicodeError:
+                                raise error.ConfigurationError(message %
+                                                               {'name': name})
+
+    def _check_directories(self):
+        """ Make sure directories are accessible
+
+        Both data and underlay should exists and allow read, write and
+        execute.
+        """
+        mode = os.F_OK | os.R_OK | os.W_OK | os.X_OK
+        for attr in ('data_dir', 'data_underlay_dir'):
+            path = getattr(self, attr)
+
+            # allow an empty underlay path or None
+            if attr == 'data_underlay_dir' and not path:
+                continue
+
+            path_pages = os.path.join(path, "pages")
+            if not (os.path.isdir(path_pages) and os.access(path_pages, mode)):
+                msg = '''
+%(attr)s "%(path)s" does not exists, or has incorrect ownership or
+permissions.
+
+Make sure the directory and the subdirectory pages are owned by the web
+server and are readable, writable and executable by the web server user
+and group.
+
+It is recommended to use absolute paths and not relative paths. Check
+also the spelling of the directory name.
+''' % {'attr': attr, 'path': path, }
+                raise error.ConfigurationError(msg)
+
+    def _loadPluginModule(self):
+        """ import plugin module under configname.plugin
+
+        To be able to import plugin from arbitrary path, we have to load
+        the base package once using imp.load_module. Later, we can use
+        standard __import__ call to load plugins in this package.
+
+        Since each wiki has unique plugins, we load the plugin package
+        under the wiki configuration module, named self.siteid.
+        """
+        import sys, imp
+
+        name = self.siteid + '.plugin'
+        try:
+            # Lock other threads while we check and import
+            imp.acquire_lock()
+            try:
+                # If the module is not loaded, try to load it
+                if not name in sys.modules:
+                    # Find module on disk and try to load - slow!
+                    plugin_parent_dir = os.path.abspath(os.path.join(self.plugin_dir, '..'))
+                    fp, path, info = imp.find_module('plugin', [plugin_parent_dir])
+                    try:
+                        # Load the module and set in sys.modules             
+                        module = imp.load_module(name, fp, path, info)
+                        sys.modules[self.siteid].plugin = module
+                    finally:
+                        # Make sure fp is closed properly
+                        if fp:
+                            fp.close()
+            finally:
+                imp.release_lock()
+        except ImportError, err:
+            msg = '''
+Could not import plugin package "%(path)s/plugin" because of ImportError:
+%(err)s.
+
+Make sure your data directory path is correct, check permissions, and
+that the data/plugin directory has an __init__.py file.
+''' % {
+    'path': self.data_dir,
+    'err': str(err),
+}
+            raise error.ConfigurationError(msg)
+
+    def _fillDicts(self):
+        """ fill config dicts
+
+        Fills in missing dict keys of derived user config by copying
+        them from this base class.
+        """
+        # user checkbox defaults
+        for key, value in DefaultConfig.user_checkbox_defaults.items():
+            if not self.user_checkbox_defaults.has_key(key):
+                self.user_checkbox_defaults[key] = value
+
+    def __getitem__(self, item):
+        """ Make it possible to access a config object like a dict """
+        return getattr(self, item)
+
+# remove the gettext pseudo function 
+del _
+
--- a/MoinMoin/multiconfig.py	Mon Jul 24 01:19:18 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,717 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Multiple configuration handler and Configuration defaults class
-
-    @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
-                2005-2006 by MoinMoin:ThomasWaldmann.
-    @license: GNU GPL, see COPYING for details.
-"""
-
-import re, os, sys
-from MoinMoin import error
-import MoinMoin.auth as authmodule
-
-_url_re_cache = None
-_farmconfig_mtime = None
-_config_cache = {}
-
-
-def _importConfigModule(name):
-    """ Import and return configuration module and its modification time
-    
-    Handle all errors except ImportError, because missing file is not
-    always an error.
-    
-    @param name: module name
-    @rtype: tuple
-    @return: module, modification time
-    """
-    try:
-        module = __import__(name, globals(), {})
-        mtime = os.path.getmtime(module.__file__)
-    except ImportError:
-        raise
-    except IndentationError, err:
-        msg = '''IndentationError: %(err)s
-
-The configuration files are python modules. Therefore, whitespace is
-important. Make sure that you use only spaces, no tabs are allowed here!
-You have to use four spaces at the beginning of the line mostly.
-''' % {
-    'err': err,
-}
-        raise error.ConfigurationError(msg)
-    except Exception, err:
-        msg = '%s: %s' % (err.__class__.__name__, str(err))
-        raise error.ConfigurationError(msg)
-    return module, mtime
-
-
-def _url_re_list():
-    """ Return url matching regular expression
-
-    Import wikis list from farmconfig on the first call and compile the
-    regexes. Later then return the cached regex list.
-
-    @rtype: list of tuples of (name, compiled re object)
-    @return: url to wiki config name matching list
-    """
-    global _url_re_cache, _farmconfig_mtime
-    if _url_re_cache is None:
-        try:
-            farmconfig, _farmconfig_mtime = _importConfigModule('farmconfig')
-        except ImportError:
-            # Default to wikiconfig for all urls.
-            _farmconfig_mtime = 0
-            _url_re_cache = [('wikiconfig', re.compile(r'.')), ] # matches everything
-        else:
-            try:
-                cache = []
-                for name, regex in farmconfig.wikis:
-                    cache.append((name, re.compile(regex)))
-                _url_re_cache = cache
-            except AttributeError:
-                msg = """
-Missing required 'wikis' list in 'farmconfig.py'.
-
-If you run a single wiki you do not need farmconfig.py. Delete it and
-use wikiconfig.py.
-"""
-                raise error.ConfigurationError(msg)
-    return _url_re_cache
-
-
-def _makeConfig(name):
-    """ Create and return a config instance 
-
-    Timestamp config with either module mtime or farmconfig mtime. This
-    mtime can be used later to invalidate older caches.
-
-    @param name: module name
-    @rtype: DefaultConfig sub class instance
-    @return: new configuration instance
-    """
-    global _farmconfig_mtime
-    try:
-        module, mtime = _importConfigModule(name)
-        configClass = getattr(module, 'Config')
-        cfg = configClass(name)
-        cfg.cfg_mtime = max(mtime, _farmconfig_mtime)
-    except ImportError, err:
-        msg = '''ImportError: %(err)s
-
-Check that the file is in the same directory as the server script. If
-it is not, you must add the path of the directory where the file is
-located to the python path in the server script. See the comments at
-the top of the server script.
-
-Check that the configuration file name is either "wikiconfig.py" or the
-module name specified in the wikis list in farmconfig.py. Note that the
-module name does not include the ".py" suffix.
-''' % {
-    'err': err,
-}
-        raise error.ConfigurationError(msg)
-    except AttributeError, err:
-        msg = '''AttributeError: %(err)s
-
-Could not find required "Config" class in "%(name)s.py".
-
-This might happen if you are trying to use a pre 1.3 configuration file, or
-made a syntax or spelling error.
-
-Another reason for this could be a name clash. It is not possible to have
-config names like e.g. stats.py - because that colides with MoinMoin/stats/ -
-have a look into your MoinMoin code directory what other names are NOT
-possible.
-
-Please check your configuration file. As an example for correct syntax,
-use the wikiconfig.py file from the distribution.
-''' % {
-    'name': name,
-    'err': err,
-}
-        raise error.ConfigurationError(msg)
-    return cfg
-
-
-def _getConfigName(url):
-    """ Return config name for url or raise """
-    for name, regex in _url_re_list():
-        match = regex.match(url)
-        if match:
-            return name
-    # nothing matched
-    msg = '''
-Could not find a match for url: "%(url)s".
-
-Check your URL regular expressions in the "wikis" list in
-"farmconfig.py". 
-''' % {
-    'url': url,
-}
-    raise error.ConfigurationError(msg)
-
-
-def getConfig(url):
-    """ Return cached config instance for url or create new one
-
-    If called by many threads in the same time multiple config
-    instances might be created. The first created item will be
-    returned, using dict.setdefault.
-
-    @param url: the url from request, possibly matching specific wiki
-    @rtype: DefaultConfig subclass instance
-    @return: config object for specific wiki
-    """
-    configName = _getConfigName(url)
-    try:
-        config = _config_cache[configName]
-    except KeyError:
-        config = _makeConfig(configName)
-        config = _config_cache.setdefault(configName, config)
-    return config
-
-
-# This is a way to mark some text for the gettext tools so that they don't
-# get orphaned. See http://www.python.org/doc/current/lib/node278.html.
-def _(text): return text
-
-
-class DefaultConfig:
-    """ default config values """
-
-    # All acl_rights_* lines must use unicode!
-    acl_rights_default = u"Trusted:read,write,delete,revert Known:read,write,delete,revert All:read,write"
-    acl_rights_before = u""
-    acl_rights_after = u""
-    acl_rights_valid = ['read', 'write', 'delete', 'revert', 'admin']
-
-    actions_excluded = [] # ['DeletePage', 'AttachFile', 'RenamePage', 'test', ]
-    allow_xslt = 0
-    attachments = None # {'dir': path, 'url': url-prefix}
-    auth = [authmodule.moin_login, authmodule.moin_session, ]
-
-    backup_compression = 'gz'
-    backup_users = []
-    backup_include = []
-    backup_exclude = [
-        r"(.+\.py(c|o)$)",
-        r"%(cache_dir)s",
-        r"%(/)spages%(/)s.+%(/)scache%(/)s[^%(/)s]+$" % {'/': os.sep},
-        r"%(/)s(edit-lock|event-log|\.DS_Store)$" % {'/': os.sep},
-        ]
-    backup_storage_dir = '/tmp'
-    backup_restore_target_dir = '/tmp'
-
-    bang_meta = 1
-    caching_formats = ['text_html']
-    changed_time_fmt = '%H:%M'
-
-    # chars_{upper,lower,digits,spaces} see MoinMoin/util/chartypes.py
-
-    # if you have gdchart, add something like
-    # chart_options = {'width = 720, 'height': 540}
-    chart_options = None
-
-    config_check_enabled = 0
-
-    cookie_domain = None # use '.domain.tld" for a farm with hosts in that domain
-    cookie_path = None   # use '/wikifarm" for a farm with pathes below that path
-    cookie_lifetime = 12 # 12 hours from now
-    cookie_secret = '1234' # secret value for crypting session cookie - you should change this :)
-
-    data_dir = './data/'
-    data_underlay_dir = './underlay/'
-
-    date_fmt = '%Y-%m-%d'
-    datetime_fmt = '%Y-%m-%d %H:%M:%S'
-
-    default_markup = 'wiki'
-    docbook_html_dir = r"/usr/share/xml/docbook/stylesheet/nwalsh/html/" # correct for debian sarge
-
-    editor_default = 'text' # which editor is called when nothing is specified
-    editor_ui = 'freechoice' # which editor links are shown on user interface
-    editor_force = False
-    editor_quickhelp = {# editor markup hints quickhelp 
-        'wiki': _("""\
- Emphasis:: [[Verbatim('')]]''italics''[[Verbatim('')]]; [[Verbatim(''')]]'''bold'''[[Verbatim(''')]]; [[Verbatim(''''')]]'''''bold italics'''''[[Verbatim(''''')]]; [[Verbatim('')]]''mixed ''[[Verbatim(''')]]'''''bold'''[[Verbatim(''')]] and italics''[[Verbatim('')]]; [[Verbatim(----)]] horizontal rule.
- Headings:: [[Verbatim(=)]] Title 1 [[Verbatim(=)]]; [[Verbatim(==)]] Title 2 [[Verbatim(==)]]; [[Verbatim(===)]] Title 3 [[Verbatim(===)]];   [[Verbatim(====)]] Title 4 [[Verbatim(====)]]; [[Verbatim(=====)]] Title 5 [[Verbatim(=====)]].
- Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
- Links:: [[Verbatim(JoinCapitalizedWords)]]; [[Verbatim(["brackets and double quotes"])]]; url; [url]; [url label].
- Tables:: || cell text |||| cell text spanning 2 columns ||;    no trailing white space allowed after tables or titles.
-
-(!) For more help, see HelpOnEditing or SyntaxReference.
-"""),
-        'rst': _("""\
-Emphasis: <i>*italic*</i> <b>**bold**</b> ``monospace``<br/>
-<br/><pre>
-Headings: Heading 1  Heading 2  Heading 3
-          =========  ---------  ~~~~~~~~~
-
-Horizontal rule: ---- 
-Links: TrailingUnderscore_ `multi word with backticks`_ external_ 
-
-.. _external: http://external-site.net/foo/
-
-Lists: * bullets; 1., a. numbered items.
-</pre>
-<br/>
-(!) For more help, see the 
-<a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">
-reStructuredText Quick Reference
-</a>.
-"""),
-    }
-    edit_locking = 'warn 10' # None, 'warn <timeout mins>', 'lock <timeout mins>'
-    edit_rows = 20
-
-    hacks = {} # { 'feature1': value1, ... }
-               # Configuration for features still in development.
-               # For boolean stuff just use config like this:
-               #   hacks = { 'feature': True, ...}
-               # and in the code use:
-               #   if cfg.hacks.get('feature', False): <doit>
-               # A non-existing hack key should ever mean False, None, "", [] or {}!
-
-    hosts_deny = []
-
-    html_head = ''
-    html_head_queries = '''<meta name="robots" content="noindex,nofollow">\n'''
-    html_head_posts   = '''<meta name="robots" content="noindex,nofollow">\n'''
-    html_head_index   = '''<meta name="robots" content="index,follow">\n'''
-    html_head_normal  = '''<meta name="robots" content="index,nofollow">\n'''
-    html_pagetitle = None
-
-    interwiki_preferred = [] # list of wiki names to show at top of interwiki list
-
-    language_default = 'en'
-    language_ignore_browser = False # ignore browser settings, use language_default
-                                    # or user prefs
-
-    log_reverse_dns_lookups = True  # if we do reverse dns lookups for logging hostnames
-                                    # instead of just IPs
-
-    xapian_search = False # disabled until xapian is finished
-    xapian_index_dir = None
-    xapian_stemming = True
-    search_results_per_page = 10
-
-    mail_login = None # or "user pwd" if you need to use SMTP AUTH
-    mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
-    mail_smarthost = None
-    mail_from = None # u'Juergen Wiki <noreply@jhwiki.org>'
-
-    mail_import_subpage_template = u"$from-$date-$subject" # used for mail import
-    mail_import_wiki_address = None # the e-mail address for e-mails that should go into the wiki
-    mail_import_secret = ""
-
-    navi_bar = [u'RecentChanges', u'FindPage', u'HelpContents', ]
-    nonexist_qm = 0
-
-    page_credits = [
-        '<a href="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a>',
-        '<a href="http://www.python.org/">Python Powered</a>',
-        '<a href="http://validator.w3.org/check?uri=referer">Valid HTML 4.01</a>',
-        ]
-    page_footer1 = ''
-    page_footer2 = ''
-
-    page_header1 = ''
-    page_header2 = ''
-
-    page_front_page = u'HelpOnLanguages' # this will make people choose a sane config
-    page_local_spelling_words = u'LocalSpellingWords'
-    page_category_regex = u'^Category[A-Z]'
-    page_dict_regex = u'[a-z0-9]Dict$'
-    page_group_regex = u'[a-z0-9]Group$'
-    page_template_regex = u'[a-z0-9]Template$'
-
-    page_license_enabled = 0
-    page_license_page = u'WikiLicense'
-
-    # These icons will show in this order in the iconbar, unless they
-    # are not relevant, e.g email icon when the wiki is not configured
-    # for email.
-    page_iconbar = ["up", "edit", "view", "diff", "info", "subscribe", "raw", "print", ]
-
-    # Standard buttons in the iconbar
-    page_icons_table = {
-        # key           last part of url, title, icon-key
-        'help':        ("%(q_page_help_contents)s", "%(page_help_contents)s", "help"),
-        'find':        ("%(q_page_find_page)s?value=%(q_page_name)s", "%(page_find_page)s", "find"),
-        'diff':        ("%(q_page_name)s?action=diff", _("Diffs"), "diff"),
-        'info':        ("%(q_page_name)s?action=info", _("Info"), "info"),
-        'edit':        ("%(q_page_name)s?action=edit", _("Edit"), "edit"),
-        'unsubscribe': ("%(q_page_name)s?action=subscribe", _("UnSubscribe"), "unsubscribe"),
-        'subscribe':   ("%(q_page_name)s?action=subscribe", _("Subscribe"), "subscribe"),
-        'raw':         ("%(q_page_name)s?action=raw", _("Raw"), "raw"),
-        'xml':         ("%(q_page_name)s?action=show&amp;mimetype=text/xml", _("XML"), "xml"),
-        'print':       ("%(q_page_name)s?action=print", _("Print"), "print"),
-        'view':        ("%(q_page_name)s", _("View"), "view"),
-        'up':          ("%(q_page_parent_page)s", _("Up"), "up"),
-        }
-
-    refresh = None # (minimum_delay, type), e.g.: (2, 'internal')
-    rss_cache = 60 # suggested caching time for RecentChanges RSS, in seconds
-    shared_intermap = None # can be string or list of strings (filenames)
-    show_hosts = 1
-    show_interwiki = 0
-    show_login = 1
-    show_names = True
-    show_section_numbers = 0
-    show_timings = 0
-    show_version = 0
-    siteid = 'default'
-    stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
-    superuser = [] # list of unicode user names that have super powers :)
-
-    surge_action_limits = {# allow max. <count> <action> requests per <dt> secs
-        # action: (count, dt)
-        'all': (30, 30),
-        'show': (30, 60),
-        'recall': (5, 60),
-        'raw': (20, 40),  # some people use this for css
-        'AttachFile': (90, 60),
-        'diff': (30, 60),
-        'fullsearch': (5, 60),
-        'edit': (10, 120),
-        'rss_rc': (1, 60),
-        'default': (30, 60),
-    }
-    surge_lockout_time = 3600 # secs you get locked out when you ignore warnings
-
-    theme_default = 'modern'
-    theme_force = False
-
-    trail_size = 5
-    tz_offset = 0.0 # default time zone offset in hours from UTC
-
-    user_autocreate = False # do we auto-create user profiles
-    user_email_unique = True # do we check whether a user's email is unique?
-
-    # a regex of HTTP_USER_AGENTS that should be excluded from logging
-    # and receive a FORBIDDEN for anything except viewing a page
-    ua_spiders = ('archiver|cfetch|crawler|curl|gigabot|googlebot|holmes|htdig|httrack|httpunit|jeeves|larbin|leech|'
-                  'linkbot|linkmap|linkwalk|mercator|mirror|msnbot|nutbot|omniexplorer|puf|robot|scooter|'
-                  'sherlock|slurp|sitecheck|spider|teleport|voyager|webreaper|wget')
-
-    # Wiki identity
-    sitename = u'Untitled Wiki'
-    url_prefix = '/wiki'
-    logo_string = None
-    interwikiname = None
-
-    url_mappings = {}
-
-    user_checkbox_fields = [
-        ('mailto_author', lambda _: _('Publish my email (not my wiki homepage) in author info')),
-        ('edit_on_doubleclick', lambda _: _('Open editor on double click')),
-        ('remember_last_visit', lambda _: _('After login, jump to last visited page')),
-        ('show_nonexist_qm', lambda _: _('Show question mark for non-existing pagelinks')),
-        ('show_page_trail', lambda _: _('Show page trail')),
-        ('show_toolbar', lambda _: _('Show icon toolbar')),
-        ('show_topbottom', lambda _: _('Show top/bottom links in headings')),
-        ('show_fancy_diff', lambda _: _('Show fancy diffs')),
-        ('wikiname_add_spaces', lambda _: _('Add spaces to displayed wiki names')),
-        ('remember_me', lambda _: _('Remember login information')),
-        ('want_trivial', lambda _: _('Subscribe to trivial changes')),
-
-        ('disabled', lambda _: _('Disable this account forever')),
-        # if an account is disabled, it may be used for looking up
-        # id -> username for page info and recent changes, but it
-        # is not usable for the user any more:
-    ]
-
-    user_checkbox_defaults = {'mailto_author':       0,
-                              'edit_on_doubleclick': 0,
-                              'remember_last_visit': 0,
-                              'show_nonexist_qm':    nonexist_qm,
-                              'show_page_trail':     1,
-                              'show_toolbar':        1,
-                              'show_topbottom':      0,
-                              'show_fancy_diff':     1,
-                              'wikiname_add_spaces': 0,
-                              'remember_me':         1,
-                              'want_trivial':        0,
-                             }
-
-    # don't let the user change those
-    # user_checkbox_disable = ['disabled', 'want_trivial']
-    user_checkbox_disable = []
-
-    # remove those checkboxes:
-    #user_checkbox_remove = ['edit_on_doubleclick', 'show_nonexist_qm', 'show_toolbar', 'show_topbottom',
-    #                        'show_fancy_diff', 'wikiname_add_spaces', 'remember_me', 'disabled',]
-    user_checkbox_remove = []
-
-    user_form_fields = [
-        ('name', _('Name'), "text", "36", _("(Use Firstname''''''Lastname)")),
-        ('aliasname', _('Alias-Name'), "text", "36", ''),
-        ('password', _('Password'), "password", "36", ''),
-        ('password2', _('Password repeat'), "password", "36", _('(Only for password change or new account)')),
-        ('email', _('Email'), "text", "36", ''),
-        ('css_url', _('User CSS URL'), "text", "40", _('(Leave it empty for disabling user CSS)')),
-        ('edit_rows', _('Editor size'), "text", "3", ''),
-    ]
-
-    user_form_defaults = {# key: default - do NOT remove keys from here!
-        'name': '',
-        'aliasname': '',
-        'password': '',
-        'password2': '',
-        'email': '',
-        'css_url': '',
-        'edit_rows': "20",
-    }
-
-    # don't let the user change those, but show them:
-    #user_form_disable = ['name', 'aliasname', 'email',]
-    user_form_disable = []
-
-    # remove those completely:
-    #user_form_remove = ['password', 'password2', 'css_url', 'logout', 'create', 'account_sendmail',]
-    user_form_remove = []
-
-    # attributes we do NOT save to the userpref file
-    user_transient_fields = ['id', 'valid', 'may', 'auth_username', 'trusted', 'password', 'password2', 'auth_method', 'auth_attribs', ]
-
-    user_homewiki = 'Self' # interwiki name for where user homepages are located
-
-    unzip_single_file_size = 2.0 * 1000**2
-    unzip_attachments_space = 200.0 * 1000**2
-    unzip_attachments_count = 51 # 1 zip file + 50 files contained in it
-
-    xmlrpc_putpage_enabled = 0 # if 0, putpage will write to a test page only
-    xmlrpc_putpage_trusted_only = 1 # if 1, you will need to be http auth authenticated
-
-    SecurityPolicy = None
-
-    def __init__(self, siteid):
-        """ Init Config instance """
-        self.siteid = siteid
-        if self.config_check_enabled:
-            self._config_check()
-
-        # define directories
-        self.moinmoin_dir = os.path.abspath(os.path.dirname(__file__))
-        data_dir = os.path.normpath(self.data_dir)
-        self.data_dir = data_dir
-        for dirname in ('user', 'cache', 'plugin'):
-            name = dirname + '_dir'
-            if not getattr(self, name, None):
-                setattr(self, name, os.path.join(data_dir, dirname))
-
-        # Try to decode certain names which allow unicode
-        self._decode()
-
-        self._check_directories()
-
-        if not isinstance(self.superuser, list):
-            msg = """The superuser setting in your wiki configuration is not a list
-                     (e.g. ['Sample User', 'AnotherUser']).
-                     Please change it in your wiki configuration and try again."""
-            raise error.ConfigurationError(msg)
-
-        self._loadPluginModule()
-
-        # Preparse user dicts
-        self._fillDicts()
-
-        # Normalize values
-        self.language_default = self.language_default.lower()
-
-        # Use site name as default name-logo
-        if self.logo_string is None:
-            self.logo_string = self.sitename
-
-        # Check for needed modules
-
-        # FIXME: maybe we should do this check later, just before a
-        # chart is needed, maybe in the chart module, instead doing it
-        # for each request. But this require a large refactoring of
-        # current code.
-        if self.chart_options:
-            try:
-                import gdchart
-            except ImportError:
-                self.chart_options = None
-
-        # post process
-        # we replace any string placeholders with config values
-        # e.g u'%(page_front_page)s' % self
-        self.navi_bar = [elem % self for elem in self.navi_bar]
-        self.backup_exclude = [elem % self for elem in self.backup_exclude]
-
-        # list to cache xapian searcher objects
-        self.xapian_searchers = []
-
-        # check if mail is possible and set flag:
-        self.mail_enabled = (self.mail_smarthost is not None or self.mail_sendmail is not None) and self.mail_from
-
-    def _config_check(self):
-        """ Check namespace and warn about unknown names
-        
-        Warn about names which are not used by DefaultConfig, except
-        modules, classes, _private or __magic__ names.
-
-        This check is disabled by default, when enabled, it will show an
-        error message with unknown names.
-        """
-        unknown = ['"%s"' % name for name in dir(self)
-                  if not name.startswith('_') and
-                  not DefaultConfig.__dict__.has_key(name) and
-                  not isinstance(getattr(self, name), (type(sys), type(DefaultConfig)))]
-        if unknown:
-            msg = """
-Unknown configuration options: %s.
-
-For more information, visit HelpOnConfiguration. Please check your
-configuration for typos before requesting support or reporting a bug.
-""" % ', '.join(unknown)
-            raise error.ConfigurationError(msg)
-
-    def _decode(self):
-        """ Try to decode certain names, ignore unicode values
-        
-        Try to decode str using utf-8. If the decode fail, raise FatalError. 
-
-        Certain config variables should contain unicode values, and
-        should be defined with u'text' syntax. Python decode these if
-        the file have a 'coding' line.
-        
-        This will allow utf-8 users to use simple strings using, without
-        using u'string'. Other users will have to use u'string' for
-        these names, because we don't know what is the charset of the
-        config files.
-        """
-        charset = 'utf-8'
-        message = u'''
-"%(name)s" configuration variable is a string, but should be
-unicode. Use %(name)s = u"value" syntax for unicode variables.
-
-Also check your "-*- coding -*-" line at the top of your configuration
-file. It should match the actual charset of the configuration file.
-'''
-
-        decode_names = (
-            'sitename', 'logo_string', 'navi_bar', 'page_front_page',
-            'page_category_regex', 'page_dict_regex',
-            'page_group_regex', 'page_template_regex', 'page_license_page',
-            'page_local_spelling_words', 'acl_rights_default',
-            'acl_rights_before', 'acl_rights_after', 'mail_from'
-            )
-
-        for name in decode_names:
-            attr = getattr(self, name, None)
-            if attr:
-                # Try to decode strings
-                if isinstance(attr, str):
-                    try:
-                        setattr(self, name, unicode(attr, charset))
-                    except UnicodeError:
-                        raise error.ConfigurationError(message %
-                                                       {'name': name})
-                # Look into lists and try to decode strings inside them
-                elif isinstance(attr, list):
-                    for i in xrange(len(attr)):
-                        item = attr[i]
-                        if isinstance(item, str):
-                            try:
-                                attr[i] = unicode(item, charset)
-                            except UnicodeError:
-                                raise error.ConfigurationError(message %
-                                                               {'name': name})
-
-    def _check_directories(self):
-        """ Make sure directories are accessible
-
-        Both data and underlay should exists and allow read, write and
-        execute.
-        """
-        mode = os.F_OK | os.R_OK | os.W_OK | os.X_OK
-        for attr in ('data_dir', 'data_underlay_dir'):
-            path = getattr(self, attr)
-
-            # allow an empty underlay path or None
-            if attr == 'data_underlay_dir' and not path:
-                continue
-
-            path_pages = os.path.join(path, "pages")
-            if not (os.path.isdir(path_pages) and os.access(path_pages, mode)):
-                msg = '''
-%(attr)s "%(path)s" does not exists, or has incorrect ownership or
-permissions.
-
-Make sure the directory and the subdirectory pages are owned by the web
-server and are readable, writable and executable by the web server user
-and group.
-
-It is recommended to use absolute paths and not relative paths. Check
-also the spelling of the directory name.
-''' % {'attr': attr, 'path': path, }
-                raise error.ConfigurationError(msg)
-
-    def _loadPluginModule(self):
-        """ import plugin module under configname.plugin
-
-        To be able to import plugin from arbitrary path, we have to load
-        the base package once using imp.load_module. Later, we can use
-        standard __import__ call to load plugins in this package.
-
-        Since each wiki has unique plugins, we load the plugin package
-        under the wiki configuration module, named self.siteid.
-        """
-        import sys, imp
-
-        name = self.siteid + '.plugin'
-        try:
-            # Lock other threads while we check and import
-            imp.acquire_lock()
-            try:
-                # If the module is not loaded, try to load it
-                if not name in sys.modules:
-                    # Find module on disk and try to load - slow!
-                    plugin_parent_dir = os.path.abspath(os.path.join(self.plugin_dir, '..'))
-                    fp, path, info = imp.find_module('plugin', [plugin_parent_dir])
-                    try:
-                        # Load the module and set in sys.modules             
-                        module = imp.load_module(name, fp, path, info)
-                        sys.modules[self.siteid].plugin = module
-                    finally:
-                        # Make sure fp is closed properly
-                        if fp:
-                            fp.close()
-            finally:
-                imp.release_lock()
-        except ImportError, err:
-            msg = '''
-Could not import plugin package "%(path)s/plugin" because of ImportError:
-%(err)s.
-
-Make sure your data directory path is correct, check permissions, and
-that the data/plugin directory has an __init__.py file.
-''' % {
-    'path': self.data_dir,
-    'err': str(err),
-}
-            raise error.ConfigurationError(msg)
-
-    def _fillDicts(self):
-        """ fill config dicts
-
-        Fills in missing dict keys of derived user config by copying
-        them from this base class.
-        """
-        # user checkbox defaults
-        for key, value in DefaultConfig.user_checkbox_defaults.items():
-            if not self.user_checkbox_defaults.has_key(key):
-                self.user_checkbox_defaults[key] = value
-
-    def __getitem__(self, item):
-        """ Make it possible to access a config object like a dict """
-        return getattr(self, item)
-
-# remove the gettext pseudo function 
-del _
-
--- a/MoinMoin/request/CGI.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/CGI.py	Mon Jul 24 11:52:07 2006 +0200
@@ -7,7 +7,7 @@
                 2003-2006 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
-import sys, os
+import sys, os, cgi
 
 from MoinMoin import config
 from MoinMoin.request import RequestBase
@@ -29,6 +29,11 @@
         except Exception, err:
             self.fail(err)
 
+    def _setup_args_from_cgi_form(self):
+        """ Override to create cgi form """
+        form = cgi.FieldStorage()
+        return RequestBase._setup_args_from_cgi_form(self, form)
+
     def open_logs(self):
         # create log file for catching stderr output
         if not self.opened_logs:
--- a/MoinMoin/request/CLI.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/CLI.py	Mon Jul 24 11:52:07 2006 +0200
@@ -30,6 +30,12 @@
         self.cfg.caching_formats = [] # don't spoil the cache
         self.initTheme() # usually request.run() does this, but we don't use it
 
+    def _setup_args_from_cgi_form(self):
+        """ Override to create cli form """
+        #form = cgi.FieldStorage()
+        #return RequestBase._setup_args_from_cgi_form(self, form)
+        return {}
+
     def read(self, n=None):
         """ Read from input stream. """
         if n is None:
--- a/MoinMoin/request/FCGI.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/FCGI.py	Mon Jul 24 11:52:07 2006 +0200
@@ -32,11 +32,9 @@
         except Exception, err:
             self.fail(err)
 
-    def _setup_args_from_cgi_form(self, form=None):
+    def _setup_args_from_cgi_form(self):
         """ Override to use FastCGI form """
-        if form is None:
-            form = self.fcgform
-        return RequestBase._setup_args_from_cgi_form(self, form)
+        return RequestBase._setup_args_from_cgi_form(self, self.fcgform)
 
     def read(self, n=None):
         """ Read from input stream. """
--- a/MoinMoin/request/MODPYTHON.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/MODPYTHON.py	Mon Jul 24 11:52:07 2006 +0200
@@ -76,15 +76,14 @@
 
         RequestBase.fixURI(self, env)
 
-    def _setup_args_from_cgi_form(self, form=None):
+    def _setup_args_from_cgi_form(self):
         """ Override to use mod_python.util.FieldStorage 
         
-        Its little different from cgi.FieldStorage, so we need to
+        It's little different from cgi.FieldStorage, so we need to
         duplicate the conversion code.
         """
         from mod_python import util
-        if form is None:
-            form = util.FieldStorage(self.mpyreq)
+        form = util.FieldStorage(self.mpyreq)
 
         args = {}
         for key in form.keys():
--- a/MoinMoin/request/STANDALONE.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/STANDALONE.py	Mon Jul 24 11:52:07 2006 +0200
@@ -54,7 +54,7 @@
         except Exception, err:
             self.fail(err)
 
-    def _setup_args_from_cgi_form(self, form=None):
+    def _setup_args_from_cgi_form(self):
         """ Override to create standalone form """
         form = cgi.FieldStorage(self.rfile, headers=self.headers, environ={'REQUEST_METHOD': 'POST'})
         return RequestBase._setup_args_from_cgi_form(self, form)
--- a/MoinMoin/request/TWISTED.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/TWISTED.py	Mon Jul 24 11:52:07 2006 +0200
@@ -64,7 +64,7 @@
             return self.finish()
         RequestBase.run(self)
 
-    def setup_args(self, form=None):
+    def setup_args(self):
         """ Return args dict 
         
         Twisted already parsed args, including __filename__ hacking,
--- a/MoinMoin/request/WSGI.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/WSGI.py	Mon Jul 24 11:52:07 2006 +0200
@@ -6,7 +6,7 @@
                 2003-2006 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
-import sys, os
+import sys, os, cgi
 
 from MoinMoin import config
 from MoinMoin.request import RequestBase
@@ -30,12 +30,11 @@
         except Exception, err:
             self.fail(err)
 
-    def setup_args(self, form=None):
+    def setup_args(self):
         # TODO: does this include query_string args for POST requests?
         # see also how CGI works now
-        if form is None:
-            form = cgi.FieldStorage(fp=self.stdin, environ=self.env, keep_blank_values=1)
-        return self._setup_args_from_cgi_form(form)
+        form = cgi.FieldStorage(fp=self.stdin, environ=self.env, keep_blank_values=1)
+        return RequestBase._setup_args_from_cgi_form(self, form)
 
     def read(self, n=None):
         if n is None:
--- a/MoinMoin/request/__init__.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/request/__init__.py	Mon Jul 24 11:52:07 2006 +0200
@@ -265,7 +265,7 @@
     def _load_multi_cfg(self):
         # protect against calling multiple times
         if not hasattr(self, 'cfg'):
-            from MoinMoin import multiconfig
+            from MoinMoin.config import multiconfig
             self.cfg = multiconfig.getConfig(self.url)
 
     def setAcceptedCharsets(self, accept_charset):
@@ -546,7 +546,6 @@
         # during the rendering of a page by lang macros
         self.current_lang = self.cfg.language_default
 
-        self._all_pages = None
         # caches unique ids
         self._page_ids = {}
         # keeps track of pagename/heading combinations
@@ -887,40 +886,33 @@
                     break
         return forbidden
 
-    def setup_args(self, form=None):
+    def setup_args(self):
         """ Return args dict 
         First, we parse the query string (usually this is used in GET methods,
         but TwikiDraw uses ?action=AttachFile&do=savedrawing plus posted stuff).
         Second, we update what we got in first step by the stuff we get from
         the form (or by a POST). We invoke _setup_args_from_cgi_form to handle
         possible file uploads.
-        
-        Warning: calling with a form might fail, depending on the type of the
-        request! Only the request knows which kind of form it can handle.
-        
-        TODO: The form argument should be removed in 1.5.
         """
         args = cgi.parse_qs(self.query_string, keep_blank_values=1)
         args = self.decodeArgs(args)
-        # if we have form data (e.g. in a POST), those override the stuff we already have:
-        if form is not None or self.request_method == 'POST':
-            postargs = self._setup_args_from_cgi_form(form)
+        # if we have form data (in a POST), those override the stuff we already have:
+        if self.request_method == 'POST':
+            postargs = self._setup_args_from_cgi_form()
             args.update(postargs)
         return args
 
     def _setup_args_from_cgi_form(self, form=None):
         """ Return args dict from a FieldStorage
-        
-        Create the args from a standard cgi.FieldStorage or from given form.
-        Each key contain a list of values.
+
+        Create the args from a given form. Each key contain a list of values.
+        This method usually gets overridden in classes derived from this - it
+        is their task to call this method with an appropriate form parameter.
 
         @param form: a cgi.FieldStorage
         @rtype: dict
         @return: dict with form keys, each contains a list of values
         """
-        if form is None:
-            form = cgi.FieldStorage()
-
         args = {}
         for key in form:
             values = form[key]
@@ -1098,18 +1090,21 @@
                 else:
                     self.page = Page(self, pagename)
 
+                msg = None
                 # Complain about unknown actions
                 if not action_name in self.getKnownActions():
-                    self.http_headers()
-                    self.write(u'<html><body><h1>Unknown action %s</h1></body>' % wikiutil.escape(action_name))
+                    msg = _("Unknown action %(action_name)s.") % {
+                            'action_name': wikiutil.escape(action_name), }
 
                 # Disallow non available actions
                 elif action_name[0].isupper() and not action_name in self.getAvailableActions(self.page):
-                    # Send page with error
-                    msg = _("You are not allowed to do %s on this page.") % wikiutil.escape(action_name)
+                    msg = _("You are not allowed to do %(action_name)s on this page.") % {
+                            'action_name': wikiutil.escape(action_name), }
                     if not self.user.valid:
                         # Suggest non valid user to login
                         msg += " " + _("Login and try again.", formatted=0)
+
+                if msg:
                     self.page.send_page(self, msg=msg)
 
                 # Try action
--- a/MoinMoin/stats/hitcounts.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/stats/hitcounts.py	Mon Jul 24 11:52:07 2006 +0200
@@ -47,16 +47,17 @@
 
 
 def get_data(pagename, request, filterpage=None):
+    cache_days, cache_views, cache_edits = [], [], []
+    cache_date = 0
 
     # Get results from cache
     if filterpage:
         arena = Page(request, pagename)
+        cache = caching.CacheEntry(request, arena, 'hitcounts', scope='item')
     else:
         arena = 'charts'
+        cache = caching.CacheEntry(request, arena, 'hitcounts', scope='wiki')
 
-    cache_days, cache_views, cache_edits = [], [], []
-    cache_date = 0
-    cache = caching.CacheEntry(request, arena, 'hitcounts', scope='wiki')
     if cache.exists():
         try:
             cache_date, cache_days, cache_views, cache_edits = eval(cache.content())
--- a/MoinMoin/theme/__init__.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/theme/__init__.py	Mon Jul 24 11:52:07 2006 +0200
@@ -196,13 +196,13 @@
         @rtype: string
         @return: interwiki html
         """
-        html = u''
         if self.request.cfg.show_interwiki:
-            # Show our interwikiname or Self (and link to page_front_page)
-            pagename = wikiutil.getFrontPage(self.request).page_name
-            pagename = wikiutil.quoteWikinameURL(pagename)
-            link = wikiutil.link_tag(self.request, pagename, self.request.cfg.interwikiname or 'Self')
+            page = wikiutil.getFrontPage(self.request)
+            text = self.request.cfg.interwikiname or 'Self'
+            link = page.link_to(self.request, text=text, rel='nofollow')
             html = u'<div id="interwiki"><span>%s</span></div>' % link
+        else:
+            html = u''
         return html
 
     def title(self, d):
@@ -1118,25 +1118,24 @@
             return self.disabledEdit()
 
         _ = self.request.getText
-        params = (wikiutil.quoteWikinameURL(page.page_name) +
-                  '?action=edit&amp;editor=')
+        querystr = {'action': 'edit'}
 
         guiworks = self.guiworks(page)
         if self.showBothEditLinks() and guiworks:
             text = _('Edit (Text)', formatted=False)
-            params = params + 'text'
+            querystr['editor'] = 'text'
             attrs = {'name': 'texteditlink', 'rel': 'nofollow', }
         else:
             text = _('Edit', formatted=False)
             if guiworks:
                 # 'textonly' will be upgraded dynamically to 'guipossible' by JS
-                params = params + 'textonly'
+                querystr['editor'] = 'textonly'
                 attrs = {'name': 'editlink', 'rel': 'nofollow', }
             else:
-                params = params + 'text'
+                querystr['editor'] = 'text'
                 attrs = {'name': 'texteditlink', 'rel': 'nofollow', }
 
-        return wikiutil.link_tag(self.request, params, text, **attrs)
+        return page.link_to(self.request, text=text, querystr=querystr, **attrs)
 
     def showBothEditLinks(self):
         """ Return True if both edit links should be displayed """
@@ -1179,7 +1178,7 @@
         _ = self.request.getText
         return page.link_to(self.request,
                             text=_('Info', formatted=False),
-                            querystr='action=info', rel='nofollow')
+                            querystr={'action': 'info'}, id='info', rel='nofollow')
 
     def subscribeLink(self, page):
         """ Return subscribe/unsubscribe link to valid users
@@ -1195,8 +1194,7 @@
             text = _("Unsubscribe", formatted=False)
         else:
             text = _("Subscribe", formatted=False)
-        params = wikiutil.quoteWikinameURL(page.page_name) + '?action=subscribe'
-        return wikiutil.link_tag(self.request, params, text, self.request.formatter, rel='nofollow')
+        return page.link_to(self.request, text=text, querystr={'action': 'subscribe'}, id='subscribe', rel='nofollow')
 
     def quicklinkLink(self, page):
         """ Return add/remove quicklink link
@@ -1212,15 +1210,14 @@
             text = _("Remove Link", formatted=False)
         else:
             text = _("Add Link", formatted=False)
-        params = wikiutil.quoteWikinameURL(page.page_name) + '?action=quicklink'
-        return wikiutil.link_tag(self.request, params, text, self.request.formatter, rel='nofollow')
+        return page.link_to(self.request, text=text, querystr={'action': 'quicklink'}, id='quicklink', rel='nofollow')
 
     def attachmentsLink(self, page):
         """ Return link to page attachments """
         _ = self.request.getText
         return page.link_to(self.request,
                             text=_('Attachments', formatted=False),
-                            querystr='action=AttachFile', rel='nofollow')
+                            querystr={'action': 'AttachFile'}, id='attachments', rel='nofollow')
 
     def startPage(self):
         """ Start page div with page language and direction
--- a/MoinMoin/theme/classic.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/theme/classic.py	Mon Jul 24 11:52:07 2006 +0200
@@ -8,7 +8,7 @@
     If you want modified behaviour, just override the stuff you
     want to change in the child class.
 
-    @copyright: 2003 by ThomasWaldmann (LinuxWiki:ThomasWaldmann)
+    @copyright: 2003-2006 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -194,13 +194,11 @@
                 title = Page(request, action).split_title(request, force=1)
                 # Use translated version if available
                 title = _(title, formatted=False)
-                params = '%s?action=%s' % (d['q_page_name'], action)
-                link = wikiutil.link_tag(request, params, title, request.formatter, rel='nofollow')
+                link = page.link_to(request, text=title, querystr={'action': action}, rel='nofollow')
                 html.append(link)
 
         title = _("DeleteCache", formatted=False)
-        params = '%s?action=%s' % (d['page_name'], 'refresh')
-        link = wikiutil.link_tag(request, params, title, request.formatter, rel='nofollow')
+        link = page.link_to(request, text=title, querystr={'action': 'refresh'}, rel='nofollow')
 
         cache = caching.CacheEntry(request, page, page.getFormatterName(), scope='item')
         date = request.user.getFormattedDateTime(cache.mtime())
--- a/MoinMoin/util/diff.py	Mon Jul 24 01:19:18 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Side by side diffs
-
-    @copyright: 2002 by Jürgen Hermann <jh@web.de>
-    @copyright: 2002 by Scott Moonen <smoonen@andstuff.org>
-    @license: GNU GPL, see COPYING for details.
-"""
-
-from MoinMoin.support import difflib
-from MoinMoin.wikiutil import escape
-
-def indent(line):
-    eol = ''
-    while line and line[0] == '\n':
-        eol += '\n'
-        line = line[1:]
-    stripped = line.lstrip()
-    if len(line) - len(stripped):
-        line = "&nbsp;" * (len(line) - len(stripped)) + stripped
-    #return "%d / %d / %s" % (len(line), len(stripped), line)
-    return eol + line
-
-
-# This code originally by Scott Moonen, used with permission.
-def diff(request, old, new):
-    """ Find changes between old and new and return
-        HTML markup visualising them.
-    """
-    _ = request.getText
-    t_line = _("Line") + " %d"
-
-    seq1 = old.splitlines()
-    seq2 = new.splitlines()
-
-    seqobj = difflib.SequenceMatcher(None, seq1, seq2)
-    linematch = seqobj.get_matching_blocks()
-
-    if len(seq1) == len(seq2) and linematch[0] == (0, 0, len(seq1)):
-        # No differences.
-        return _("No differences found!")
-
-    lastmatch = (0, 0)
-
-    result = """
-<table class="diff">
-<tr>
-<td class="diff-removed">
-<span>
-%s
-</span>
-</td>
-<td class="diff-added">
-<span>
-%s
-</span>
-</td>
-</tr>
-""" % (_('Deletions are marked like this.'), _('Additions are marked like this.'),)
-
-    # Print all differences
-    for match in linematch:
-        # Starts of pages identical?
-        if lastmatch == match[0:2]:
-            lastmatch = (match[0] + match[2], match[1] + match[2])
-            continue
-        llineno, rlineno = lastmatch[0]+1, lastmatch[1]+1
-        result += """
-<tr class="diff-title">
-<td>
-%s:
-</td>
-<td>
-%s:
-</td>
-</tr>
-""" % (request.formatter.line_anchorlink(1, llineno) + request.formatter.text(t_line % llineno) + request.formatter.line_anchorlink(0),
-       request.formatter.line_anchorlink(1, rlineno) + request.formatter.text(t_line % rlineno) + request.formatter.line_anchorlink(0))
-
-        leftpane = ''
-        rightpane = ''
-        linecount = max(match[0] - lastmatch[0], match[1] - lastmatch[1])
-        for line in range(linecount):
-            if line < match[0] - lastmatch[0]:
-                if line > 0:
-                    leftpane += '\n'
-                leftpane += seq1[lastmatch[0] + line]
-            if line < match[1] - lastmatch[1]:
-                if line > 0:
-                    rightpane += '\n'
-                rightpane += seq2[lastmatch[1] + line]
-
-        charobj = difflib.SequenceMatcher(None, leftpane, rightpane)
-        charmatch = charobj.get_matching_blocks()
-
-        if charobj.ratio() < 0.5:
-            # Insufficient similarity.
-            if leftpane:
-                leftresult = """<span>%s</span>""" % indent(escape(leftpane))
-            else:
-                leftresult = ''
-
-            if rightpane:
-                rightresult = """<span>%s</span>""" % indent(escape(rightpane))
-            else:
-                rightresult = ''
-        else:
-            # Some similarities; markup changes.
-            charlast = (0, 0)
-
-            leftresult = ''
-            rightresult = ''
-            for thismatch in charmatch:
-                if thismatch[0] - charlast[0] != 0:
-                    leftresult += """<span>%s</span>""" % indent(
-                        escape(leftpane[charlast[0]:thismatch[0]]))
-                if thismatch[1] - charlast[1] != 0:
-                    rightresult += """<span>%s</span>""" % indent(
-                        escape(rightpane[charlast[1]:thismatch[1]]))
-                leftresult += escape(leftpane[thismatch[0]:thismatch[0] + thismatch[2]])
-                rightresult += escape(rightpane[thismatch[1]:thismatch[1] + thismatch[2]])
-                charlast = (thismatch[0] + thismatch[2], thismatch[1] + thismatch[2])
-
-        leftpane = '<br>\n'.join(map(indent, leftresult.splitlines()))
-        rightpane = '<br>\n'.join(map(indent, rightresult.splitlines()))
-
-        # removed width="50%%"
-        result += """
-<tr>
-<td class="diff-removed">
-%s
-</td>
-<td class="diff-added">
-%s
-</td>
-</tr>
-""" % (leftpane, rightpane)
-
-        lastmatch = (match[0] + match[2], match[1] + match[2])
-
-    result += '</table>\n'
-    return result
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/util/diff_html.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,143 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Side by side diffs
+
+    @copyright: 2002 by Jürgen Hermann <jh@web.de>
+    @copyright: 2002 by Scott Moonen <smoonen@andstuff.org>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.support import difflib
+from MoinMoin.wikiutil import escape
+
+def indent(line):
+    eol = ''
+    while line and line[0] == '\n':
+        eol += '\n'
+        line = line[1:]
+    stripped = line.lstrip()
+    if len(line) - len(stripped):
+        line = "&nbsp;" * (len(line) - len(stripped)) + stripped
+    #return "%d / %d / %s" % (len(line), len(stripped), line)
+    return eol + line
+
+
+# This code originally by Scott Moonen, used with permission.
+def diff(request, old, new):
+    """ Find changes between old and new and return
+        HTML markup visualising them.
+    """
+    _ = request.getText
+    t_line = _("Line") + " %d"
+
+    seq1 = old.splitlines()
+    seq2 = new.splitlines()
+
+    seqobj = difflib.SequenceMatcher(None, seq1, seq2)
+    linematch = seqobj.get_matching_blocks()
+
+    if len(seq1) == len(seq2) and linematch[0] == (0, 0, len(seq1)):
+        # No differences.
+        return _("No differences found!")
+
+    lastmatch = (0, 0)
+
+    result = """
+<table class="diff">
+<tr>
+<td class="diff-removed">
+<span>
+%s
+</span>
+</td>
+<td class="diff-added">
+<span>
+%s
+</span>
+</td>
+</tr>
+""" % (_('Deletions are marked like this.'), _('Additions are marked like this.'),)
+
+    # Print all differences
+    for match in linematch:
+        # Starts of pages identical?
+        if lastmatch == match[0:2]:
+            lastmatch = (match[0] + match[2], match[1] + match[2])
+            continue
+        llineno, rlineno = lastmatch[0]+1, lastmatch[1]+1
+        result += """
+<tr class="diff-title">
+<td>
+%s:
+</td>
+<td>
+%s:
+</td>
+</tr>
+""" % (request.formatter.line_anchorlink(1, llineno) + request.formatter.text(t_line % llineno) + request.formatter.line_anchorlink(0),
+       request.formatter.line_anchorlink(1, rlineno) + request.formatter.text(t_line % rlineno) + request.formatter.line_anchorlink(0))
+
+        leftpane = ''
+        rightpane = ''
+        linecount = max(match[0] - lastmatch[0], match[1] - lastmatch[1])
+        for line in range(linecount):
+            if line < match[0] - lastmatch[0]:
+                if line > 0:
+                    leftpane += '\n'
+                leftpane += seq1[lastmatch[0] + line]
+            if line < match[1] - lastmatch[1]:
+                if line > 0:
+                    rightpane += '\n'
+                rightpane += seq2[lastmatch[1] + line]
+
+        charobj = difflib.SequenceMatcher(None, leftpane, rightpane)
+        charmatch = charobj.get_matching_blocks()
+
+        if charobj.ratio() < 0.5:
+            # Insufficient similarity.
+            if leftpane:
+                leftresult = """<span>%s</span>""" % indent(escape(leftpane))
+            else:
+                leftresult = ''
+
+            if rightpane:
+                rightresult = """<span>%s</span>""" % indent(escape(rightpane))
+            else:
+                rightresult = ''
+        else:
+            # Some similarities; markup changes.
+            charlast = (0, 0)
+
+            leftresult = ''
+            rightresult = ''
+            for thismatch in charmatch:
+                if thismatch[0] - charlast[0] != 0:
+                    leftresult += """<span>%s</span>""" % indent(
+                        escape(leftpane[charlast[0]:thismatch[0]]))
+                if thismatch[1] - charlast[1] != 0:
+                    rightresult += """<span>%s</span>""" % indent(
+                        escape(rightpane[charlast[1]:thismatch[1]]))
+                leftresult += escape(leftpane[thismatch[0]:thismatch[0] + thismatch[2]])
+                rightresult += escape(rightpane[thismatch[1]:thismatch[1] + thismatch[2]])
+                charlast = (thismatch[0] + thismatch[2], thismatch[1] + thismatch[2])
+
+        leftpane = '<br>\n'.join(map(indent, leftresult.splitlines()))
+        rightpane = '<br>\n'.join(map(indent, rightresult.splitlines()))
+
+        # removed width="50%%"
+        result += """
+<tr>
+<td class="diff-removed">
+%s
+</td>
+<td class="diff-added">
+%s
+</td>
+</tr>
+""" % (leftpane, rightpane)
+
+        lastmatch = (match[0] + match[2], match[1] + match[2])
+
+    result += '</table>\n'
+    return result
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/util/diff_text.py	Mon Jul 24 11:52:07 2006 +0200
@@ -0,0 +1,78 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - simple text diff (uses difflib)
+
+    @copyright: 2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+from MoinMoin.support import difflib
+
+def diff(oldlines, newlines, **kw):
+    """
+    Find changes between oldlines and newlines.
+    
+    @param oldlines: list of old text lines
+    @param newlines: list of new text lines
+    @keyword ignorews: if 1: ignore whitespace
+    @rtype: list
+    @return: lines like diff tool does output.
+    """
+    false = lambda s: None
+    if kw.get('ignorews', 0):
+        d = difflib.Differ(false)
+    else:
+        d = difflib.Differ(false, false)
+
+    lines = list(d.compare(oldlines, newlines))
+
+    # return empty list if there were no changes
+    changed = 0
+    for l in lines:
+        if l[0] != ' ':
+            changed = 1
+            break
+    if not changed: return []
+
+    if not "we want the unchanged lines, too":
+        if "no questionmark lines":
+            lines = filter(lambda line: line[0] != '?', lines)
+        return lines
+
+
+    # calculate the hunks and remove the unchanged lines between them
+    i = 0              # actual index in lines
+    count = 0          # number of unchanged lines
+    lcount_old = 0     # line count old file
+    lcount_new = 0     # line count new file
+    while i < len(lines):
+        marker = lines[i][0]
+        if marker == ' ':
+            count = count + 1
+            i = i + 1
+            lcount_old = lcount_old + 1
+            lcount_new = lcount_new + 1
+        elif marker in ['-', '+']:
+            if (count == i) and count > 3:
+                lines[:i-3] = []
+                i = 4
+                count = 0
+            elif count > 6:
+                # remove lines and insert new hunk indicator
+                lines[i-count+3:i-3] = ['@@ -%i, +%i @@\n' %
+                                        (lcount_old, lcount_new)]
+                i = i - count + 8
+                count = 0
+            else:
+                count = 0
+                i += 1
+            if marker == '-': lcount_old = lcount_old + 1
+            else: lcount_new = lcount_new + 1
+        elif marker == '?':
+            lines[i:i+1] = []
+
+    # remove unchanged lines a the end
+    if count > 3:
+        lines[-count+3:] = []
+
+    return lines
+
--- a/MoinMoin/wikiutil.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/MoinMoin/wikiutil.py	Mon Jul 24 11:52:07 2006 +0200
@@ -9,7 +9,6 @@
 import os, re, urllib, cgi
 import codecs, types
 
-from MoinMoin.support import difflib
 from MoinMoin import util, version, config
 from MoinMoin.util import pysupport, filesys
 
@@ -1449,76 +1448,6 @@
     """ Returns true if there is a conflict marker in the text. """
     return "/!\ '''Edit conflict" in text
 
-def linediff(oldlines, newlines, **kw):
-    """
-    Find changes between oldlines and newlines.
-    
-    @param oldlines: list of old text lines
-    @param newlines: list of new text lines
-    @keyword ignorews: if 1: ignore whitespace
-    @rtype: list
-    @return: lines like diff tool does output.
-    """
-    false = lambda s: None
-    if kw.get('ignorews', 0):
-        d = difflib.Differ(false)
-    else:
-        d = difflib.Differ(false, false)
-
-    lines = list(d.compare(oldlines, newlines))
-
-    # return empty list if there were no changes
-    changed = 0
-    for l in lines:
-        if l[0] != ' ':
-            changed = 1
-            break
-    if not changed: return []
-
-    if not "we want the unchanged lines, too":
-        if "no questionmark lines":
-            lines = filter(lambda line: line[0] != '?', lines)
-        return lines
-
-
-    # calculate the hunks and remove the unchanged lines between them
-    i = 0              # actual index in lines
-    count = 0          # number of unchanged lines
-    lcount_old = 0     # line count old file
-    lcount_new = 0     # line count new file
-    while i < len(lines):
-        marker = lines[i][0]
-        if marker == ' ':
-            count = count + 1
-            i = i + 1
-            lcount_old = lcount_old + 1
-            lcount_new = lcount_new + 1
-        elif marker in ['-', '+']:
-            if (count == i) and count > 3:
-                lines[:i-3] = []
-                i = 4
-                count = 0
-            elif count > 6:
-                # remove lines and insert new hunk indicator
-                lines[i-count+3:i-3] = ['@@ -%i, +%i @@\n' %
-                                        (lcount_old, lcount_new)]
-                i = i - count + 8
-                count = 0
-            else:
-                count = 0
-                i += 1
-            if marker == '-': lcount_old = lcount_old + 1
-            else: lcount_new = lcount_new + 1
-        elif marker == '?':
-            lines[i:i+1] = []
-
-    # remove unchanged lines a the end
-    if count > 3:
-        lines[-count+3:] = []
-
-    return lines
-
-
 def pagediff(request, pagename1, rev1, pagename2, rev2, **kw):
     """
     Calculate the "diff" between two page contents.
@@ -1532,10 +1461,11 @@
     @return: lines of diff output
     """
     from MoinMoin.Page import Page
+    from MoinMoin.util import diff_text
     lines1 = Page(request, pagename1, rev=rev1).getlines()
     lines2 = Page(request, pagename2, rev=rev2).getlines()
 
-    lines = linediff(lines1, lines2, **kw)
+    lines = diff_text.diff(lines1, lines2, **kw)
     return lines
 
 
--- a/docs/CHANGES	Mon Jul 24 01:19:18 2006 +0200
+++ b/docs/CHANGES	Mon Jul 24 11:52:07 2006 +0200
@@ -67,6 +67,8 @@
     * refactored some actions to use ActionBase base class
     * moved "test" action from wikiaction to MoinMoin/action/
       (and use ActionBase)
+    * moved MoinMoin/config.py to MoinMoin/config/__init__.py
+    * moved MoinMoin/multiconfig.py to MoinMoin/config/multiconfig.py
     * moved "SystemInfo" macro from wikimacro to MoinMoin/macro/
     * moved wikiaction.py stuff to MoinMoin/action/__init__.py
     * moved wikimacro.py stuff to MoinMoin/macro/__init__.py
@@ -190,6 +192,9 @@
       internally, too. So if GUI editor invocation is broken due to browser
       compatibility issues or a wrong browser version check, please file a bug
       at FCKeditor development or browser development.
+    * HINT: instead of "from MoinMoin.multiconfig import DefaultConfig" you
+      need to use "from MoinMoin.config.multiconfig import DefaultConfig" now.
+      You need to change this in you wikiconfig.py or farmconfig.py file.
 
 Version 1.5.4-current:
     * increased maxlength of some input fields from 80 to 200
--- a/wiki/config/more_samples/ldap_smb_farmconfig.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/wiki/config/more_samples/ldap_smb_farmconfig.py	Mon Jul 24 11:52:07 2006 +0200
@@ -69,7 +69,7 @@
 # this is to get everything to sane defaults, so we need to change only what
 # we like to have different:
 
-from MoinMoin.multiconfig import DefaultConfig
+from MoinMoin.config.multiconfig import DefaultConfig
 
 # Now we subclass this DefaultConfig. This means that we inherit every setting
 # from the DefaultConfig, except those we explicitely define different.
--- a/wiki/config/wikiconfig.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/wiki/config/wikiconfig.py	Mon Jul 24 11:52:07 2006 +0200
@@ -15,7 +15,7 @@
 
     Note that there are more config options than you'll find in
     the version of this file that is installed by default; see
-    the module MoinMoin.multiconfig for a full list of names and their
+    the module MoinMoin.config.multiconfig for a full list of names and their
     default values.
 
     Also, the URL http://moinmoin.wikiwikiweb.de/HelpOnConfiguration has
@@ -25,7 +25,7 @@
     from the wikifarm directory instead! **
 """
 
-from MoinMoin.multiconfig import DefaultConfig
+from MoinMoin.config.multiconfig import DefaultConfig
 
 
 class Config(DefaultConfig):
--- a/wiki/config/wikifarm/farmconfig.py	Mon Jul 24 01:19:18 2006 +0200
+++ b/wiki/config/wikifarm/farmconfig.py	Mon Jul 24 11:52:07 2006 +0200
@@ -14,7 +14,7 @@
 
     Note that there are more config options than you'll find in
     the version of this file that is installed by default; see
-    the module MoinMoin.multiconfig for a full list of names and their
+    the module MoinMoin.config.multiconfig for a full list of names and their
     default values.
 
     Also, the URL http://moinmoin.wikiwikiweb.de/HelpOnConfiguration has
@@ -42,10 +42,10 @@
 wikis = [
     # Standalone server needs the port e.g. localhost:8000
     # Twisted server can now use the port, too.
-    
+
     # wikiname,     url regular expression (no protocol)
     # ---------------------------------------------------------------
-    ("mywiki",  r".*"),   # this is ok for a single wiki
+    ("mywiki", r".*"),   # this is ok for a single wiki
 
     # for multiple wikis, do something like this:
     #("moinmoin",    r"^moinmoin.wikiwikiweb.de/.*$"),
@@ -65,7 +65,7 @@
 # this is to get everything to sane defaults, so we need to change only what
 # we like to have different:
 
-from MoinMoin.multiconfig import DefaultConfig
+from MoinMoin.config.multiconfig import DefaultConfig
 
 # Now we subclass this DefaultConfig. This means that we inherit every setting
 # from the DefaultConfig, except those we explicitely define different.