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


Python tags.div函数代码示例

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


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

示例1: render_GET

 def render_GET(self, request):
     email = self.getRequestEmail(request)
     request.setHeader('content-type', 'text/html; charset=utf-8')
     element = tags.html(
         htmlHead,
         tags.body(tags.form(
             tags.fieldset(
                 tags.div(
                     tags.label('Cert e-mail'),
                     tags.label('Username', for_='username'),
                     tags.label('Password', for_='password'),
                     tags.label('Site', for_='site', class_='last'),
                     id='names',
                 ),
                 tags.div(
                     tags.input(disabled='true', value=email),
                     tags.input(name='username', type='text'),
                     tags.input(name='password', type='password'),
                     tags.input(name='site', type='url', class_='last'),
                     id='fields',
                 ),
             ),
             tags.button('Generate', type='submit'),
             action='', method='POST',
         )),
     )
     return renderElement(request, element)
开发者ID:habnabit,项目名称:passacre-server,代码行数:27,代码来源:passacre_server.py

示例2: generateTabsAndContent

        def generateTabsAndContent(results):
            """
            results is a dictionary whose keys are normalized ASCII chars and
            whose values are the original (possible unicode) chars that map to
            the ASCII ones.
            """
            tabs = []
            contents = []
            for asciiLetter in sorted(results.keys()):
                if not asciiLetter:
                    continue
                for letter in sorted(results[asciiLetter]):
                    tab = tags.li(
                        tags.a(
                            letter.upper(),
                            href="#l%s" % letter,
                            **{"data-toggle": "tab"})
                        )
                    tabs.append(tab)
                    content = tags.div(
                        tags.p("holding content"),
                        class_="tab-pane",
                        id="l%s" % letter)
                    contents.append(content)

            return tags.div(
                tags.ul(tabs, class_="nav nav-tabs"),
                tags.div(contents, class_="tab-content"),
                class_="tabbable tabs-left")
开发者ID:oubiwann,项目名称:tharsk,代码行数:29,代码来源:elements.py

示例3: functionExtras

 def functionExtras(self, data):
     imeth = self.interfaceMeth(data.name)
     r = []
     if imeth:
         r.append(tags.div(class_="interfaceinfo")('from ', taglink(imeth, imeth.parent.fullName())))
     r.extend(super(ZopeInterfaceClassPage, self).functionExtras(data))
     return r
开发者ID:chevah,项目名称:pydoctor,代码行数:7,代码来源:__init__.py

示例4: test_sourceFragmentElement

    def test_sourceFragmentElement(self):
        """
        L{_SourceFragmentElement} renders source lines at and around the line
        number indicated by a frame object.
        """
        element = _SourceFragmentElement(
            TagLoader(tags.div(
                    tags.span(render="lineNumber"),
                    tags.span(render="sourceLine"),
                    render="sourceLines")),
            self.frame)

        source = [
            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}message = '
            u'"This is a problem"',

            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}raise Exception(message)',
            u'# Figure out the line number from which the exception will be '
            u'raised.',
        ]
        d = flattenString(None, element)
        d.addCallback(
            self.assertEqual,
            ''.join([
                    '<div class="snippet%sLine"><span>%d</span><span>%s</span>'
                    '</div>' % (
                        ["", "Highlight"][lineNumber == 1],
                        self.base + lineNumber,
                        (u" \N{NO-BREAK SPACE}" * 4 + sourceLine).encode(
                            'utf-8'))
                    for (lineNumber, sourceLine)
                    in enumerate(source)]))
        return d
开发者ID:ali-hallaji,项目名称:twisted,代码行数:33,代码来源:test_util.py

示例5: test_template_numbers

    def test_template_numbers(self):
        """
        Data returned from a plated method may include numeric types (integers,
        floats, and possibly longs), which although they are not normally
        serializable by twisted.web.template, will be converted by plating into
        their decimal representation.
        """
        @page.routed(
            self.app.route("/"),
            tags.div(
                tags.span(slot("anInteger")),
                tags.i(slot("anFloat")),
                tags.b(slot("anLong")),
            ),
        )
        def plateMe(result):
            return {"anInteger": 7,
                    "anFloat": 3.2,
                    "anLong": 0x10000000000000001}

        request, written = self.get(b"/")

        self.assertIn(b"<span>7</span>", written)
        self.assertIn(b"<i>3.2</i>", written)
        self.assertIn(b"<b>18446744073709551617</b>", written)
开发者ID:twisted,项目名称:klein,代码行数:25,代码来源:test_plating.py

示例6: functionExtras

 def functionExtras(self, data):
     r = []
     for b in self.ob.allbases(include_self=False):
         if data.name not in b.contents:
             continue
         overridden = b.contents[data.name]
         r.append(tags.div(class_="interfaceinfo")("overrides ", taglink(overridden)))
         break
     ocs = sorted(overriding_subclasses(self.ob, data.name), key=lambda o: o.fullName().lower())
     if ocs:
         self.overridenInCount += 1
         idbase = "overridenIn" + str(self.overridenInCount)
         l = assembleList(self.ob.system, "overridden in ", [o.fullName() for o in ocs], idbase)
         if l is not None:
             r.append(tags.div(class_="interfaceinfo")(l))
     return r
开发者ID:pombredanne,项目名称:pydoctor,代码行数:16,代码来源:__init__.py

示例7: test_widget_json

    def test_widget_json(self):
        """
        When L{Plating.widgeted} is applied as a decorator, and the result is
        serialized to JSON, it appears the same as the returned value despite
        the HTML-friendly wrapping described above.
        """
        @page.routed(self.app.route("/"),
                     tags.div(tags.div(slot("widget")),
                              tags.div(slot("instance-widget"))))
        def rsrc(request):
            return {"widget": enwidget.widget(a=3, b=4),
                    "instance-widget": InstanceWidget().enwidget.widget(5, 6)}

        request, written = self.get(b"/?json=1")
        self.assertEqual(json.loads(written.decode('utf-8')),
                         {"widget": {"a": 3, "b": 4},
                          "instance-widget": {"a": 5, "b": 6},
                          "title": "default title unchanged"})
开发者ID:twisted,项目名称:klein,代码行数:18,代码来源:test_plating.py

示例8: test_widget_html

    def test_widget_html(self):
        """
        When L{Plating.widgeted} is applied as a decorator, it gives the
        decorated function a C{widget} attribute which is a version of the
        function with a modified return type that turns it into a renderable
        HTML sub-element that may fill a slot.
        """
        @page.routed(self.app.route("/"),
                     tags.div(tags.div(slot("widget")),
                              tags.div(slot("instance-widget"))))
        def rsrc(request):
            return {"widget": enwidget.widget(a=3, b=4),
                    "instance-widget": InstanceWidget().enwidget.widget(5, 6)}

        request, written = self.get(b"/")

        self.assertIn(b"<span>a: 3</span>", written)
        self.assertIn(b"<span>b: 4</span>", written)
        self.assertIn(b"<span>a: 5</span>", written)
        self.assertIn(b"<span>b: 6</span>", written)
开发者ID:twisted,项目名称:klein,代码行数:20,代码来源:test_plating.py

示例9: main

    def main(self, request, tag):
        retval = []
        for automaton in factory.automatons:
            title = tags.h2(automaton.name)
            stats = []

            # Discover tracked information.
            if hasattr(automaton, "tracked"):
                t = automaton.tracked
                if isinstance(t, dict):
                    l = sum(len(i) for i in t.values())
                else:
                    l = len(t)
                stats.append(tags.li("Currently tracking %d blocks" % l))

            if hasattr(automaton, "step"):
                stats.append(tags.li("Currently processing every %f seconds" %
                    automaton.step))

            retval.append(tags.div(title, tags.ul(stats)))
        return tags.div(*retval)
开发者ID:gwylim,项目名称:bravo,代码行数:21,代码来源:web.py

示例10: test_failureElementTraceback

 def test_failureElementTraceback(self):
     """
     The I{traceback} renderer of L{FailureElement} renders the failure's
     stack frames using L{_StackElement}.
     """
     element = FailureElement(self.failure)
     renderer = element.lookupRenderMethod("traceback")
     tag = tags.div()
     result = renderer(None, tag)
     self.assertIsInstance(result, _StackElement)
     self.assertIdentical(result.stackFrames, self.failure.frames)
     self.assertEqual([tag], result.loader.load())
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:12,代码来源:test_util.py

示例11: service

 def service(self, request, tag):
     l = []
     services = []
     for name, service in self.services.iteritems():
         factory = service.args[1]
         if isinstance(factory, BravoFactory):
             services.append(self.bravofactory(request, tags.div, factory))
         else:
             l.append(tags.li("%s (%s)" %
                 (name, self.services[name].__class__)))
     ul = tags.ul(*l)
     div = tags.div(*services)
     return tag(ul, div)
开发者ID:matejcik,项目名称:bravo,代码行数:13,代码来源:web.py

示例12: test_frameElementSource

 def test_frameElementSource(self):
     """
     The I{source} renderer of L{_FrameElement} renders the source code near
     the source filename/line number associated with the frame object used to
     initialize the L{_FrameElement}.
     """
     element = _FrameElement(None, self.frame)
     renderer = element.lookupRenderMethod("source")
     tag = tags.div()
     result = renderer(None, tag)
     self.assertIsInstance(result, _SourceFragmentElement)
     self.assertIdentical(result.frame, self.frame)
     self.assertEqual([tag], result.loader.load())
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:13,代码来源:test_util.py

示例13: body

    def body(self, req):
        status = self.getStatus(req)
        authz = self.getAuthz(req)

        builders = req.args.get(
            "builder", status.getBuilderNames(categories=self.categories))
        branches = [b for b in req.args.get("branch", []) if b]
        if not branches:
            branches = ["master"]
        if branches and "master" not in branches:
            defaultCount = "1"
        else:
            defaultCount = "10"
        num_builds = int(req.args.get("num_builds", [defaultCount])[0])

        tag = tags.div()

        tag(tags.script(src="hlbb.js"))
        tag(tags.h2(style="float:left; margin-top:0")
                   ("Latest builds: ", ", ".join(branches)))

        form = tags.form(method="get", action="", style="float:right",
                         onsubmit="return checkBranch(branch.value)")
        form(tags.input(type="test", name="branch",
                        placeholder=branches[0], size="40"))
        form(tags.input(type="submit", value="View"))
        if (yield authz.actionAllowed('forceAllBuilds', req)):
            # XXX: Unsafe interpolation
            form(tags.button(
                type="button",
                onclick="forceBranch(branch.value || %r, %r)"
                        % (branches[0], self.categories,)
                )("Force"))
        tag(form)

        table = tags.table(style="clear:both")
        tag(table)

        for bn in filter(lambda bn: bn not in self.failing_builders, builders):
            table(self.builder_row(bn, req, branches, num_builds))

        table(tags.tr()(tags.td(colspan="100")(
            tags.h3(style="float:left; margin-top:0")
                   ("Expected failures: "))))

        for bn in filter(lambda bn: bn in self.failing_builders, builders):
            table(self.builder_row(bn, req, branches, num_builds))

        defer.returnValue((yield flattenString(req, tag)))
开发者ID:ClusterHQ,项目名称:build.clusterhq.com,代码行数:49,代码来源:boxes.py

示例14: test_sourceLineElement

 def test_sourceLineElement(self):
     """
     L{_SourceLineElement} renders a source line and line number.
     """
     element = _SourceLineElement(
         TagLoader(tags.div(
                 tags.span(render="lineNumber"),
                 tags.span(render="sourceLine"))),
         50, "    print 'hello'")
     d = flattenString(None, element)
     expected = (
         u"<div><span>50</span><span>"
         u" \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}print 'hello'</span></div>")
     d.addCallback(
         self.assertEqual, expected.encode('utf-8'))
     return d
开发者ID:daweasel27,项目名称:PhobiaEnemy,代码行数:16,代码来源:test_util.py

示例15: render_POST

 def render_POST(self, request):
     request.setHeader('content-type', 'text/html; charset=utf-8')
     app = self.getApplication(request)
     password = app.config.generate_for_site(
         request.args['username'][0],
         request.args['password'][0],
         request.args['site'][0])
     element = tags.html(
         htmlHead,
         tags.body(tags.div(
             tags.input(
                 size='1', value=password, onFocus=selectJS, onMouseUp='return false',
             ),
         ), class_='center'),
     ),
     return renderElement(request, element)
开发者ID:habnabit,项目名称:passacre-server,代码行数:16,代码来源:passacre_server.py


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