本文整理汇总了Python中pyramid.security.forget方法的典型用法代码示例。如果您正苦于以下问题:Python security.forget方法的具体用法?Python security.forget怎么用?Python security.forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.security
的用法示例。
在下文中一共展示了security.forget方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: logout_cookie_view
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def logout_cookie_view(request):
headers = forget(request)
return Response(status=200, headers=headers, body="OK")
示例2: logout_view
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def logout_view(request):
headers = forget(request)
return HTTPFound(location='/', headers=headers)
示例3: logout
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def logout(self):
next = self._query_params.get('next')
headers = forget(self.request)
if next:
return JHTTPFound(location=next, headers=headers)
return JHTTPOk('Logged out', headers=headers)
示例4: admin_sign_out
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def admin_sign_out(self):
headers = forget(self.request)
url = self.request.route_url("admin_action", action="sign_in")
return HTTPFound(url, headers=headers)
示例5: _check_tarif_control
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def _check_tarif_control(request, company):
"""check the possibility to make request from current IP
"""
if not get_tarifs():
return
ip_limit = cast_int(company.settings.get('tarif_limit'))
if not ip_limit:
return
ips = company.settings.get('tarif_ips', [])
new_ips = []
timeout = get_tarifs_timeout()
ip_already_in = False
dt_format = '%Y-%m-%dT%H:%M:%S'
for ip, last_activity in ips:
last_activity = datetime.strptime(last_activity, dt_format)
if (
(last_activity + timedelta(seconds=timeout)) <= datetime.now()
and ip != request.client_addr
):
continue
elif ip == request.client_addr:
new_ips.append((ip, datetime.now().strftime(dt_format)))
ip_already_in = True
else:
new_ips.append((ip, last_activity.strftime(dt_format)))
if len(new_ips) >= ip_limit and not ip_already_in:
log.error(_(u'IP limit exceeded'))
redirect_url = request.resource_url(Root(request))
raise HTTPFound(location=redirect_url, headers=forget(request))
if not ip_already_in:
new_ips.append(
(request.client_addr, datetime.now().strftime(dt_format))
)
settings = copy.copy(company.settings)
settings['tarif_ips'] = new_ips
company.settings = settings
示例6: company_settings
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def company_settings(event):
request = event.request
employee = get_auth_employee(request)
if not employee:
_company_settings(request, get_company())
return
structure = get_employee_structure(employee)
if not structure:
redirect_url = request.resource_url(Root(request))
raise HTTPFound(location=redirect_url, headers=forget(request))
_check_tarif_control(request, structure.company)
_company_settings(request, structure.company)
示例7: logout
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def logout(request):
security.forget(request)
request.session.invalidate()
return HTTPFound(location=request.route_url('index'))
示例8: update
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def update(self):
self.execute(None)
headers = forget(self.request)
return HTTPFound(location = self.request.resource_url(
self.request.context),
headers = headers)
示例9: logout
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def logout(context, request):
headers = forget(request)
data = {
'status': True
}
return Response(json=data, status=200, headerlist=headers)
示例10: render
# 需要导入模块: from pyramid import security [as 别名]
# 或者: from pyramid.security import forget [as 别名]
def render(self):
return HTTPFound(location=route_url('index', self.request),
headers=forget(self.request))