# HG changeset patch # User Paul Boddie # Date 1384173219 -3600 # Node ID 2315c680bd16585883b7c66c0aae75621a408869 # Parent a2e8615152cfdd14e8749e4fba980e55d1a1221f Made use of functionality moved to MoinSupport. diff -r a2e8615152cf -r 2315c680bd16 MoinContentSupport.py --- a/MoinContentSupport.py Sun Sep 11 18:50:16 2011 +0200 +++ b/MoinContentSupport.py Mon Nov 11 13:33:39 2013 +0100 @@ -2,26 +2,27 @@ """ MoinMoin - MoinContentSupport library - @copyright: 2008, 2009, 2010, 2011 by Paul Boddie + @copyright: 2008, 2009, 2010, 2011, 2013 by Paul Boddie @copyright: 2000-2004 Juergen Hermann , 2005-2008 MoinMoin:ThomasWaldmann. @license: GNU GPL (v2 or later), see COPYING.txt for details. """ +from MoinSupport import heading_regexp_str from MoinMoin.wikiutil import escape import re __version__ = "0.1" # Regular expressions. -# NOTE: These overlap with ImprovedMoinSearch and EventAggregator. -heading_regexp_str = r"^(?P=+)\s*(?P.*?)\s*(?P=level)$" hrule_regexp_str = r"^----$" include_regexp_str = r"^\s*<>$" section_regexp_str = "(" + heading_regexp_str + "|" + hrule_regexp_str + "|" + include_regexp_str + ")" section_regexp = re.compile(section_regexp_str, re.UNICODE | re.MULTILINE) +# NOTE: This overlaps with EventAggregator. + category_membership_str = ur"^\s*(?:(Category\S+)(?:\s+(Category\S+))*)\s*$" category_membership_regexp = re.compile(category_membership_str, re.MULTILINE | re.UNICODE) category_declarations_regexp = re.compile("^----$\s*" + category_membership_str, re.MULTILINE | re.UNICODE) @@ -81,64 +82,4 @@ return "\n----\n%s\n" % " ".join(categories) -# Utility classes and associated functions. -# NOTE: These are a subset of EventAggregatorSupport. - -class Form: - - """ - A wrapper preserving MoinMoin 1.8.x (and earlier) behaviour in a 1.9.x - environment. - """ - - def __init__(self, form): - self.form = form - - def get(self, name, default=None): - values = self.form.getlist(name) - if not values: - return default - else: - return values - - def __getitem__(self, name): - return self.form.getlist(name) - -class ActionSupport: - - """ - Work around disruptive MoinMoin changes in 1.9, and also provide useful - convenience methods. - """ - - def get_form(self): - return get_form(self.request) - -def get_form(request): - - "Work around disruptive MoinMoin changes in 1.9." - - if hasattr(request, "values"): - return Form(request.values) - else: - return request.form - -class send_headers: - - """ - A wrapper to preserve MoinMoin 1.8.x (and earlier) request behaviour in a - 1.9.x environment. - """ - - def __init__(self, request): - self.request = request - - def __call__(self, headers): - for header in headers: - parts = header.split(":") - self.request.headers.add(parts[0], ":".join(parts[1:])) - -def escattr(s): - return escape(s, 1) - # vim: tabstop=4 expandtab shiftwidth=4 diff -r a2e8615152cf -r 2315c680bd16 actions/AddLinkToPage.py --- a/actions/AddLinkToPage.py Sun Sep 11 18:50:16 2011 +0200 +++ b/actions/AddLinkToPage.py Mon Nov 11 13:33:39 2013 +0100 @@ -5,7 +5,7 @@ Add a link using a form in the page, getting details of the linked document and inserting them with the link itself. - @copyright: 2010 Paul Boddie + @copyright: 2010, 2013 Paul Boddie @license: GNU GPL, see COPYING for details. """ @@ -13,7 +13,8 @@ from MoinMoin.action import ActionBase from MoinMoin.PageEditor import PageEditor -from MoinContentSupport import ActionSupport, escape, escattr +from MoinMoin.wikiutil import escape +from MoinSupport import ActionSupport, escattr import urllib import re diff -r a2e8615152cf -r 2315c680bd16 actions/SectionBreakout.py --- a/actions/SectionBreakout.py Sun Sep 11 18:50:16 2011 +0200 +++ b/actions/SectionBreakout.py Mon Nov 11 13:33:39 2013 +0100 @@ -5,7 +5,7 @@ Break sections out of a page, making new pages for each of the sections and replacing them with Include macros. - @copyright: 2011 Paul Boddie + @copyright: 2011, 2013 Paul Boddie @license: GNU GPL, see COPYING for details. """ @@ -13,7 +13,9 @@ from MoinMoin.action import ActionBase from MoinMoin.PageEditor import PageEditor +from MoinMoin.wikiutil import escape from MoinContentSupport import * +from MoinSupport import ActionSupport, escattr import re # Action class and supporting functions.