当前位置: 首页>>代码示例>>Python>>正文


Python wikiutil.importPlugin函数代码示例

本文整理汇总了Python中MoinMoin.wikiutil.importPlugin函数的典型用法代码示例。如果您正苦于以下问题:Python importPlugin函数的具体用法?Python importPlugin怎么用?Python importPlugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了importPlugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: contentfilter

 def contentfilter(self, filename):
     """ Get a filter for content of filename and return unicode content. """
     import mimetypes
     from MoinMoin import wikiutil
     request = self.request
     mimetype, encoding = mimetypes.guess_type(filename)
     if mimetype is None:
         mimetype = 'application/octet-stream'
     def mt2mn(mt): # mimetype to modulename
         return mt.replace("/", "_").replace("-","_").replace(".", "_")
     try:
         _filter = mt2mn(mimetype)
         execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
     except wikiutil.PluginMissingError:
         try:
             _filter = mt2mn(mimetype.split("/", 1)[0])
             execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
         except wikiutil.PluginMissingError:
             try:
                 _filter = mt2mn('application/octet-stream')
                 execute = wikiutil.importPlugin(request.cfg, 'filter', _filter)
             except wikiutil.PluginMissingError:
                 raise ImportError("Cannot load filter %s" % binaryfilter)
     try:
         data = execute(self, filename)
         request.log("Filter %s returned %d characters for file %s" % (_filter, len(data), filename))
     except (OSError, IOError), err:
         data = ''
         request.log("Filter %s threw error '%s' for file %s" % (_filter, str(err), filename))
开发者ID:imosts,项目名称:flume,代码行数:29,代码来源:lupy.py

示例2: setProcessor

 def setProcessor(self, name):
     """ Set processer to either processor or parser named 'name' """
     cfg = self.request.cfg
     try:
         self.processor = wikiutil.importPlugin(cfg, "processor", name, "process")
         self.processor_is_parser = 0
     except wikiutil.PluginMissingError:
         try:
             self.processor = wikiutil.importPlugin(cfg, "parser", name, "Parser")
             self.processor_is_parser = 1
         except wikiutil.PluginMissingError:
             self.processor = None
开发者ID:Glottotopia,项目名称:aagd,代码行数:12,代码来源:text_moin158_wiki.py

示例3: execute

    def execute(self, macro_name, args):
        """ Get and execute a macro

        Try to get a plugin macro, or a builtin macro or a language
        macro, or just raise ImportError.
        """
        self.name = macro_name
        try:
            str(macro_name)
        except UnicodeEncodeError:
            _ = self._
            return self.formatter.text(_("<<%(macro_name)s: invalid macro name>>") % {"macro_name": macro_name})
        try:
            call = wikiutil.importPlugin(self.cfg, "macro", macro_name, function="macro_%s" % macro_name)
            execute = lambda _self, _args: wikiutil.invoke_extension_function(_self.request, call, _args, [_self])
        except wikiutil.PluginAttributeError:
            # fall back to old execute() method, no longer recommended
            execute = wikiutil.importPlugin(self.cfg, "macro", macro_name)
        except wikiutil.PluginMissingError:
            try:
                call = getattr(self, "macro_%s" % macro_name)
                execute = lambda _self, _args: wikiutil.invoke_extension_function(_self.request, call, _args, [])
            except AttributeError:
                if macro_name in i18n.wikiLanguages():
                    execute = self.__class__._m_lang
                else:
                    raise ImportError("Cannot load macro %s" % macro_name)
        try:
            return execute(self, args)
        except Exception, err:
            # we do not want that a faulty macro aborts rendering of the page
            # and makes the wiki UI unusable (by emitting a Server Error),
            # thus, in case of exceptions, we just log the problem and return
            # some standard text.
            try:
                page_spec = " (page: '%s')" % self.formatter.page.page_name
            except:
                page_spec = ""
            logging.exception("Macro %s%s raised an exception:" % (self.name, page_spec))
            _ = self.request.getText
            return self.formatter.text(
                _("<<%(macro_name)s: execution failed [%(error_msg)s] (see also the log)>>")
                % {
                    "macro_name": self.name,
                    "error_msg": err.args[0],  # note: str(err) or unicode(err) does not work for py2.4/5/6
                }
            )
            import traceback

            logging.info("Stack:\n" + traceback.format_stack())
开发者ID:microcosmx,项目名称:experiments,代码行数:50,代码来源:__init__.py

示例4: get_dependencies

 def get_dependencies(self, macro_name):
     if macro_name in self.Dependencies:
         return self.Dependencies[macro_name]
     try:
         return wikiutil.importPlugin(self.request.cfg, "macro", macro_name, "Dependencies")
     except wikiutil.PluginError:
         return self.defaultDependency
开发者ID:microcosmx,项目名称:experiments,代码行数:7,代码来源:__init__.py

示例5: _handle_submission

def _handle_submission(request):
    """ Handle GET and POST requests of preferences forms.

    Return error msg_class, msg tuple or None, None.
    """
    _ = request.getText
    sub = request.form.get('handler', [None])[0]

    if sub in request.cfg.userprefs_disabled:
        return None, None

    try:
        cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
    except wikiutil.PluginMissingError:
        # we never show this plugin to click on so no need to
        # give a message here
        return None, None

    obj = cls(request)
    if not obj.allowed():
        return None, None
    res = obj.handle_form()
    if isinstance(res, tuple):
        return res
    # backward compatibility for userprefs plugins,
    # they just get 'dialog'-style messages.
    return None, res
开发者ID:steveyen,项目名称:moingo,代码行数:27,代码来源:userprefs.py

示例6: execute

def execute(pagename, request):
    macro_action = wikiutil.importPlugin(request.cfg, "macro", pagename, "action_" + pagename)
    
    result = macro_action(request)
    
    request.write(result)
    request.close()
开发者ID:felixonmars,项目名称:process,代码行数:7,代码来源:process.py

示例7: execute

def execute(pagename, request):
    # Strip non-ascii chars in header
    pagename_header = '%s.csv' % (pagename)
    pagename_header = pagename_header.encode('ascii', 'ignore')
    
    request.content_type = 'text/csv; charset=UTF-8'
    request.headers['Content-Disposition'] = \
        'attachment; filename="%s"' % pagename_header
    GetMeta = wikiutil.importPlugin(request.cfg, 'xmlrpc', 'GetMeta', 'do_action')

    form = values_to_form(request.values)

    try:
        args = form['args'][0]
    except (KeyError, IndexError):
        args = u''

    table = GetMeta(request, args, keysonly=False)
    table = getmeta_to_table(table)
    if 0:
        print '--', table, '--'
        print 'args', args
        print 'pagename', pagename

    writer = csv.writer(request, delimiter=';')

    for row in table:
        writer.writerow(map(encode_page, row))
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:28,代码来源:metaCSV.py

示例8: execute

def execute(pagename, request):
    enter_page(request, pagename, "Group Editor")
    macro = wikiutil.importPlugin(request.cfg, "macro", "GroupEditor", "do_macro")
    request.write(macro(request))
    page = Page(request, pagename)
    request.write(page.link_to(request, text=request.getText("back")))
    exit_page(request, pagename)
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:7,代码来源:GroupEditor.py

示例9: send_page_content

    def send_page_content(self, request, notparser, body, format_args='',
                          do_cache=0, **kw):
        self.parser = importPlugin(request.cfg, "parser",
                                   'link_collect', "Parser")

        kw['format_args'] = format_args
        kw['do_cache'] = 0
        apply(Page.send_page_content, (self, request, self.parser, body), kw)
开发者ID:graphingwiki,项目名称:graphingwiki,代码行数:8,代码来源:savegraphdata.py

示例10: createParser

 def createParser(self, format, text):
     if format == "wiki":
         format = "text_moin_wiki"
     try:
         Parser = wikiutil.importPlugin(self.request.cfg, "parser", format, "Parser")
     except wikiutil.PluginMissingError:
         from MoinMoin.parser.text import Parser
     parser = Parser(text, self.request)
     return parser
开发者ID:microcosmx,项目名称:experiments,代码行数:9,代码来源:SlideShow.py

示例11: format

    def format(self, formatter):
        if len(self.args) <= 0:
            from MoinMoin.wikiutil import importPlugin
            sqlparser = importPlugin(self.request.cfg, 'parser', 'sql', 'Parser')
            sqlparser(self.query, self.request).format(formatter)
        else:
            try:
                self.validate()
                self.__run_n_format(formatter)
            except Exception as inst:
                from MoinMoin.wikiutil import importPlugin
                sqlparser = importPlugin(self.request.cfg, 'parser', 'sql', 'Parser')
                sqlparser(self.query, self.request).format(formatter)

                self.request.write(u'<pre>%s</pre>' % str(inst))

                import traceback, sys
                traceback.print_exc(file=sys.stdout)
开发者ID:happytk,项目名称:moin,代码行数:18,代码来源:sqlrun.py

示例12: get_dependencies

 def get_dependencies(self, macro_name):
     if self.Dependencies.has_key(macro_name):
         return self.Dependencies[macro_name]
     result = wikiutil.importPlugin(self.request.cfg, 'macro', macro_name,
                                    'Dependencies')
     if result != None:
         return result
     else:
         return ["time"]
开发者ID:moinwiki,项目名称:moin-legacy,代码行数:9,代码来源:wikimacro.py

示例13: processor

 def processor(self, processor_name, lines, is_parser=0):
     """ processor_name MUST be valid!
         writes out the result instead of returning it!
     """
     if not is_parser:
         processor = wikiutil.importPlugin(self.request.cfg, "processor",
                                           processor_name, "process")
         processor(self.request, self, lines)
     else:
         parser = wikiutil.importPlugin(self.request.cfg, "parser",
                                        processor_name, "Parser")
         args = self._get_bang_args(lines[0])
         if args is not None:
             lines = lines[1:]
         p = parser('\n'.join(lines), self.request, format_args=args)
         p.format(self)
         del p
     return ''
开发者ID:imosts,项目名称:flume,代码行数:18,代码来源:base.py

示例14: testSyntaxReferenceDomXml

 def testSyntaxReferenceDomXml(self):
     f_name = 'dom_xml'
     try:
         formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
     except wikiutil.PluginAttributeError:
         pass
     else:
         print "Formatting using %r" % formatter
         self.formatPage("SyntaxReference", formatter)
         print "Done."
开发者ID:steveyen,项目名称:moingo,代码行数:10,代码来源:test_formatter.py

示例15: getHandler

def getHandler(request, action, identifier="execute"):
    # check for excluded actions
    if action in request.cfg.excluded_actions:
        return None

    handler = wikiutil.importPlugin(request.cfg, "action", action, identifier)
    if handler is None:
        handler = globals().get('do_' + action)
        
    return handler
开发者ID:mikejamesthompson,项目名称:orgsites,代码行数:10,代码来源:wikiaction.py


注:本文中的MoinMoin.wikiutil.importPlugin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。