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


Python Catalog.authority_verify方法代码示例

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


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

示例1: fun_article_update_src

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import authority_verify [as 别名]
def fun_article_update_src(user, article_id=0, article_type='blog', 
                            src_type='code', alias='1', title='', 
                            body='', source='', code_type='python', math_type='inline', group_id='-1'):
    '''
        update the lib of the article, article_type is about|blog|comment
        article_id must be have
        need alias too, then we find the lib _id, create the object, and set of it
    '''
    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
    if src_type not in Agree_Src:
        return [1, '暂不支持当前资源的类型!']
        
    if title is None:
        return [1, '请您填写标题/名称!']
              
    if src_type != 'image':
        if body is None:
            if src_type == 'r':
                if source is None:
                    return [1, '出处不能为空']
                if re.search(r'^(http|https|ftp):\/\/.+$', source) is None:
                    return [1, '请填写链接地址或者引用真实内容!']
                body = ''
            else:
                return [1, '内容不能为空!']
        
        if src_type == 'math':
            if math_type not in ['display', 'inline']:
                math_type  = 'display'
                body = math_encode( xhtml_unescape(body) )

        if src_type == 'code':
            if code_type not in Agree_Code:
                return [1, '目前不支持此类型的程序代码!']
                
    if article_type == "about":
        AF_Object = About(_id=user.about._id)
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权修改!']
            pass
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该知识谱!']
开发者ID:deju,项目名称:afw_old,代码行数:52,代码来源:AF_EditTool.py

示例2: fun_new_article_pic

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import authority_verify [as 别名]
def fun_new_article_pic(user, article_id=0, article_type='blog', title='', url='', thumb='', father_id=0, group_id='-1'):
    isnew = 0
    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
        
    if article_type == "about":
        AF_Object = About(_id=user.about._id)
        isnew = 0
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权修改摘要!']
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该目录!']
开发者ID:deju,项目名称:afw_old,代码行数:21,代码来源:AF_EditTool.py

示例3: fun_article_delete_src

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import authority_verify [as 别名]
def fun_article_delete_src(user, article_id=0, article_type='blog', src_type='code', alias=0, group_id='-1'):

    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
    if src_type not in Agree_Src:
        return [1, '不支持当前类型的资源!']
        
    if article_type == "about":
        AF_Object = About(_id=user.about._id)
    elif article_type == "book-about":
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权删除!']
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到该知识谱!']
开发者ID:deju,项目名称:afw_old,代码行数:22,代码来源:AF_EditTool.py

示例4: fun_article_new_src

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import authority_verify [as 别名]
def fun_article_new_src(user, article_id='-1', article_type='blog', src_type='code',
            title='', body='', source='', code_type='python', math_type='inline', father_id='-1', group_id='-1'):
    if article_type not in Article_Type:
        return [1, '不支持当前文章类型!']
    if src_type not in Agree_Src:
        return [1, '不支持当前类型的资源!']
        
    if title is None:
        return [1, '名称不能为空!']
        
    if body is None:
        if src_type != 'reference':
            return [1, '内容不能为空!']
        else:
            if re.search(r'^(http|https|ftp):\/\/.+$', source) is None:
                return [1, '请填写链接地址或者引用真实内容!']
            body = ''
    else:
        if src_type == 'math':    
            body = math_encode(escape.xhtml_unescape(body))
        elif src_type == 'code':
            if code_type not in Agree_Code:
                return [1, '请选择代码种类!']
    
    if article_type == "about":
        AF_Object = user.about
        article_id = str(user.about._id)
        isnew = False
    elif article_type == "book-about":
        isnew = False
        try:
            book = Catalog(_id=group_id)
            AF_Object = book.about
            limit = book.authority_verify(user)
            if test_auth(limit, A_WRITE) is False:
                return [1, '您无权修改摘要!']
        except Exception, err:
            logging.error(traceback.format_exc())
            logging.error('Catalog not exist, id %s' % group_id)
            return [1, '未找到知识谱!']
开发者ID:deju,项目名称:afw_old,代码行数:42,代码来源:AF_EditTool.py

示例5: Catalog

# 需要导入模块: from catalog import Catalog [as 别名]
# 或者: from catalog.Catalog import authority_verify [as 别名]
     # write blog end 
 elif article_type == "about":
     # write user about start
     AF_Object = user.about
     AF_Object.body = body
     AF_Object.env = user
     return [0, '']
     # write user about end 
 elif article_type == "book-about":
     try:
         book = Catalog(_id=group_id)
     except Exception, err:
         logging.error(traceback.format_exc())
         logging.error('Catalog not exist, id %s' % group_id)
     else:
         limit = book.authority_verify(user)
         if test_auth(limit, A_WRITE) is False:
             return [1, '您无权修改摘要!']
         book.about.body = body
         book.about.env = book
         return [0, '摘要更新成功!']
     
 elif article_type == "comment":
     # write comment, maybe blog comment, topic reply, and so on
     return fun_update_comment(user=user, article_id=article_id, group_id=group_id, father_id=father_id, 
         father_type=father_type, ref_comments=ref_comments, article_type=article_type, body=body)
     # write comment end
 else:
     # for group
     return fun_update_group_article(user=user, group_id=group_id, article_id=article_id, article_type=article_type,
         title=title, body=body, classes=classes, do=do) 
开发者ID:deju,项目名称:afw_old,代码行数:33,代码来源:AF_BlogTool.py


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