Пример #1
0
	def checkAuthority(self):
		"""
		验证用户权限
		"""
		Logger.info('AuthorityManagement.checkAuthority begin');
		
		# 判断当前浏览的页面是否需要登陆
		exception = None
		if DBAuthority.checkUrl(web.ctx.path):
			Logger.info("访问的路径[%s]是受权限保护路径" % str(web.ctx.path))
			# 判断用户权限是否可以浏览页面
			
			# 判断用户登录
			from webapp.Common import Common
			if Common.session.userInfo == None:
				exception = Exception(u"用户没有登录")
			else:
				userInfo = Common.session.userInfo
				# 判断浏览权限
				if DBAuthority.checkUserUrl(userInfo.userName, str(web.ctx.path)):
					pass;
				else:
					exception = Exception(u"没有权限浏览网页")
					
		else:
			Logger.info("访问的路径[%s]" % str(web.ctx.path))
		
		if exception == None:
			return
		else:
			Common.session.exception = exception;
			raise exception
		
		Logger.info('AuthorityManagement.checkAuthority end');
Пример #2
0
	def updateAuthority(self, authorityId, text, menuIdList):
		DBConn().begin();
		try:
			DBAuthority.deleteByAuthorityId(authorityId)
			DBAuthority.insrt(text, authorityId, menuIdList)
			DBConn().commit(); 
		except Exception, e:
			print e
			DBConn().rollback();
Пример #3
0
	def initMenu(self, userName):
		"""
		初始化菜单项目
		"""
		Logger.info('MenuManagement.initMenu begin');
		self.menuList = []
		# 获取所有菜单项目
		menu = DBAuthority.selectMenu(userName)
		for subMenu in menu:
			# 查找子菜单所属的主菜单
			flg=True
			for menu in self.menuList:
				if subMenu["parentId"] == menu["id"]:
					menu["subMenu"].append(subMenu)
					flg=False;
			
			if flg:
				# 创建主菜单
				temp = DBMenu.selectByMenuId(subMenu["parentId"])
				menu = {}
				menu['id'] = temp['menuId']
				menu['text'] = temp['text']
				menu['url'] = temp['url']
				menu['sort'] = temp['sort']
				menu["subMenu"] = []
				menu["subMenu"].append(subMenu)
				self.menuList.append(menu)
				
		self.menuList.sort(key=self.sort)
		# sorted(self.menuList,key=sort)
		
		'''
		# 获取一级菜单项目
		menu = DBAuthority.selectMenu(userName, 0)
		for item in menu:
			subMenu = DBAuthority.selectMenu(userName, item["id"])
			menuItem = {};
			menuItem["id"] = item["id"]
			menuItem["text"] = item["text"]
			menuItem["url"] = item["url"]
			menuItem["subMenu"] = subMenu
			self.menuList.append(menuItem)
		'''
		# 整理菜单项目
		for item in self.menuList:
			item['url'] = item['subMenu'][0]['url']
		Logger.info('MenuManagement.initMenu end');
Пример #4
0
	def selectAuthorityByUserName(self, userName):
		# 权限信息
		value = DBAuthority.selectAuthorityByUserName(userName)
		return value
Пример #5
0
	def selectAuthorityById(self, id):
		# 权限信息
		value = DBAuthority.selectAuthorityById(id)
		return value
Пример #6
0
	def select(self, text):
		'''
		查找指定用户
		'''
		value = DBAuthority.selectAuthority(text)
		return value
Пример #7
0
	def selectAll(self, text):
		'''
		查找用户
		'''
		value = DBAuthority.selectAllAuthority(text)
		return value
Пример #8
0
	def replaceAuthority(self, userName, authorityId):
		value = DBAuthority.update(userName, authorityId)
		return value
Пример #9
0
	def createAuthority(self, text):
		value = DBAuthority.insrt(text)
		return value