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


Python handlers.COOKIE_NAME属性代码示例

本文整理汇总了Python中handlers.COOKIE_NAME属性的典型用法代码示例。如果您正苦于以下问题:Python handlers.COOKIE_NAME属性的具体用法?Python handlers.COOKIE_NAME怎么用?Python handlers.COOKIE_NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在handlers的用法示例。


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

示例1: auth_factory

# 需要导入模块: import handlers [as 别名]
# 或者: from handlers import COOKIE_NAME [as 别名]
def auth_factory(app, handler):
    @asyncio.coroutine
    def auth(request):
        logging.info('check user: %s %s' % (request.method, request.path))
        request.__user__ = None  # ?????__user__????None
        cookie_str = request.cookies.get(COOKIE_NAME)  # ??cookie?????cookie????COOKIE_NAME??headlers??????
        if cookie_str:
            user = yield from cookie2user(cookie_str)  # ??cookie????????
            if user:
                logging.info('set current user: %s' % user.email)
                request.__user__ = user  # ???????????
        # ???????????????????????????????
        if request.path.startswith('/manage/') and (request.__user__ is None or not request.__user__.admin):
            return web.HTTPFound('/signin')
        return (yield from handler(request))
    return auth

# ????????POST????????? 
开发者ID:ReedSun,项目名称:Preeminent,代码行数:20,代码来源:app.py

示例2: auth_factory

# 需要导入模块: import handlers [as 别名]
# 或者: from handlers import COOKIE_NAME [as 别名]
def auth_factory(app, handler):
    '''
    middleware(???)???cookie?????????
    '''
    async def auth(request):
        logging.info('check user: %s %s' % (request.method, request.path))
        request.__user__ = None
        cookie_str = request.cookies.get(COOKIE_NAME)
        if cookie_str:
            # ??cookie???????????
            user = await cookie2user(cookie_str)
            if user:
                logging.info('set current user:%s' % user.email)
                request.__user__ = user
        if request.path.startswith('/manage/') and (request.__user__ is None or not request.__user__.admin):
            # HTTPFound: Exception->HTTPRedirection->302
            return web.HTTPFound('/signin')
        return (await handler(request)) 
    return auth 
开发者ID:chenpengcong,项目名称:python3-webapp,代码行数:21,代码来源:app.py

示例3: auth_factory

# 需要导入模块: import handlers [as 别名]
# 或者: from handlers import COOKIE_NAME [as 别名]
def auth_factory(app,handler):
	async def auth(request):
		request.__user__ = None
		cookie_str = request.cookies.get(COOKIE_NAME)
		if cookie_str:
			user = await cookie2user(cookie_str)
			if user:
				logging.info('set current user :%s' % user.email)
				request.__user__ = user
		if request.path.startswith('/manage/') and (request.__user__ is None or not request.__user__.admin):
			return web.HTTPFound('/signin')
		return	await handler(request)
	return auth

# ?????? 
开发者ID:syusonn,项目名称:awesome-python3-webapp,代码行数:17,代码来源:app.py

示例4: auth_factory

# 需要导入模块: import handlers [as 别名]
# 或者: from handlers import COOKIE_NAME [as 别名]
def auth_factory(app, handler):
    @asyncio.coroutine
    def auth(request):
        logging.info('check user: {} {}'.format(request.method, request.path))
        request.__user__ = None
        cookie_str = request.cookies.get(COOKIE_NAME)
        if cookie_str:
            user = yield from cookie2user(cookie_str)
            if user:
                logging.info('set current user: {}'.format(user.email))
                request.__user__ = user
        if request.path.startswith('/manage/') and (request.__user__ is None or not request.__user__.admin):
            return web.HTTPFound('/signin')
        return (yield from handler(request))
    return auth 
开发者ID:tianzhenyun,项目名称:python-awesome-web,代码行数:17,代码来源:app.py

示例5: auth_factory

# 需要导入模块: import handlers [as 别名]
# 或者: from handlers import COOKIE_NAME [as 别名]
def auth_factory(app, handler):
	async def auth(request):
		logging.info('check user: %s %s' % (request.method, request.path))
		request.__user__ = None
		cookie_str = request.cookies.get(COOKIE_NAME)
		if cookie_str:
			user = await cookie2user(cookie_str)
			if user:
				logging.info('set current user: %s' % user.email)
				request.__user__ = user
		if request.path.startswith('/manage/') and (request.__user__ is None or not request.__user__.admin):
			return web.HTTPFound('/signin')
		return (await handler(request))
	return auth 
开发者ID:TsangTen,项目名称:awesome-webapp,代码行数:16,代码来源:app.py


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