Example #1
0
    def get(self, *args, **kwargs):
        # 渲染页面
        handler_page = u'user_list.html'

        arguments = get_arguments_analysis(self.request.arguments)

        if 'ajax' not in arguments:     # 直接访问页面,非ajax
            # 渲染页面
            render_page = assert_path + handler_page
            # 查询语句
            sql = u'select user.*,GroupName from user join user_group on user.UserGroupID = user_group.ID;'
            mysql_query_result = query.query(sql)
            self.render(render_page,user_list=mysql_query_result)
        else:                           # ajax get方式访问页面
            if arguments['action'] == 'add':
                try:
                    if self.__AddUser(
                        UserName=arguments['UserName'],
                        Password=arguments['Password'],
                        UserGroupID=arguments['UserGroupID'],
                        Fullname=arguments['Fullname'] if 'Fullname' in arguments else '',
                        isPermit=arguments['isPermit'] if 'isPermit' in arguments else '1',
                        TellphoneNumber=arguments['TellphoneNumber'] if 'TellphoneNumber' in arguments else '',
                        Description=arguments['Description'] if 'Description' in arguments else ''
                    ):
                        self.write_error('true')
                    else:
                        self.write_error('false')
                except Exception,err:
                    print err
            self.write('aaa')
Example #2
0
    def get(self, request_page=None, *args, **kwargs):
        # 获取get参数
        arguments = self.request.arguments

        # 遍历一次,key-value化
        if  'action' in arguments and arguments and isinstance(arguments,dict):
            arguments_keyvalue = {key:u''.join(value) for key,value in arguments.items()}

            action = arguments_keyvalue['action']

            # 定义一个action-sql字典
            action_sql = {
                'show': 'show tables;',
                'get_user': ''
            }

            mysql_query_result = query.query(action_sql[action])

            self.write(json.dumps(mysql_query_result))
        else:
            self.write(json.dumps({}))