本文整理汇总了Python中pyramid.response.Response.location方法的典型用法代码示例。如果您正苦于以下问题:Python Response.location方法的具体用法?Python Response.location怎么用?Python Response.location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.location方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_tgt_target_lun_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_tgt_target_lun_list(request):
iqn = request.matchdict['target_iqn']
tgt_mgr = tgtmgr.TgtManager
target = tgt_mgr.get_target_by_iqn(iqn)
new_lun_conf = get_params_from_request(request, lun_conf_schema)
if "path" not in new_lun_conf:
raise StorLeverError("New LUN's path must be configured", 400)
target.add_lun(new_lun_conf["lun"],
new_lun_conf["path"],
new_lun_conf.get("device_type", "disk"),
new_lun_conf.get("bs_type", "rdwr"),
new_lun_conf.get("direct_map", False),
new_lun_conf.get("write_cache", True),
new_lun_conf.get("readonly", False),
new_lun_conf.get("online", True),
new_lun_conf.get("scsi_id", ""),
new_lun_conf.get("scsi_sn", ""),
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('tgt_target_lun_info',
target_iqn=iqn,
lun_number=new_lun_conf["lun"])
return resp
示例2: toolbar_handler
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def toolbar_handler(request):
root_path = request.route_path("debugtoolbar.root")
request.exc_history = exc_history
remote_addr = request.remote_addr
if request.path.startswith(root_path) or (not remote_addr in hosts):
return handler(request)
toolbar = DebugToolbar(request, panel_classes)
request.debug_toolbar = toolbar
_handler = handler
for panel in toolbar.panels:
_handler = panel.wrap_handler(_handler)
try:
response = _handler(request)
except Exception:
info = sys.exc_info()
if exc_history is not None:
tb = get_traceback(info=info, skip=1, show_hidden_frames=False, ignore_system_exceptions=True)
for frame in tb.frames:
exc_history.frames[frame.id] = frame
exc_history.tracebacks[tb.id] = tb
body = tb.render_full(request, evalex=True).encode("utf-8", "replace")
response = Response(body, status=500)
toolbar.process_response(response)
return response
raise
else:
if intercept_redirects:
# Intercept http redirect codes and display an html page with a
# link to the target.
if response.status_int in redirect_codes:
redirect_to = response.location
redirect_code = response.status_int
if redirect_to:
content = render(
"pyramid_debugtoolbar:templates/redirect.jinja2",
{"redirect_to": redirect_to, "redirect_code": redirect_code},
)
content = content.encode(response.charset)
response.content_length = len(content)
response.location = None
response.app_iter = [content]
response.status_int = 200
toolbar.process_response(response)
return response
finally:
# break circref
del request.debug_toolbar
示例3: add_bond_group
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def add_bond_group(request):
params = get_params_from_request(request, bond_add_schema)
bond_manager = bond.bond_mgr()
bond_name = bond_manager.add_group(params['miimon'], params['mode'], params['ifs'],
params['ip'], params['netmask'], params['gateway'],
request.client_addr)
resp = Response(status=201)
resp.location = request.route_url('bond_port', port_name=bond_name)
return resp
示例4: add_group
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def add_group(request):
group_info = get_params_from_request(request, group_info_schema)
user_mgr = usermgr.user_mgr()
user_mgr.group_add(group_info["name"], group_info.get("gid"),
user=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('group_info', group_name=group_info["name"])
return resp
示例5: post_tgt_target_iqn_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_tgt_target_iqn_list(request):
tgt_mgr = tgtmgr.TgtManager
new_target_conf = get_params_from_request(request, target_conf_schema)
tgt_mgr.create_target(new_target_conf["iqn"], operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('tgt_target_info',
target_iqn=new_target_conf["iqn"])
return resp
示例6: add_user
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def add_user(request):
user_info = get_params_from_request(request, user_info_schema)
user_mgr = usermgr.user_mgr()
user_mgr.user_add(user_info["name"], user_info.get("password"), user_info.get("uid"),
user_info.get("primary_group"), user_info.get("groups"),
user_info.get("home_dir"), user_info.get("login"),
user_info.get("comment"), user=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('user_info', user_name=user_info["name"])
return resp
示例7: post_smb_account_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_smb_account_list(request):
smb_mgr = smbmgr.SmbManager
new_account_conf = get_params_from_request(request, smb_account_schema)
smb_mgr.add_smb_account(new_account_conf["account_name"],
new_account_conf["password"],
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('smb_account_conf',
account_name=new_account_conf["account_name"])
return resp
示例8: post_nfs_export_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_nfs_export_list(request):
nfs_mgr = nfsmgr.NfsManager
new_export_conf = get_params_from_request(request, nfs_export_schema)
nfs_mgr.append_export_conf(new_export_conf["name"],
new_export_conf.get("path", "/"),
new_export_conf.get("clients", []),
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('nfs_export_info',
export_name=new_export_conf["name"])
return resp
示例9: post_ftp_user_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_ftp_user_list(request):
ftp_mgr = ftpmgr.FtpManager
new_user_conf = get_params_from_request(request, ftp_user_schema)
ftp_mgr.add_user_conf(new_user_conf["user_name"],
new_user_conf.get("login_enable", False),
new_user_conf.get("chroot_enable", False),
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('ftp_user_conf',
user_name=new_user_conf["user_name"])
return resp
示例10: post_snmp_agent_monitor_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_snmp_agent_monitor_list(request):
snmp_agent = snmpagent.SnmpAgentManager
new_monitor_conf = get_params_from_request(request, snmp_monitor_new_schema)
snmp_agent.add_monitor_conf(new_monitor_conf["monitor_name"],
new_monitor_conf["expression"],
new_monitor_conf["option"],
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('snmp_agent_monitor_info',
monitor_name=new_monitor_conf["monitor_name"])
return resp
示例11: post_tgt_target_outgoinguser_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_tgt_target_outgoinguser_list(request):
iqn = request.matchdict['target_iqn']
tgt_mgr = tgtmgr.TgtManager
target = tgt_mgr.get_target_by_iqn(iqn)
new_user_conf = get_params_from_request(request, user_conf_schema)
target.set_outgoinguser(new_user_conf["username"], new_user_conf["password"], operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('tgt_target_outgoinguser_info',
target_iqn=iqn,
user_name=new_user_conf["username"])
return resp
示例12: post_snmp_agent_community_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_snmp_agent_community_list(request):
snmp_agent = snmpagent.SnmpAgentManager
new_community_conf = get_params_from_request(request, snmp_community_schema)
snmp_agent.add_community_conf(new_community_conf["community_name"],
new_community_conf.get("ipv6", False),
new_community_conf.get("source", ""),
new_community_conf.get("oid", ""),
new_community_conf.get("read_only", False),
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('snmp_agent_community_info',
community_name=new_community_conf["community_name"])
return resp
示例13: post_smb_share_list
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def post_smb_share_list(request):
smb_mgr = smbmgr.SmbManager
new_share_conf = get_params_from_request(request, smb_share_schema)
smb_mgr.add_share_conf(new_share_conf["share_name"],
new_share_conf.get("path", ""),
new_share_conf.get("comment", ""),
new_share_conf.get("create_mask", 0744),
new_share_conf.get("directory_mask", 0755),
new_share_conf.get("guest_ok", False),
new_share_conf.get("read_only", True),
new_share_conf.get("browseable", True),
new_share_conf.get("force_create_mode", 0),
new_share_conf.get("force_directory_mode", 0),
new_share_conf.get("valid_users", ""),
new_share_conf.get("write_list", ""),
new_share_conf.get("veto_files", ""),
operator=request.client_addr)
# generate 201 response
resp = Response(status=201)
resp.location = request.route_url('smb_share_conf',
share_name=new_share_conf["share_name"])
return resp
示例14: toolbar_tween
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def toolbar_tween(request):
root_path = request.route_path(ROOT_ROUTE_NAME)
request.exc_history = exc_history
remote_addr = request.remote_addr
if remote_addr is None or request.path.startswith(root_path):
return handler(request)
else:
for host in hosts:
if ipaddr.IPAddress(remote_addr) in ipaddr.IPNetwork(host):
break
else:
return handler(request)
toolbar = DebugToolbar(request, panel_classes)
request.debug_toolbar = toolbar
_handler = handler
for panel in toolbar.panels:
_handler = panel.wrap_handler(_handler)
try:
response = _handler(request)
except Exception:
if exc_history is not None:
tb = get_traceback(info=sys.exc_info(),
skip=1,
show_hidden_frames=False,
ignore_system_exceptions=True)
for frame in tb.frames:
exc_history.frames[frame.id] = frame
exc_history.tracebacks[tb.id] = tb
body = tb.render_full(request).encode('utf-8', 'replace')
response = Response(body, status=500)
toolbar.process_response(response)
qs = {'token':exc_history.token, 'tb':str(tb.id)}
msg = 'Exception at %s\ntraceback url: %s'
exc_url = request.route_url(EXC_ROUTE_NAME, _query=qs)
exc_msg = msg % (request.url, exc_url)
logger.exception(exc_msg)
return response
else:
logger.exception('Exception at %s' % request.url)
raise
else:
if intercept_redirects:
# Intercept http redirect codes and display an html page with a
# link to the target.
if response.status_int in redirect_codes:
redirect_to = response.location
redirect_code = response.status_int
if redirect_to:
content = render(
'pyramid_debugtoolbar:templates/redirect.dbtmako',
{'redirect_to': redirect_to,
'redirect_code': redirect_code},
request=request)
content = content.encode(response.charset)
response.content_length = len(content)
response.location = None
response.app_iter = [content]
response.status_int = 200
toolbar.process_response(response)
return response
finally:
# break circref
del request.debug_toolbar
示例15: toolbar_tween
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import location [as 别名]
def toolbar_tween(request):
root_path = request.route_path(ROOT_ROUTE_NAME)
exclude = [root_path] + exclude_prefixes
request.exc_history = exc_history
last_proxy_addr = None
try:
p = request.path
except UnicodeDecodeError as e:
raise URLDecodeError(e.encoding, e.object, e.start, e.end, e.reason)
starts_with_excluded = list(filter(None, map(p.startswith, exclude)))
if request.remote_addr:
last_proxy_addr = last_proxy(request.remote_addr)
if last_proxy_addr is None \
or starts_with_excluded \
or not addr_in(last_proxy_addr, hosts) \
or auth_check and not auth_check(request):
return handler(request)
toolbar = DebugToolbar(request, panel_classes)
request.debug_toolbar = toolbar
_handler = handler
for panel in toolbar.panels:
_handler = panel.wrap_handler(_handler)
try:
response = _handler(request)
except Exception:
if exc_history is not None:
tb = get_traceback(info=sys.exc_info(),
skip=1,
show_hidden_frames=False,
ignore_system_exceptions=True)
for frame in tb.frames:
exc_history.frames[frame.id] = frame
exc_history.tracebacks[tb.id] = tb
body = tb.render_full(request).encode('utf-8', 'replace')
response = Response(body, status=500)
toolbar.process_response(response)
qs = {'token': exc_history.token, 'tb': str(tb.id)}
msg = 'Exception at %s\ntraceback url: %s'
exc_url = request.route_url(EXC_ROUTE_NAME, _query=qs)
exc_msg = msg % (request.url, exc_url)
logger.exception(exc_msg)
return response
else:
logger.exception('Exception at %s' % request.url)
raise
else:
if intercept_redirects:
# Intercept http redirect codes and display an html page with a
# link to the target.
if response.status_int in redirect_codes:
redirect_to = response.location
redirect_code = response.status_int
if redirect_to:
content = render(
'pyramid_debugtoolbar:templates/redirect.dbtmako',
{'redirect_to': redirect_to,
'redirect_code': redirect_code},
request=request)
content = content.encode(response.charset)
response.content_length = len(content)
response.location = None
response.app_iter = [content]
response.status_int = 200
if not show_on_exc_only:
toolbar.process_response(response)
return response
finally:
# break circref
del request.debug_toolbar