Exemple #1
0
    def createFormatter(self, format):
        try:
            Formatter = wikiutil.importPlugin(self.request.cfg, "formatter", format, "Formatter")
        except wikiutil.PluginMissingError:
            from MoinMoin.formatter.text_plain import Formatter

        formatter = Formatter(self.request)
        self.request.formatter = formatter
        formatter.page = self.page
        return formatter
Exemple #2
0
    def createFormatter(self, format):
        try:
            Formatter = wikiutil.importPlugin(self.request.cfg, 'formatter',
                                              format, 'Formatter')
        except wikiutil.PluginMissingError:
            from MoinMoin.formatter.text_plain import Formatter

        formatter = Formatter(self.request)
        self.request.formatter = formatter
        formatter.page = self.page
        return formatter
def execute(pagename, request):
    # _ = request.getText
    request.http_headers(["Content-type: text/plain;charset=%s" %
                          config.charset])

    try:
        # try to load the formatter
        Formatter = wikiutil.importPlugin(request.cfg, 'formatter',
                                          'application_x_tex', "Formatter")
        if Formatter is None:
            raise TexException("Plugin not found!")
        formatter = Formatter(request)
        # The proper exception classes seem to exist in documentation only
        #                raise wikiutil.PluginMissingError
        #         except wikiutil.PluginMissingError:
        #             request.write(formatter.text("Plugin not found"))
        #             urlformatter = formatter
        #         except wikiutil.PluginAttributeError:
        #             request.write(formatter.text(
        #                           "Something wrong with plugin"))
        #             urlformatter = formatter
    except:
        # default to plain 
        import sys
        del Formatter
        from MoinMoin.formatter.text_plain import Formatter
        formatter = Formatter(request)
        request.write(formatter.text("What error??" + str(sys.exc_info()[0])))

    Page(request, pagename, formatter=formatter).send_page(request)

    # Write args to end, reminder/debug
    args = filter(lambda x: x != 'action', request.form.keys())
    if args:
        request.write(formatter.preformatted(1))
        for arg in args:
            request.write(arg)
            for val in request.form[arg]:
                request.write(" " + val)
        request.write(formatter.preformatted(0))

    raise MoinMoinNoFooter
Exemple #4
0
        @param search_type: "text" or "title" search
        @param length: length of context preview (in characters)
        @param case: should the search be case sensitive?
        @param mtime: only output pages modified after mtime
        @param regexp: should the query_string be treates as a regular expression?
        @return: (page name, context preview, page url)
        """
        from MoinMoin import search
        from MoinMoin.formatter.text_plain import Formatter

        kwargs = {"sort": "page_name", "case": case, "regex": regexp}
        if search_type == "title":
            kwargs["titlesearch"] = True

        results = search.searchPages(self.request, query_string, **kwargs)
        results.formatter = Formatter(self.request)
        results.request = self.request

        return [(self._outstr(hit.page_name),
                 self._outstr(results.formatContext(hit, length, 1)),
                 self.request.getQualifiedURL(hit.page.url(self.request, {})))
                for hit in results.hits]

    def xmlrpc_getMoinVersion(self):
        """
        Returns a tuple of the MoinMoin version:
        (project, release, revision)
        """
        from MoinMoin import version
        return (version.project, version.release, version.revision)