• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python template.renderElement函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_nonDefaultDoctype

    def test_nonDefaultDoctype(self):
        """
        L{renderElement} will write the doctype string specified by the
        doctype keyword argument.
        """

        element = TestElement()

        d = self.request.notifyFinish()

        def check(_):
            self.assertEqual(
                "".join(self.request.written),
                ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
                 ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'
                 '<p>Hello, world.</p>'))

        d.addCallback(check)

        renderElement(
            self.request,
            element,
            doctype=(
                '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
                ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'))

        return d
开发者ID:Varriount,项目名称:Colliberation,代码行数:27,代码来源:test_template.py


示例2: _showDirectory

 def _showDirectory(self, request, dirinfo):
     children = dirinfo[1]['children']
     body = tags.ul(*[
         tags.li(tags.a(name + ('/' if info[0] == 'dirnode' else ''),
                        href='/' + info[1]['ro_uri']))
         for name, info in children.iteritems()
     ])
     renderElement(request, body)
开发者ID:habnabit,项目名称:pubtahoe,代码行数:8,代码来源:pubtahoe.py


示例3: process

        def process(r):
            """
            Recursively go through r and any child Resources until something
            returns an IRenderable, then render it and let the result of that
            bubble back up.
            """

            if IResource.providedBy(r):
                request.render(getChildForRequest(r, request))
                return _StandInResource

            if IRenderable.providedBy(r):
                renderElement(request, r)
                return _StandInResource

            return r
开发者ID:glasnt,项目名称:klein,代码行数:16,代码来源:resource.py


示例4: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).getSessionUser()

        if session_user['id'] == 0:
            return redirectTo('../', request)

        sessionResponse = SessionManager(request).getSessionResponse()

        try:
            status = request.args.get('status')[0]
        except:
            status = 'pending'

        filters = {'status': status}

        Page = pages.SummaryTransactions('Summary Transactions', 'summaryTransactions', filters)
        Page.session_user = session_user
        Page.sessionResponse = sessionResponse

        print "%ssession_user: %s%s" % (config.color.BLUE, session_user, config.color.ENDC)
        print "%ssessionResponse: %s%s" % (config.color.BLUE, sessionResponse, config.color.ENDC)
        SessionManager(request).clearSessionResponse()

        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:27,代码来源:summaryTransactions.py


示例5: 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


示例6: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).get_session_user()
        session_user['action'] = 'summary_bids'

        if session_user['level'] != 0:
            return redirectTo('../', request)

        session_response = SessionManager(request).get_session_response()

        filters = {}
        try:
            filters['status'] = request.args.get('status')[0]
        except:
            filters['status'] = 'active'

        Page = pages.SummaryBids('%s Summary Bids' % config.company_name, 'summary_bids', filters)
        Page.session_user = session_user

        print "%ssession_user: %s%s" % (config.color.BLUE, session_user, config.color.ENDC)
        print "%ssession_response: %s%s" % (config.color.BLUE, session_response, config.color.ENDC)

        SessionManager(request).clearSessionResponse()

        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:27,代码来源:summary_bids.py


示例7: render_POST

    def render_POST(self, request):
        uri = request.args.get('uri', [])
        if not uri or not tahoeRegex.match(uri[0]):
            return self.render_GET(request)
        ext = request.args.get('ext', [])

        b64uri = base64.urlsafe_b64encode(uri[0])
        extension = ''
        if ext and ext[0]:
            extension = '.' + ext[0].lstrip('.')
        if uri[0] not in self.shortdb:
            while True:
                short = crockford.b32encode(os.urandom(9)).lower()
                if short not in self.shortdb:
                    break
            self.shortdb[short] = uri[0]
            self.shortdb[uri[0]] = short
            self.shortdb.sync()
        else:
            short = self.shortdb[uri[0]]

        if request.args.get('api', []):
            return '/' + short + extension

        body = tags.p(
            tags.a('long url', href=b64uri + extension), '; ',
            tags.a('medium url', href='/' + uri[0] + extension), '; ',
            tags.a('short url', href=short + extension))
        return renderElement(request, body)
开发者ID:habnabit,项目名称:pubtahoe,代码行数:29,代码来源:pubtahoe.py


示例8: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).get_session_user()
        session_user['page'] = 'transactions'

        if session_user['id'] == 0:
            return redirectTo('../', request)

        session_response = SessionManager(request).get_session_response()

        filters = {}
        try:
            filters['status'] = request.args.get('status')[0]
        except:
            filters['status'] = 'open'

        try:
            filters['kind'] = request.args.get('kind')[0]
        except:
            filters['kind'] = 'promoter'

        Page = pages.Transactions('%s Transactions' % config.company_name, 'transactions', filters)
        Page.session_user = session_user

        print "%ssession_user: %s%s" % (config.color.BLUE, session_user, config.color.ENDC)
        print "%ssession_response: %s%s" % (config.color.BLUE, session_response, config.color.ENDC)

        SessionManager(request).clearSessionResponse()

        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:32,代码来源:transactions.py


示例9: render

    def render(self, request):

        session_transaction = SessionManager(request).getSessionTransaction()
        #transactionId = session_transaction['id']

        if session_transaction['id'] == 0:
            return redirectTo('../', request)

        #lenderId = session_transaction['lenderId']

        #transaction = db.query(Transaction).filter(Transaction.id == transactionId).first()

        session_user = SessionManager(request).getSessionUser()
        session_user['page'] = 'receipt'

        Page = pages.Receipt('Smart Property Group - Receipt', 'receipt')
        Page.session_user = session_user
        Page.session_transaction = session_transaction

        print "%ssession_user: %s%s" % (config.color.YELLOW, session_user, config.color.ENDC)
        print "%ssession_transaction: %s%s" % (config.color.YELLOW, session_transaction, config.color.ENDC)
        SessionManager(request).clearSessionResponse()

        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:25,代码来源:receipt.py


示例10: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).getSessionUser()

        if session_user['id'] == 0:
            return redirectTo('../', request)

        sessionResponse = SessionManager(request).getSessionResponse()
        sessionProperty = SessionManager(request).getSessionProperty()

        try:
            status = request.args.get('status')[0]
        except:
            status = 'pending'

        Page = pages.Orders('Orders', 'orders', status)
        Page.session_user = session_user

        print "%ssession_user: %s%s" % (config.color.BLUE, session_user, config.color.ENDC)
        print "%ssessionProperty: %s%s" % (config.color.BLUE, sessionProperty, config.color.ENDC)
        print "%ssessionResponse: %s%s" % (config.color.BLUE, sessionResponse, config.color.ENDC)
        SessionManager(request).clearSessionResponse()

        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:26,代码来源:orders.py


示例11: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).getSessionUser()

        if session_user['id'] == 0:
            return redirectTo('../', request)

        sessionResponse = SessionManager(request).getSessionResponse()

        session_user['page'] = 'lend'

        session_transaction = SessionManager(request).getSessionTransaction()

        if not session_transaction.get('amount'):
            session_transaction['amount'] = 1

        session_user['page'] = 'lend'

        Page = pages.Lend('Smart Property Group - Lend', 'lend')
        Page.session_user = session_user
        Page.sessionResponse = sessionResponse
        Page.session_transaction = session_transaction

        print "%ssession_user: %s%s" % (config.color.BLUE, session_user, config.color.ENDC)
        print "%ssessionResponse: %s%s" % (config.color.BLUE, sessionResponse, config.color.ENDC)
        print "%ssession_transaction: %s%s" % (config.color.BLUE, session_transaction, config.color.ENDC)

        SessionManager(request).clearSessionResponse()
        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:31,代码来源:lend.py


示例12: test_simpleFailure

    def test_simpleFailure(self):
        """
        L{renderElement} handles failures by writing a minimal
        error message to the request and finishing it.
        """
        element = FailingElement()

        d = self.request.notifyFinish()

        def check(_):
            flushed = self.flushLoggedErrors(FlattenerError)
            self.assertEqual(len(flushed), 1)
            self.assertEqual(
                "".join(self.request.written),
                ('<!DOCTYPE html>\n'
                 '<div style="font-size:800%;'
                 'background-color:#FFF;'
                 'color:#F00'
                 '">An error occurred while rendering the response.</div>'))
            self.assertTrue(self.request.finished)

        d.addCallback(check)

        self.assertIdentical(NOT_DONE_YET, renderElement(self.request, element))

        return d
开发者ID:Varriount,项目名称:Colliberation,代码行数:26,代码来源:test_template.py


示例13: render_GET

 def render_GET(self, request):
     accept = request.getHeader('Accept')
     if accept is not None and b'application/json' in accept:  # TODO: Implement or obtain correct Accept interpretation
         request.setHeader(b'Content-Type', b'application/json')
         return serialize(self.__describe_block()).encode('utf-8')
     else:
         request.setHeader(b'Content-Type', b'text/html;charset=utf-8')
         return template.renderElement(request, self.__element)
开发者ID:thefinn93,项目名称:shinysdr,代码行数:8,代码来源:export_http.py


示例14: wrapper

    def wrapper(
        self: Any, request: IRequest, *args: Any, **kwargs: Any
    ) -> KleinRenderable:
        response = f(self, request, *args, **kwargs)

        if IRenderable.providedBy(response):
            return renderElement(request, response)

        return response
开发者ID:burningmantech,项目名称:ranger-ims-server,代码行数:9,代码来源:_klein.py


示例15: render

    def render(self, format, kind=None, buffer=None):

        # Variable aliases
        bucket = self.bucket
        df = self.dataframe

        # Compute group name for HDF5 and NetCDF formats
        # TODO: Optionally prefix with "realm" from "bucket.tdata"
        group_name = bucket.title.short

        if format == 'xlsx':
            # http://pandas.pydata.org/pandas-docs/stable/io.html#io-excel-writer
            # https://stackoverflow.com/questions/28058563/write-to-stringio-object-using-pandas-excelwriter
            with pandas.ExcelWriter('temp.xlsx', engine='xlsxwriter') as excel_writer:
                excel_writer.book.filename = buffer
                df.to_excel(excel_writer, sheet_name=bucket.title.compact[:31], index=False)

        elif format in ['hdf', 'hdf5', 'h5']:

            # Create index from "time" column
            df = dataframe_index_and_sort(df, 'time')

            # http://pandas.pydata.org/pandas-docs/stable/io.html#hdf5-pytables
            t = tempfile.NamedTemporaryFile(suffix='.hdf5')
            try:
                df.to_hdf(t.name, group_name, format='table', data_columns=True, index=False)
                buffer.write(t.read())
            except Exception as ex:
                return self.request.error_response(bucket, with_traceback=True)

        elif format in ['nc', 'cdf']:

            # Create index from "time" column
            df = dataframe_index_and_sort(df, 'time')

            # http://xarray.pydata.org/
            # http://xarray.pydata.org/en/stable/io.html#netcdf
            t = tempfile.NamedTemporaryFile(suffix='.nc')
            try:
                #df.to_xarray().to_netcdf(path=t.name, group=group_name)
                #df.to_xarray().to_netcdf(path=t.name, format='NETCDF4', engine='h5netcdf', group=group_name)
                df.to_xarray().to_netcdf(path=t.name, format='NETCDF4', engine='netcdf4', group=group_name)
                buffer.write(t.read())
            except Exception as ex:
                return self.request.error_response(bucket, with_traceback=True)

        elif format in ['dt', 'datatables']:
            # https://datatables.net/

            # Compute data_uri, forward "from" and "to" parameters
            data_uri = get_data_uri(bucket, 'data.html')

            # Render HTML snippet containing DataTable widget
            page = DatatablesPage(data_uri=data_uri, bucket=bucket)
            bucket.request.setHeader('Content-Type', 'text/html; charset=utf-8')
            return renderElement(bucket.request, page)
开发者ID:hiveeyes,项目名称:kotori,代码行数:56,代码来源:tabular.py


示例16: test_noneDoctype

    def test_noneDoctype(self):
        """
        L{renderElement} will not write out a doctype if the doctype keyword
        argument is L{None}.
        """
        element = TestElement()

        d = self.request.notifyFinish()

        def check(_):
            self.assertEqual(
                b"".join(self.request.written),
                b'<p>Hello, world.</p>')

        d.addCallback(check)

        renderElement(self.request, element, doctype=None)

        return d
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:19,代码来源:test_template.py


示例17: render_GET

    def render_GET(self, request):
        applications = []
        for app in self.registry.applications.values():
            link = tags.a(tags.tt(app.name), ' at ', tags.tt(app.path.path),
                          href=app.name)
            applications.append(tags.li(link))

        body = tags.body(
            tags.p('Here are your applications:'),
            tags.ul(*applications))
        return renderElement(request, body)
开发者ID:eevee,项目名称:mamayo,代码行数:11,代码来源:status.py


示例18: render_GET

 def render_GET(self, request):
     body = tags.form(
         tags.label('Tahoe URI', for_='uri'), ' ',
         tags.input(id='uri', type='text', name='uri'),
         tags.br(),
         tags.label('Extension', for_='ext'), ' ',
         tags.input(id='ext', type='text', name='ext'),
         tags.br(),
         tags.input(type='submit', value='Convert to HTTP URL'),
         action='', method='POST')
     return renderElement(request, body)
开发者ID:habnabit,项目名称:pubtahoe,代码行数:11,代码来源:pubtahoe.py


示例19: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).getSessionUser()
        session_user['page'] = 'legal'

        Page = pages.Legal('Legal', 'legal')
        Page.session_user = session_user

        print "%ssession_user: %s%s" % (config.color.YELLOW, session_user, config.color.ENDC)
        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:12,代码来源:legal.py


示例20: render

    def render(self, request):
        print '%srequest.args: %s%s' % (config.color.RED, request.args, config.color.ENDC)

        session_user = SessionManager(request).get_session_user()
        session_user['page'] = 'faq'

        Page = pages.Faq('%s FAQ' % config.company_name, 'faq', {})
        Page.session_user = session_user

        print "%ssession_user: %s%s" % (config.color.YELLOW, session_user, config.color.ENDC)
        request.write('<!DOCTYPE html>\n')
        return renderElement(request, Page)
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:12,代码来源:faq.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python template.Element类代码示例发布时间:2022-05-27
下一篇:
Python template.flattenString函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap