本文整理匯總了Python中libs.base_handler.BaseHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python base_handler.BaseHandler方法的具體用法?Python base_handler.BaseHandler怎麽用?Python base_handler.BaseHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類libs.base_handler
的用法示例。
在下文中一共展示了base_handler.BaseHandler方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from libs import base_handler [as 別名]
# 或者: from libs.base_handler import BaseHandler [as 別名]
def get(self, *args, **kwargs):
page_data, component_data = {'all': False}, {'all': False}
with DBContext('r') as session:
if self.request_is_superuser:
components_info = session.query(Components.component_name).filter(Components.status == '0').all()
page_data['all'] = True
for msg in components_info: component_data[msg[0]] = True
else:
this_menus = session.query(Menus.menu_name).outerjoin(RoleMenus,
Menus.menu_id == RoleMenus.menu_id).outerjoin(
UserRoles, RoleMenus.role_id == UserRoles.role_id).filter(UserRoles.user_id == self.request_user_id,
UserRoles.status == '0',
Menus.status == '0').all()
this_components = session.query(Components.component_name).outerjoin(RolesComponents,
Components.comp_id == RolesComponents.comp_id
).outerjoin(
UserRoles, RolesComponents.role_id == UserRoles.role_id).filter(
UserRoles.user_id == self.request_user_id, UserRoles.status == '0', Components.status == '0').all()
for p in this_menus: page_data[p[0]] = True
for c in this_components: component_data[c[0]] = True
data = dict(rules=dict(page=page_data, component=component_data))
return self.write(dict(data=data, code=0, msg='獲取前端權限成功'))
# class AuthorizationHandler(BaseHandler):
# def get(self, *args, **kwargs):
# user_id = self.get_current_id()
#
# redis_conn = cache_conn()
# page = redis_conn.hget("{}_rules".format(user_id), 'page')
# component = redis_conn.hget("{}_rules".format(user_id), 'component')
#
# data = dict(rules=dict(page=literal_eval(convert(page)), component=literal_eval(convert(component))))
# return self.write(dict(data=data, code=0, msg='獲取前端權限成功'))