Exemplo n.º 1
0
	def run(self):
		"""
		启动网站
		"""
		# 初始化
		Common.init();
		
		# 创建web应用
		Logger.info('创建web应用')
		Common.app = web.application(Common.urls, globals())
		
		# 创建session
		Logger.info('创建session')
		Common.initSession(Common.app);
		Common.session.menu = MenuManagement();
		
		# 加载模板
		Logger.info('加载模板')
		Common.render = web.template.render('templates/', base='baseframe', globals={'context': Common.session})
		# 
		# 设置错误页面
		# Common.app.notfound = Common.notfound
		# Common.app.internalerror = Common.internalerror
		# 加载设置
		Logger.info('加载设置')
		# Common.app.add_processor(Common.error_precessor);
		Common.app.add_processor(web.loadhook(Common.session_hook));
		# Common.app.add_processor(web.loadhook(Common.session.menu.setSelectedMenu));
		Common.app.add_processor(web.loadhook(AuthorityManagement.checkAuthority))
		# Common.app.add_processor(web.unloadhook(AuthorityManagement.checkAuthority))
		
		Logger.debug('网站启动')
		Common.initFinish = True
		Common.app.run();
Exemplo n.º 2
0
	def POST(self):
		'''
		'''
		self.id = web.input().authorityId
		self.temp = web.input(menuId4=False).menuId4
		self.selectMenuId = [];
		self.text = web.input().text
		self.menuAll = MenuManagement.selectAll()
		for item in self.menuAll:
			temp = None
			exec('temp=web.input(menuId%d=False).menuId%d' % (item["menuId"], item["menuId"]))
			if temp == "on":
				self.selectMenuId.append(item["menuId"])

		if self.id == "":
			# 新建数据
			Logger.info('新建数据')
			self.id = AuthorityManagement.createAuthority(self.text)

			'''
			for item in self.menuAll:
				self.dictMenuAuthority[item['menuId']] = ""
			'''
			
		else:
			# 更新数据
			Logger.info('更新数据')
			
			AuthorityManagement.updateAuthority(self.id, self.text, self.selectMenuId)
			
		# return Common.render.authority.modify(self)
		return web.seeother('/authority/modify?id=' + str(self.id))
Exemplo n.º 3
0
	def GET(self):
		'''
		'''
		urlParam = web.input(id=None)
		self.id = urlParam.id
		'''
		self.menuAll = MenuManagement.selectAll()
		for item in self.menuAll:
			self.dictMenuAuthority[item['menuId']] = ""
		'''
		if self.id == None:
			self.id = ""
			self.menuAll = []
			self.text = ""
		else:
			self.menuAuthority = AuthorityManagement.selectAuthorityById(self.id)
			self.text = self.menuAuthority[0]["comment"]
			self.menuAll = MenuManagement.selectAll()
			for item in self.menuAll:
				self.dictMenuAuthority[item['menuId']] = ""
				
			for item in self.menuAuthority:
				self.dictMenuAuthority[item['menuId']] = 'checked'
		
		return Common.render.authority.modify(self)
Exemplo n.º 4
0
    def POST(self):
        '''
		'''
        self.id = web.input().authorityId
        self.temp = web.input(menuId4=False).menuId4
        self.selectMenuId = []
        self.text = web.input().text
        self.menuAll = MenuManagement.selectAll()
        for item in self.menuAll:
            temp = None
            exec('temp=web.input(menuId%d=False).menuId%d' %
                 (item["menuId"], item["menuId"]))
            if temp == "on":
                self.selectMenuId.append(item["menuId"])

        if self.id == "":
            # 新建数据
            Logger.info('新建数据')
            self.id = AuthorityManagement.createAuthority(self.text)
            '''
			for item in self.menuAll:
				self.dictMenuAuthority[item['menuId']] = ""
			'''

        else:
            # 更新数据
            Logger.info('更新数据')

            AuthorityManagement.updateAuthority(self.id, self.text,
                                                self.selectMenuId)

        # return Common.render.authority.modify(self)
        return web.seeother('/authority/modify?id=' + str(self.id))
Exemplo n.º 5
0
    def GET(self):
        '''
		'''
        urlParam = web.input(id=None)
        self.id = urlParam.id
        '''
		self.menuAll = MenuManagement.selectAll()
		for item in self.menuAll:
			self.dictMenuAuthority[item['menuId']] = ""
		'''
        if self.id == None:
            self.id = ""
            self.menuAll = []
            self.text = ""
        else:
            self.menuAuthority = AuthorityManagement.selectAuthorityById(
                self.id)
            self.text = self.menuAuthority[0]["comment"]
            self.menuAll = MenuManagement.selectAll()
            for item in self.menuAll:
                self.dictMenuAuthority[item['menuId']] = ""

            for item in self.menuAuthority:
                self.dictMenuAuthority[item['menuId']] = 'checked'

        return Common.render.authority.modify(self)
Exemplo n.º 6
0
	def initSession(self, app):
		"""
		初始化session
		"""
		# 设置session
		web.config.session_parameters['cookie_name'] = 'webpy_session_id'
		web.config.session_parameters['timeout'] = 500  # session过期时间(秒)
		
		# session格式
		dictSession = {
				'userInfo':None  # 登录系统的用户信息
				, 'menu':MenuManagement()
				, 'exception':Exception("没有错误")  # 异常信息
				}
		
		# 创建session
		if web.config.get('_session') is None:
			Common.session = web.session.Session(app, web.session.DiskStore('sessions'), dictSession)
		else:
			Common.session = web.config._session