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


Python util.redirectTo函数代码示例

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


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


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