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

Python renderers.render_to_response函数代码示例

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

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



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

示例1: sample16

def sample16(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    inputFile = request.POST.get('file')
    url = request.POST.get('url')
    basePath = request.POST.get('basePath')
    fileId = request.POST.get('fileId')
    guid = None
    iframe = None
    # Checking required parameters
    if not clientId or not privateKey:
        return render_to_response('__main__:templates/sample16.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage object
    api = StorageApi(apiClient)
    if not basePath:
        basePath = 'https://api.groupdocs.com/v2.0'
        #Set base path
    api.basePath = basePath
    if url:
        try:
            # Upload file to current user storage using entered URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = None
        except Exception, e:
            return render_to_response('__main__:templates/sample16.pt',
                                      dict(error=str(e)))
开发者ID:groupdocs-total,项目名称:groupdocs-python,代码行数:35,代码来源:sample16.py


示例2: sample15

def sample15(request):
    clientId = request.POST.get("client_id")
    privateKey = request.POST.get("private_key")

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response("__main__:templates/sample15.pt", {"error": "You do not enter all parameters"})

    ### Create Signer, ApiClient, StorageApi and Document Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create DocApi object
    doc = DocApi(apiClient)

    # set total views
    views = 0

    try:
        # Make a request to Document API
        response = doc.GetDocumentViews(clientId)
        if response.status == "Ok":
            views = len(response.result.views)

    except Exception, e:
        return render_to_response("__main__:templates/sample15.pt", {"error": str(e)})
开发者ID:jamesgmorgan,项目名称:groupdocs-python,代码行数:28,代码来源:sample15.py


示例3: read_one_public

def read_one_public(request):
    """
    Read one Stakeholder based on ID and return all versions of this
    Stakeholder. Do not return any pending versions.
    Default output format: JSON
    """

    try:
        output_format = request.matchdict['output']
    except KeyError:
        output_format = 'json'

    uid = request.matchdict.get('uid', None)
    if check_valid_uuid(uid) is not True:
        raise HTTPNotFound()

    if output_format == 'json':
        stakeholders = stakeholder_protocol3.read_one(request, uid=uid,
            public=True)
        return render_to_response('json', stakeholders, request)
    elif output_format == 'html':
        #@TODO
        return render_to_response('json', {'HTML': 'Coming soon'}, request)
    else:
        # If the output format was not found, raise 404 error
        raise HTTPNotFound()
开发者ID:sinnwerkstatt,项目名称:lokp,代码行数:26,代码来源:stakeholders.py


示例4: sample13

def sample13(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    fileGuId = request.POST.get('fileId')
    email = request.POST.get('email')

    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(fileGuId) == False or IsNotNull(email) == False:
        return render_to_response('__main__:templates/sample13.pt',
                { 'error' : 'You do not enter all parameters' })

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Annotation object
    ant = AntApi(apiClient)

    try:
        # Make a request to Annotation API
        ant.SetAnnotationCollaborators(clientId, fileGuId, "v2.0", body=[email])

    except Exception, e:
        return render_to_response('__main__:templates/sample13.pt',
                { 'error' : str(e) })
开发者ID:liosha2007,项目名称:temporary-groupdocs-python-sdk,代码行数:27,代码来源:sample13.py


示例5: test_registerTemplateRenderer_explicitrenderer

 def test_registerTemplateRenderer_explicitrenderer(self):
     from pyramid import testing
     def renderer(kw, system):
         self.assertEqual(kw, {'foo':1, 'bar':2})
     renderer = testing.registerTemplateRenderer('templates/foo', renderer)
     from pyramid.renderers import render_to_response
     render_to_response('templates/foo', dict(foo=1, bar=2))
开发者ID:SMFOSS,项目名称:pyramid,代码行数:7,代码来源:test_testing.py


示例6: sample12

def sample12(request):
    clientId = request.POST.get('clientId')
    privateKey = request.POST.get('privateKey')
    fileGuId = request.POST.get('fileId')

    # Checking required parameters
    if not clientId or not privateKey or not fileGuId:
        return render_to_response('__main__:templates/sample12.pt',
                                  dict(error='You do not enter all parameters'))

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Annotation object
    ant = AntApi(apiClient)

    try:
        # Make a request to Annotation API using clientId and fileGuId
        response = ant.ListAnnotations(clientId, fileGuId)
    except Exception, e:
        return render_to_response('__main__:templates/sample12.pt',
                                  dict(error=str(e)))
开发者ID:groupdocs-total,项目名称:groupdocs-python,代码行数:25,代码来源:sample12.py


示例7: render_page

 def render_page(self, section, redirpath, values=None):
     if self.endpath is None:
         return HTTPFound(
             location=route_url(
                 'subsections',
                 self.request,
                 action=section,
                 endpath='/'.join(redirpath)
             ))
     self.c.active_footer_nav = '-'.join(
         [self.request.matchdict.get('action')]
         +list(self.endpath))
     for ext in ('.mako', '.rst'):
         tmpl_path = ('templates/pages/%s/%s%s' % (
             section,
             '/'.join(self.endpath),
             ext))
         values = values or {}
         if pkg_resources.resource_exists('pylonshq', tmpl_path):
             if ext == '.mako':
                 return render_to_response(
                     'pylonshq:%s' % tmpl_path, values, self.request)
             else:
                 self.c.pagename = ' : '.join(
                     [item.replace('-', ' ').title() for item in self.endpath])
                 content = pkg_resources.resource_string(
                     'pylonshq',
                     tmpl_path)
                 body = publish_parts(
                     content,
                     writer_name='html')['html_body']
                 values={'body':body}
                 return render_to_response(
                     'pylonshq:templates/rst.mako', values, self.request)
     raise NotFound()
开发者ID:fero14041,项目名称:pylonshq,代码行数:35,代码来源:pages.py


示例8: login_form_process

    def login_form_process(self):
        """Process login form.
        Render form if attempt_authorize was failed
        and redirect to root '/' of site.
        Return form in 'form' key.
        
        @todo redirect to request_from url
        @todo process csrf value"""
        schema = AuthSchema()
        form = Form(schema, buttons=('submit',))
        if 'submit' in self.request.POST:
            controls = self.request.POST.items()
            values = None
            try:
                appstruct = form.validate(controls)
            except ValidationFailure, e:
                return render_to_response(
                    'templates/auth_form.jinja2',
                    {'form': e.render()}
                )

            # make here call of attempt_login
            if self.user_helper.attempt_authorize(
                appstruct['login'],
                appstruct['password']):
                remember(self.request, appsctruct['login'])
                return HTTPFound("/")
            else:
                return render_to_response(
                    'templates/auth_form.jinja2',
                    {'form':form.render(appstruct=appstruct)}
                )

            return HTTPFound('/')
开发者ID:sakal,项目名称:pyramid-watchshop,代码行数:34,代码来源:views.py


示例9: sample32

def sample32(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    formGuid = request.POST.get('form_guid')
    templateGuid = request.POST.get('template_guid')
    callbackUrl = request.POST.get('callbackUrl')
    basePath = request.POST.get('server_type')
    email = request.POST.get('email')
    message = ""
    # Checking clientId, privateKey and file_Id
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample32.pt',
                                  { 'error' : 'You do not enter all parameters' })

    #Get curent work directory
    currentDir = os.path.dirname(os.path.realpath(__file__))
    #Create text file
    fp = open(currentDir + '/../user_info.txt', 'w')
    #Write user info to text file
    fp.write(clientId + "\r\n" + privateKey + "\r\n" + email)
    fp.close()
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Storage Api object
    signatureApi = SignatureApi(apiClient)
    #Set base Path
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
    signatureApi.basePath = basePath
    #Create webHook and set callback URL
    webHook = WebhookInfo()
    webHook.callbackUrl = callbackUrl
    ####Make a request to Signature API using clientId
    if formGuid != "":
        try:
            #Post form by entered form GUID
            postForm = signatureApi.PublishSignatureForm(clientId, formGuid, body=webHook)
            if postForm.status == "Ok":
                message = '<font color="green">Form is published successfully</font>'
                #Generate iframe url
                if basePath == "https://api.groupdocs.com/v2.0":
                    iframe = 'https://apps.groupdocs.com/signature2/forms/signembed/' + formGuid
                #iframe to dev server
                elif basePath == "https://dev-api.groupdocs.com/v2.0":
                    iframe = 'https://dev-apps.groupdocs.com/signature2/forms/signembed/' + formGuid
                #iframe to test server
                elif basePath == "https://stage-apps-groupdocs.dynabic.com/v2.0":
                    iframe = 'https://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/' + formGuid
                elif basePath == "http://realtime-api.groupdocs.com":
                    iframe = 'https://relatime-apps.groupdocs.com/signature2/forms/signembed/' + formGuid
                iframe = signer.signUrl(iframe)
            else:
                raise Exception(postForm.error_message)
        except Exception, e:
            return render_to_response('__main__:templates/sample32.pt',
                { 'error' : str(e) })
开发者ID:jamesgmorgan,项目名称:groupdocs-python,代码行数:60,代码来源:sample32.py


示例10: view

def view(request):
    project = get_selected_project(request)

    error_id = request.matchdict['id']
    try:
        error = Error.objects(project=project.token, id=error_id).get()
    except:
        return HTTPNotFound()

    error.mark_seen(request.user)
    error.save()

    instances = ErrorInstance.objects(hash=error.hash)[:10]

    params = {
        'error': error,
        'selected_project': project,
        'available_projects': Project.objects(),
        'instances': instances,
        'github': GithubLinker(project.github)
    }

    try:
        template = 'error-view/' + str(error['language']).lower() + '.html'
        return render_to_response(template, params)
    except:
        template = 'error-view/generic.html'
        return render_to_response(template, params)
开发者ID:arthens,项目名称:triage,代码行数:28,代码来源:error.py


示例11: index

def index(request):
    if request.method == "POST" and 'username' in request.cookies:
        username = request.cookies['username']
        # TODO process request
        wishlist = []
        for key,value in request.POST.items():
            if key.startswith("wish-"):
                wishlist.append(NAME2WISH[key[5:]])
                print("wish={}, value={}".format(key[5:], value))
        
        special = request.params["special"]
        bequick = request.params["bequick"]
        
        print(u"special={}, be quick={}".format(special,bequick))
        
        order = Order(username,request.remote_addr,wishlist,special,bequick)
        ORDERS[order.id] = order
        return HTTPFound(location = "/confirm/{}".format(order.id))
    else:
        if 'username' in request.cookies:
            username = request.cookies['username']
            response = render_to_response("pt/index.pt", { "username" : username, "wishbar" : WISHBAR }, request)
            response.set_cookie('username', value=username, max_age=86400)
            return response
        else:
            return render_to_response('pt/login.pt', {}, request)
开发者ID:Vasilui,项目名称:wishbar,代码行数:26,代码来源:views.py


示例12: sample03

def sample03(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    inputFile = request.POST.get('file')
    # Checking clientId and privateKey
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response('__main__:templates/sample03.pt',
                                  { 'error' : 'You do not enter your User Id or Private Key' })
####Create Signer, ApiClient and Storage Api objects

#Create signer object
    signer = GroupDocsRequestSigner(privateKey)
#Create apiClient object
    apiClient = ApiClient(signer)
#Create Storage Api object
    api = StorageApi(apiClient)

    try:
        #A hack to get uploaded file size
        inputFile.file.seek(0, 2)
        fileSize = inputFile.file.tell()
        inputFile.file.seek(0)
        
        fs = FileStream.fromStream(inputFile.file, fileSize)
        ####Make a request to Storage API using clientId

        #Upload file to current user storage
        response = api.Upload(clientId, inputFile.filename, fs)
        #Generation of Embeded Viewer URL with uploaded file GuId
        iframe = '<iframe src="https://apps.groupdocs.com/document-viewer/embed/' + response.result.guid + '" frameborder="0" width="720" height="600""></iframe>'
        message = '<p>File was uploaded to GroupDocs. Here you can see your <strong>' + inputFile.filename + '</strong> file in the GroupDocs Embedded Viewer.</p>'
    except Exception, e:
        return render_to_response('__main__:templates/sample03.pt',
                                  { 'error' : str(e) })
开发者ID:liosha2007,项目名称:temporary-groupdocs-python-sdk,代码行数:34,代码来源:sample03.py


示例13: notallowed

def notallowed(request):
    auth_userid = authenticated_userid(request)
    if auth_userid is None:
        login = LoginView(request)
        if request.method == 'POST':
            # Process the login form and redirect
            view_method = login.post
        else:
            # User is not logged in, render the login form
            view_method = login.get
        response = view_method()
        # We need to commit the transaction, so that details about
        # the forbidden view can be written to the database
        transaction.commit()
        if isinstance(response, Response):
            return response
        else:
            return render_to_response("speak_friend:templates/login.pt",
                                      response,
                                      request=request)
    else:
        # If the user is logged in, they don't have permission
        return render_to_response("speak_friend:templates/403_template.pt",
                                  {},
                                  request=request)
开发者ID:sixfeetup,项目名称:speak_friend,代码行数:25,代码来源:error.py


示例14: model

    def model(self, request):
        """
        The method which is used by the api to deliver a machine readable and serializable description of the underlying
        database table/model.

        :param request: The request which comes all the way through the application from the client
        :type request: pyramid.request.Request
        :param session: The session which is uesed to emit the query.
        :type session: sqlalchemy.orm.Session
        :return: An pyramid response object
        :rtype: pyramid.response.Response
        :raises: HTTPNotFound
        """
        response_format = request.matchdict['format']
        if response_format == 'json':
            return render_to_response(
                'model_restful_json',
                self.model_description,
                request=request
            )
        elif response_format == 'xml':
            return render_to_response(
                'model_restful_xml',
                self.model_description,
                request=request
            )
        else:
            text = 'The Format "{format}" is not defined for this service. Sorry...'.format(
                format=response_format
            )
            log.error(text)
            raise HTTPNotFound(
                detail=text
            )
开发者ID:vvmruder,项目名称:pyramid_rest,代码行数:34,代码来源:rest.py


示例15: picked

def picked(request):
    g = request.registry.settings.get('graph')
    action = request.matchdict.get('action')
    format_ = request.matchdict.get('format_')

    def pickedgraph():
        graph = rdflib.Graph()
        for x in request.session["picked"]:
            graph += g.triples((x, None, None))
            graph += g.triples((None, None, x))
        return graph

    if action == 'download':
        return serialize(pickedgraph(), format_)
    elif action == 'rdfgraph':
        return graphrdf(pickedgraph(), format_)
    elif action == 'rdfsgraph':
        return graphrdfs(pickedgraph(), format_)
    elif action == 'clear':
        request.session["picked"] = set()
        return render_to_response(
            "picked.jinja2", dict(things=[]), request)
    else:
        things = [resolve(x) for x in request.session["picked"]]
        return render_to_response(
            "picked.jinja2", dict(things=things), request)
开发者ID:gjhiggins,项目名称:pyralod,代码行数:26,代码来源:lod.py


示例16: payment_view

def payment_view(request):
    echeck = False
    if 'token' in request.params: # paypal return
        token = request.params['token']
        order = DBSession.query(Order).filter(Order.paypal_token==token).one()
        paypal = _get_paypal(request.registry.settings)
        try:
            result = paypal.get_express_checkout_details(token=token)
            payerid = result['PAYERID']
            result = paypal.do_express_checkout_payment(token=token, payerid=payerid,
                PAYMENTACTION='SALE',
                PAYMENTREQUEST_0_PAYMENTACTION='SALE',
                PAYMENTREQUEST_0_AMT=str(order.total)
                )
            status = result['PAYMENTINFO_0_PAYMENTSTATUS']
            if  status == 'Completed':
                order.confirm()
            elif status == 'Pending' and result['PAYMENTINFO_0_PAYMENTTYPE'] == 'echeck':
                order.paypal_transaction = result['PAYMENTINFO_0_TRANSACTIONID']
                echeck = True
            else:
                log.warn(str(result))
                return render_to_response('templates/error.pt',
                    {'message': 'PayPal returns: ' + str(result), 'url': request.application_url})
        except PayPalAPIResponseError, e:
            return render_to_response('templates/error.pt',
                {'message': str(e), 'url': request.application_url})
开发者ID:igudym,项目名称:webstore,代码行数:27,代码来源:views.py


示例17: sample16

def sample16(request):
    clientId = request.POST.get("client_id")
    privateKey = request.POST.get("private_key")
    inputFile = request.POST.get("file")
    url = request.POST.get("url")
    basePath = request.POST.get("server_type")
    fileId = request.POST.get("fileId")
    guid = ""
    iframe = ""
    # Checking required parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False:
        return render_to_response("__main__:templates/sample16.pt", {"error": "You do not enter all parameters"})

    ### Create Signer, ApiClient and Annotation Api objects

    # Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    # Create apiClient object
    apiClient = ApiClient(signer)
    # Create Storage object
    api = StorageApi(apiClient)
    if basePath == "":
        basePath = "https://api.groupdocs.com/v2.0"
        # Set base path
    api.basePath = basePath
    if url != "":
        try:
            # Upload file to current user storage using entere URl to the file
            upload = api.UploadWeb(clientId, url)
            guid = upload.result.guid
            fileId = ""
        except Exception, e:
            return render_to_response("__main__:templates/sample16.pt", {"error": str(e)})
开发者ID:jamesgmorgan,项目名称:groupdocs-python,代码行数:33,代码来源:sample16.py


示例18: sample08

def sample08(request):
    clientId = request.POST.get('client_id')
    privateKey = request.POST.get('private_key')
    fileGuId = request.POST.get('fileId')
    pageNumber = request.POST.get('pageNumber') or 0
    #Checking parameters
    if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(fileGuId) == False:
        return render_to_response('__main__:templates/sample08.pt',
                                  { 'error' : 'You do not enter all parameters' })
    ####Create Signer, ApiClient and Storage Api objects

    #Create signer object
    signer = GroupDocsRequestSigner(privateKey)
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create DocApi object
    docApi = DocApi(apiClient)
    ####Make request to DocApi using user id


    try:
        #Obtaining URl of entered page
        url = docApi.GetDocumentPagesImageUrls(clientId, fileGuId, firstPage = int(pageNumber), pageCount = 1, dimension = '600x750')
    except Exception, e:
        return render_to_response('__main__:templates/sample08.pt',
                                  { 'error' : str(e) })
开发者ID:liosha2007,项目名称:temporary-groupdocs-python-sdk,代码行数:26,代码来源:sample08.py


示例19: error_view

def error_view(exc, request, default_message, status=None,
               outstanding_principals=None, renderer='error.mako'):

    # Preserve a previously set status code unless specifically overridden
    if request.response.status != '200 OK':
        status = status or request.response.status
    else:
        status = status or getattr(exc, 'status', None) or 500

    request.response.status = status

    if len(exc.args) and exc.args[0]:
        message = exc.args[0]
    else:
        message = default_message

    data = {
        'http_status': status,
        'message': message,
        'outstanding_principals': outstanding_principals,
    }

    if not renderer:
        return data
    elif request.is_xhr:
        return render_to_response('json', data, request)
    return render_to_response(renderer, data, request)
开发者ID:eevee,项目名称:floof,代码行数:27,代码来源:errors.py


示例20: sample26

def sample26(request):
    login = request.POST.get('login')
    password = request.POST.get('password')

    if not login or not password:
        return render_to_response('__main__:templates/sample26.pt',
                                  dict(error='You do not enter you login or password'))
    ####Create Signer, ApiClient and Shared Api objects

    #Create signer object
    signer = GroupDocsRequestSigner("123")
    #Create apiClient object
    apiClient = ApiClient(signer)
    #Create Management Api object
    api = SharedApi(apiClient)
    #Encode unicode to str
    encodedPassword = password.encode('utf-8')

    try:
    ####Make a request to Management API using clientId
        userInfo = api.LoginUser(login, encodedPassword)

    except Exception, e:
        return render_to_response('__main__:templates/sample26.pt',
                                  {'error': str(e)})
开发者ID:groupdocs-total,项目名称:groupdocs-python,代码行数:25,代码来源:sample26.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python renderers.JSON类代码示例发布时间:2022-05-27
下一篇:
Python renderers.render函数代码示例发布时间: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