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


Python loaders.xmlfile函数代码示例

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


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

示例1: template

def template(templatename, pattern=None):
    """
    Load XML template
    """
    return loaders.xmlfile(templatename, 
                           templateDir=config.TEMPLATE_PATH,
                           pattern=pattern)
开发者ID:j2a,项目名称:pyo-sandbox,代码行数:7,代码来源:pages.py

示例2: __init__

 def __init__(self, original, ctx, factory):
     self.factory = factory  
     self.user = self.factory.getUser(original)
     rend.Page.__init__(self, original)
     
     r = manager.ResourceManager()
     UserAdmin.docFactory = loaders.xmlfile( r["resources"]["web"]["user_admin.html"] )
开发者ID:aoupi,项目名称:pyscrabble-club,代码行数:7,代码来源:site.py

示例3: render_content

 def render_content(self, ctx, data):
     role = self.getRole(ctx)
     
     if role == 0:
         return self.renderAlert('You are not authorized')
     
     return loaders.xmlfile(webappPath('agent/index.html'))
开发者ID:myaut,项目名称:tsload,代码行数:7,代码来源:agent.py

示例4: getDocFactory

    def getDocFactory(self, fragmentName, default=None):
        """
        For a given fragment, return a loaded Nevow template.

        @param fragmentName: the name of the template (can include relative
        paths).

        @param default: a default loader; only used if provided and the
        given fragment name cannot be resolved.

        @return: A loaded Nevow template.
        @type return: L{nevow.loaders.xmlfile}
        """
        if fragmentName in self.cachedLoaders:
            return self.cachedLoaders[fragmentName]
        segments = fragmentName.split('/')
        segments[-1] += '.html'
        file = self.directory
        for segment in segments:
            file = file.child(segment)
        if file.exists():
            loader = xmlfile(file.path)
            self.cachedLoaders[fragmentName] = loader
            return loader
        return default
开发者ID:fusionapp,项目名称:mantissa,代码行数:25,代码来源:webtheme.py

示例5: test_docFactoryInStanTree

    def test_docFactoryInStanTree(self):

        class Page(rend.Page):

            def __init__(self, included):
                self.included = included
                rend.Page.__init__(self)

            def render_included(self, context, data):
                return self.included
            
            docFactory = loaders.stan(div[invisible(render=directive('included'))])

        doc = '<p>fum</p>'
        temp = self.mktemp()
        f = file(temp, 'w')
        f.write(doc)
        f.close()

        result = deferredRender(Page(loaders.stan(p['fee'])))
        self.assertEquals(result, '<div><p>fee</p></div>')
        result = deferredRender(Page(loaders.htmlstr('<p>fi</p>')))
        self.assertEquals(result, '<div><p>fi</p></div>')
        result = deferredRender(Page(loaders.xmlstr('<p>fo</p>')))
        self.assertEquals(result, '<div><p>fo</p></div>')
        result = deferredRender(Page(loaders.htmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
        result = deferredRender(Page(loaders.xmlfile(temp)))
        self.assertEquals(result, '<div><p>fum</p></div>')
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:29,代码来源:test_rend.py

示例6: macro_content

 def macro_content(self, ctx):
     return t.invisible[
                t.p["This macro has been called ",
                    next(counter2)+1,
                    " time(s)"],
                loaders.xmlfile(util.sibpath(__file__,'child_macro.html'), ignoreDocType=True).load()
         ]
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:7,代码来源:macros.py

示例7: __init__

    def __init__(self, parent, package=None, webServer=None, name=None):
        """
        Pass me a 'parent' rendering component,
        a 'package' that I'm rendering for
        and a 'webServer' instance reference (from webServer.py)
        If you don't pass 'webServer' and 'package' I'll
        get them from 'parent'
        'name' is a identifier to distuniguish us from the other children of our
        parent
        """
        self.parent = parent # This is the same for both blocks and pages
        if name:
            self.name = name
        elif not self.name:
            raise AssertionError('Element of class "%s" created with no name.' %
                                 self.__class__.__name__)
            
        # Make pylint happy. These attributes will be gotten from
        # self.application
        self.config = Unset
        self.ideviceStore = Unset
        self.packageStore = Unset

        # Overwrite old instances with same name
        if parent:
            parent.renderChildren[self.name] = self
        self.renderChildren = {}
        if package:
            self.package = package
        elif parent:
            self.package = parent.package
        else:
            self.package = None
        if webServer:
            self.webServer = webServer
        elif parent:
            self.webServer = parent.webServer
        else:
            self.webServer = None
        if self._templateFileName:
            if hasattr(self, 'config') and self.config:
                pth = self.config.webDir/'templates'/self._templateFileName
                self.docFactory = loaders.xmlfile(pth)
            else:
                # Assume directory is included in the filename
                self.docFactory = loaders.xmlfile(self._templateFileName)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:46,代码来源:renderable.py

示例8: test_xmlfile

 def test_xmlfile(self):
     doc = '<ul id="nav"><li>a</li><li>b</li><li>c</li></ul>'
     temp = self.mktemp()
     f = file(temp, 'w')
     f.write(doc)
     f.close()
     df = loaders.xmlfile(temp)
     self.assertEquals(df.load()[0], doc)
开发者ID:StetHD,项目名称:nevow,代码行数:8,代码来源:test_loaders.py

示例9: __init__

 def __init__(self, original, options=None, otherOption=None):
     self.original = original
     if options is not None:
         self.options = options
     if otherOption is not None:
         self.otherOption = otherOption
     if self.template is None:
         self.template = loaders.xmlfile(util.resource_filename('formal',
             'html/SelectOtherChoice.html'))
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:9,代码来源:widget.py

示例10: __init__

	def __init__(self, *args, **kwargs):
		zoto_base_page.__init__(self, *args, **kwargs)
		self.album_id = -1
		self.offset = 0
		self.username = args[0]
		self.album_id = args[1]
		self.can_view = False
		self.docFactory = loaders.xmlfile(os.path.join(self.tpl_path, "album_template.xml"))
		self.template_path = "%s/album_templates" % aztk_config.setup.get("paths", "web")
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:9,代码来源:user_albums.py

示例11: test_xmlfilePreprocessors

 def test_xmlfilePreprocessors(self):
     """
     Test that the xmlstr loader properly passes uncompiled documents to
     preprocessors it is given.
     """
     xmlFile = self.mktemp()
     f = file(xmlFile, 'w')
     f.write('<div><span>Hello</span><span>world</span></div>')
     f.close()
     factory = loaders.xmlfile(xmlFile)
     return self._preprocessorTest(factory)
开发者ID:StetHD,项目名称:nevow,代码行数:11,代码来源:test_loaders.py

示例12: run

    def run(self):
        kwargs = {}
        template = self.get('template', None)
        if template is not None:
            kwargs['docFactory'] = loaders.xmlfile(template)

        feed = readFeed(self.path)
        a = Atom(feed, **kwargs)
        d = a.renderString()
        d.addCallback(self._print)
        return d
开发者ID:tv42,项目名称:atomat,代码行数:11,代码来源:import_.py

示例13: getfiles

    def getfiles(self,nodes):
        for node in nodes:
            if len(node) == 4:
                self.getfiles(node[3])

            try:
                newpage = rend.Page()
                newpage.docFactory = loaders.xmlfile(node[2],templateDir='apidoc')
            except Exception,e:
                pass
            else:
                self.children[node[1]] = newpage
开发者ID:comfuture,项目名称:numbler,代码行数:12,代码来源:apimanager.py

示例14: getHtml

def getHtml(yamlfile, countItems, template):
    ydata = list(yaml.loadFile(yamlfile))[0]
    Page.docFactory = loaders.xmlfile(template)

    d = Page(ydata, countItems).renderString()

    output = []
    d.addCallback(cb, output)
    d.addErrback(eb)
    reactor.run()

    return output[0]
开发者ID:BackupTheBerlios,项目名称:pbp-svn,代码行数:12,代码来源:news2html.py

示例15: test_xmlFileInStanTree

    def test_xmlFileInStanTree(self):
        """
        Like L{test_htmlStringInStanTree}, but for an xmlfile loader.
        """
        doc = '<p>I</p>'
        temp = self.mktemp()
        f = file(temp, 'w')
        f.write(doc)
        f.close()

        return self._testDocFactoryInStanTree(
            loaders.xmlfile(temp),
            '<p>I</p>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:13,代码来源:test_rend.py


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