本文整理汇总了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))
示例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)
示例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)
示例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))
示例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)
示例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))
示例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))
示例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)
示例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})
示例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()
示例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)
示例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)
示例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)
示例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)
示例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)