def parse(story):
    """
    The main workhorse that does nothing but call MoinMoin to do its dirty
    laundry

    @param story: A text for conversion
    @type story: string
    @returns: formatted string
    @rtype: string
    """
    s = StringIO()
    oldstdout = sys.stdout
    form = None
    page = Page(None)
    page.hilite_re = None
    request = Request()
    request.user = User()
    formatter = Formatter(request)
    formatter.setPage(page)
    sys.stdout = s
    Parser(story, request).format(formatter, form)
    sys.stdout = oldstdout
    result = s.getvalue()
    s.close()
    return result
Exemple #2
0
def make_macro(request, page):
    """ creates the macro """
    from MoinMoin import macro
    p = Parser("##\n", request)
    p.formatter = Formatter(request)
    p.formatter.page = page
    request.page = page
    request.formatter = p.formatter
    p.form = request.form
    m = macro.Macro(p)
    return m
Exemple #3
0
 def __init__(self, request, static=[], formatter=None, **kw):
     if formatter:
         self.formatter = formatter
     else:
         from MoinMoin.formatter.text_html import Formatter
         self.formatter = Formatter(request, store_pagelinks=1)
     self.static = static
     self.code_fragments = []
     self.__formatter = "formatter"
     self.__parser = "parser"
     self.request = request
     self.__lang = request.current_lang
     self.__in_p = 0
     self.__in_pre = 0
     self.text_cmd_begin = '\nrequest.write('
     self.text_cmd_end = ')\n'
Exemple #4
0
def show_result(pagename, request):
    _ = request.getText

    request.theme.send_title(_("Subscribed for %s:") % pagename, pagename=pagename)

    from MoinMoin.formatter.text_html import Formatter
    formatter = Formatter(request)

    usernames = request.form['users'].split(",")
    subscribe, unsubscribe = parse_userlist(usernames)

    result = subscribe_users(request, subscribe, unsubscribe, pagename, formatter)
    request.write(result)

    request.theme.send_footer(pagename)
    request.theme.send_closing_html()
Exemple #5
0
def execute(pagename, request):
    _ = request.getText
    from MoinMoin.formatter.text_html import Formatter
    request.formatter = Formatter(request)

    request.emit_http_headers()

    # This action generate data using the user language
    request.setContentLanguage(request.lang)
    request.theme.send_title(_('Actions for %s') % pagename, pagename=pagename)

    # Start content - IMPORTANT - without content div, there is no
    # direction support!
    request.write(request.formatter.startContent("content"))

    # Just list the actions
    request.write(availableactions(request))

    # End content and send footer
    request.write(request.formatter.endContent())
    request.theme.send_footer(pagename)
Exemple #6
0
+re:username_re: subscribes users who match <username_re> regex.
-re:username_re: unsubscribes users who match <username_re> regex.

URL is just needed for a farmconfig scenario.

Example:
%(myname)s FrontPage TestUser,MatthewSimpson

""" % {"myname": os.path.basename(args[0])}
        raise SystemExit

    pagename = args[1]
    usernames = args[2].split(",")

    if len(args) > 3:
        request_url = args[3]
    else:
        request_url = None

    # Setup MoinMoin environment
    from MoinMoin.web.contexts import ScriptContext
    request = ScriptContext(url=request_url)

    from MoinMoin.formatter.text_plain import Formatter
    formatter = Formatter(request)

    subscribe, unsubscribe = parse_userlist(usernames)

    print subscribe_users(request, subscribe, unsubscribe, pagename, formatter)