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

Python util.redirectTo函数代码示例

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

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



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

示例1: 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'] = 'withdraw_bid'

        is_confirmed = request.args.get('is_confirmed')[0]
        if is_confirmed == 'no':
            return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))
        
        try:
            bid_id = int(request.args.get('bid_id')[0])
        except:
            return redirectTo('../', request)
        
        bid = db.query(Bid).filter(Bid.id == bid_id).first()

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

        timestamp = config.create_timestamp()
        
        bid.updated_at = timestamp 
        bid.status = 'withdrawn'

        db.commit()
        return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:27,代码来源:bid.py


示例2: 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'] = 'process_offer'

        response = {'error': True}
        try:
            action = request.args.get('action')[0]
        except:
            return redirectTo('../', request)

        if action == 'complete':
            try:
                offer_id = int(request.args.get('id')[0])
            except:
                return redirectTo('../offers', request)

            response['error'] = False
            response['action'] = action

            response['offer'] = {
                    'id': str(offer_id)
                } 

            return json.dumps(response)
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:25,代码来源:offers.py


示例3: render

    def render(self, request):

        session_user = SessionManager(request).getSessionUser()
        userType = session_user['type']
        if userType != 0:
            return redirectTo('../', request)

        try:
            userId = int(request.args.get('id')[0])
        except:
            return redirectTo('../', request)

        profile = db.query(Profile).filter(Profile.userId == userId).first()
        user = db.query(User).filter(User.id == userId).first()
        store = db.query(Store).filter(Store.ownerId == userId).first()

        jsonUser = {}
        jsonUser['id'] = str(userId)
        jsonUser['email'] = str(user.email)
        jsonUser['first'] = str(profile.first)
        jsonUser['last'] = str(profile.last)
        jsonUser['currencyId'] = str(profile.currencyId)
        jsonUser['unreadCount'] = str(profile.unreadCount)
        jsonUser['bitcoinAddress'] = str(profile.bitcoinAddress)
        jsonUser['type'] = str(user.type)
        jsonUser['loginTimestamp'] = str(user.loginTimestamp)
        jsonUser['isEmailVerified'] = str(user.isEmailVerified)
        jsonUser['createTimestamp'] = str(profile.createTimestamp)
        jsonUser['updateTimestamp'] = str(profile.updateTimestamp)
        jsonUser['receivedSellOrders'] = str(profile.receivedSellOrders)
        jsonUser['receivedBuyOrders'] = str(profile.receivedBuyOrders)
        jsonUser['ip'] = str(user.ip)
        jsonUser['store'] = str(store.name)
        return json.dumps(jsonUser)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:34,代码来源:summaryUsers.py


示例4: content

    def content(self, request, cxt):
        status = self.getStatus(request)

        res = yield self.getAuthz(request).actionAllowed("cleanShutdown",
                                                            request)

        if request.path == '/shutdown':
            if res:
                eventually(status.cleanShutdown)
                yield defer.returnValue(redirectTo("/", request))
                return
            else:
                yield defer.returnValue(
                        redirectTo(path_to_authzfail(request), request))
                return
        elif request.path == '/cancel_shutdown':
            if res:
                eventually(status.cancelCleanShutdown)
                yield defer.returnValue(redirectTo("/", request))
                return
            else:
                yield defer.returnValue(
                        redirectTo(path_to_authzfail(request), request))
                return

        cxt.update(
                shutting_down = status.shuttingDown,
                shutdown_url = request.childLink("shutdown"),
                cancel_shutdown_url = request.childLink("cancel_shutdown"),
                )
        template = request.site.buildbot_service.templates.get_template("root.html")
        yield defer.returnValue(template.render(**cxt))
开发者ID:natebragg,项目名称:buildbot,代码行数:32,代码来源:root.py


示例5: render_POST

    def render_POST(self, request):
	logged = get_user(request)
	if not logged:
		return redirectTo("/", request)
	args = {}
	options = {}
	user_ext = logged.voip_id
        for a in request.args:
            args[a] = request.args[a][0]

	if logged:
		if 'tls' in args and args['tls']:
			options['tls'] = args['tls']
		else:
			options['tls'] = False
		if 'srtp' in args and args['srtp']:
			options['srtp'] = args['srtp']
		else:
			options['srtp'] = False
		options['voicemail'] = args.get('voicemail', False)
		if 'ext' in args and args['ext'] and logged.admin:
			user_ext = args['ext']
		if 'lowquality' in args and args['lowquality']:
			options['codecs'] = ['gsm']
		change_options(user_ext, options)
		return redirectTo('/options/' + user_ext, request)
	return redirectTo('/', request)
开发者ID:hungld,项目名称:rtcheckcalls,代码行数:27,代码来源:options.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'] = 'approve_user'

        try:
            user_id = int(request.args.get('user_id')[0])
        except:
            return redirectTo('../users', request)

        user = db.query(Transaction).filter(Transaction.id == user_id).first()

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

        is_confirmed = request.args.get('is_confirmed')[0]
        if is_confirmed == 'no':
            return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))

        timestamp = config.create_timestamp()
        
        #bid = db.query(Bid).filter(Bid.id == ).first()

        user.updated_at = timestamp 
        user.status = 'approved'
        db.commit()

        return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:29,代码来源:summary_bids.py


示例7: 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'] = 'withdraw_ask'

        is_confirmed = request.args.get('is_confirmed')[0]
        if is_confirmed == 'no':
            return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))
        
        try:
            ask_id = int(request.args.get('ask_id')[0])
        except:
            return redirectTo('../', request)
        
        ask = db.query(Ask).filter(Ask.id == ask_id).first()

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

        timestamp = config.create_timestamp()
        
        ask.updated_at = timestamp 
        ask.status = 'withdrawn'

        client = db.query(Profile).filter(Profile.user_id == session_user['id']).first()
        client.available_balance += ask.cost * (ask.goal - ask.target)
        client.reserved_balance -= ask.cost * (ask.goal - ask.target)

        db.commit()
        return json.dumps(dict(response=1, text=definitions.MESSAGE_SUCCESS))
开发者ID:frontierventures,项目名称:hypewizard.python,代码行数:31,代码来源:ask.py


示例8: checkSession

 def checkSession(authinfo):
     if authinfo.username:
         redirectURL = utils.getRequestArg(request, "_r", sanitize=False) or "/feed/"
         util.redirectTo(urllib.unquote(redirectURL), request)
         request.finish()
     else:
         self._renderSigninForm(request)
开发者ID:psunkari,项目名称:flocked-in,代码行数:7,代码来源:root.py


示例9: render_GET

    def render_GET(self, request):
	res = None
	logged = session.get_user(request)
	if not logged:
		return redirectTo('/', request)
	parts = request.path.split("/")
	if len(parts) > 2 and logged.admin:
		user_ext = parts[2]
	else:
		user_ext = logged.voip_id
	args = {'ext': user_ext, 'lowquality': '', 'tls': '', 'srtp': '', 'voicemail': ''}
	options = get_options(user_ext)
	if 'codecs' in options and 'gsm' in options['codecs']:
		args['lowquality'] = ' checked '
	if options['tls']:
		args['tls'] = ' checked '
	if options['srtp']:
		args['srtp'] = ' checked '
	if options['voicemail']:
		args['voicemail'] = ' checked '
        model = Model()
        user = model.query(User).filter_by(voip_id=user_ext).first()
        if user and (logged.admin or user.id == logged.id):
            args['bitcoin'] = self.render_btc(logged, user, wallet)
        else:
            return redirectTo('/', request)
	content = print_template('options', args)
	return print_template('content-pbx-lorea', {'content': content})
开发者ID:guyt101z,项目名称:rtcheckcalls,代码行数:28,代码来源:options.py


示例10: _saveSessionAndRedirect

    def _saveSessionAndRedirect(self, request, data, remember=False):
        authinfo = yield defer.maybeDeferred(request.getSession,
                                             IAuthInfo, True, remember)
        authinfo.username = data["user"]
        authinfo.organization = data.get("org", None)
        authinfo.isAdmin = True if data.has_key("isAdmin") else False

        yield request._saveSessionToDB()
        redirectURL = utils.getRequestArg(request, "_r", sanitize=False) or "/feed/"
        util.redirectTo(urllib.unquote(redirectURL), request)
        request.finish()
开发者ID:psunkari,项目名称:flocked-in,代码行数:11,代码来源:root.py


示例11: render

    def render(self, request):
        if not request.args:
            return redirectTo('../', request)

        session_user = SessionManager(request).getSessionUser()
        session_user['action'] = 'lend'

        lenderId = session_user['id']

        session_transaction = SessionManager(request).getSessionTransaction()

        btc_amount = request.args.get('btc_loan_amount')[0]

        session_transaction['lenderId'] = lenderId
        session_transaction['amount'] = btc_amount
        bitcoinAddress = explorer.getNewAddress('')['result']

        if error.amount(request, btc_amount):
            return redirectTo('../lend', request)

        btc_amount = float(btc_amount)

        if request.args.get('button')[0] == 'Get Address':
            timestamp = config.createTimestamp()

            data = {
                'status': 'open',
                'createTimestamp': timestamp,
                'updateTimestamp': timestamp,
                'userId': lenderId,
                'amount': btc_amount,
                'bitcoinAddress': bitcoinAddress,
                'statement': '',
                'signature': ''    
                }

            newTransaction = Transaction(data)
            
            db.add(newTransaction)

            db.commit()

            report.createPdf(newTransaction)

            session_transaction['id'] = newTransaction.id
            session_transaction['amount'] = newTransaction.amount
            session_transaction['createTimestamp'] = timestamp
            session_transaction['bitcoinAddress'] = newTransaction.bitcoinAddress
            session_transaction['isSigned'] = 0 

            return redirectTo('../contract', request)
开发者ID:frontierventures,项目名称:smart-properties,代码行数:51,代码来源:lend.py


示例12: render_GET

 def render_GET(self, request):
     error = request.args.get("error", [""])[0]
     code = request.args.get("code", [""])[0]
     if error:
         return str(error)
     elif not code:
         return redirectTo(self.authz.getLoginURL(), request)
     else:
         details = self.verifyCode(code)
         if "xamarin" not in details["groups"]:
             return "no xamarin employee, no power (make sure your membership is public: https://github.com/orgs/xamarin/people)"
         cookie, s = self.authz.sessions.new(details["userName"], details)
         request.addCookie(COOKIE_KEY, cookie, expires=s.getExpiration(), path="/")
         request.received_cookies = {COOKIE_KEY: cookie}
         return redirectTo(self.authz.root_uri, request)
开发者ID:xamarin,项目名称:benchmarker,代码行数:15,代码来源:githuboauth2.py


示例13: content

    def content(self, request, cxt):
        status = self.getStatus(request)

        if request.path == '/shutdown':
            return redirectTo(path_to_authfail(request), request)
        elif request.path == '/cancel_shutdown':
            return redirectTo(path_to_authfail(request), request)

        cxt.update(
                shutting_down = status.shuttingDown,
                shutdown_url = request.childLink("shutdown"),
                cancel_shutdown_url = request.childLink("cancel_shutdown"),
                )
        template = request.site.buildbot_service.templates.get_template("root.html")
        return template.render(**cxt)
开发者ID:alexmos17,项目名称:build_internal,代码行数:15,代码来源:root.py


示例14: content

    def content(self, req, ctx):
        # check for False or True on showUsersPage, redirect immediately
        authz = self.getAuthz(req)
        if not authz.needAuthForm(self.action):
            if authz.advertiseAction(self.action):
                yield redirectTo("users/table", req)
                return
            else:
                yield redirectTo(path_to_authzfail(req), req)
                return

        ctx['authz'] = self.getAuthz(req)
        ctx['table_link'] = req.childLink("table")
        template = req.site.buildbot_service.templates.get_template("users.html")
        yield template.render(**ctx)
开发者ID:Callek,项目名称:buildbot,代码行数:15,代码来源:users.py


示例15: render_GET

 def render_GET(self, request):
     error = request.args.get("error", [""])[0]
     code = request.args.get("code", [""])[0]
     if error:
         return str(error)
     elif not code:
         return redirectTo(self.authz.getLoginURL(), request)
     else:
         details = self.verifyCode(code)
         if not details["email"].split("@")[-1] == "xamarin.com":
             return "no xamarin employee, no power"
         cookie, s = self.authz.sessions.new(details["userName"], details)
         request.addCookie(COOKIE_KEY, cookie, expires=s.getExpiration(), path="/")
         request.received_cookies = {COOKIE_KEY: cookie}
         return redirectTo(self.authz.root_uri, request)
开发者ID:lewurm,项目名称:benchmarker,代码行数:15,代码来源:googleoauth2.py


示例16: flattened

 def flattened(spam):
     # Join the bits to make a complete URL.
     u = ''.join(bits)
     # It might also be relative so resolve it against the current URL
     # and flatten it again.
     u = flat.flatten(URL.fromContext(ctx).click(u), ctx)
     return redirectTo(u, inevow.IRequest(ctx))
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:7,代码来源:url.py


示例17: renderHTTP

	def renderHTTP(self, ctx):
		request = inevow.IRequest(ctx)

		def handle_user_token(result):
			if result[0] == 0:
				self.user_token = str(result[1]['user_token'])
				return self.send_to_qoop(request)
			else:
				return redirectTo("/not_found/", request)

		if request.args.has_key("bonus"):
			self.bonus = request.args['bonus'][0]
			auth_hash = request.getCookie("auth_hash")
			auth_username = self._get_auth_username(ctx)
			auth_userid = self._get_auth_userid(ctx)
			if auth_username:
				d = self.app.api.users.get_user_token(auth_userid, True)
				d.addCallback(handle_user_token)
				return d
			else:
				if request.args.has_key("user_token"):
					self.user_token = request.args['user_token'][0]
					return self.send_to_qoop(request)
				else:
					return zoto_base_page.renderHTTP(self, ctx)
		else:
			return redirectTo("/not_found/", request)
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:27,代码来源:qoop.py


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


示例19: _renderDeferred

    def _renderDeferred(self, checkedRequest):
        """Render this resource asynchronously.

        :type checkedRequest: tuple
        :param checkedRequest: A tuple of ``(bool, request)``, as returned
            from :meth:`checkSolution`.
        """
        try:
            valid, request = checkedRequest
        except Exception as err:
            logging.error("Error in _renderDeferred(): %s" % err)
            return

        logging.debug("Attemping to render %svalid request %r"
                      % ('' if valid else 'in', request))
        if valid is True:
            try:
                rendered = self.resource.render(request)
            except Exception as err:  # pragma: no cover
                rendered = replaceErrorPage(err)
        else:
            logging.info("Client failed a CAPTCHA; redirecting to %s"
                         % request.uri)
            rendered = redirectTo(request.uri, request)

        try:
            request.write(rendered)
            request.finish()
        except Exception as err:  # pragma: no cover
            logging.exception(err)

        return request
开发者ID:gsathya,项目名称:bridgedb,代码行数:32,代码来源:HTTPServer.py


示例20: render_POST

    def render_POST(self, request):
        """Process a client's CAPTCHA solution.

        If the client's CAPTCHA solution is valid (according to
        :meth:`checkSolution`), process and serve their original
        request. Otherwise, redirect them back to a new CAPTCHA page.

        :type request: :api:`twisted.web.http.Request`
        :param request: A ``Request`` object, including POST arguments which
            should include two key/value pairs: one key being
            ``'captcha_challenge_field'``, and the other,
            ``'captcha_response_field'``. These POST arguments should be
            obtained from :meth:`render_GET`.
        :rtype: str
        :returns: A rendered HTML page containing a ReCaptcha challenge image
            for the client to solve.
        """
        request.setHeader("Content-Type", "text/html; charset=utf-8")

        if self.checkSolution(request) is True:
            try:
                rendered = self.resource.render(request)
            except Exception as err:
                rendered = replaceErrorPage(err)
            return rendered

        logging.debug("Client failed a CAPTCHA; returning redirect to %s"
                      % request.uri)
        return redirectTo(request.uri, request)
开发者ID:gsathya,项目名称:bridgedb,代码行数:29,代码来源:HTTPServer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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