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


Python Auth.check_if_authorized方法代码示例

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


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

示例1: apply_acl

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
def apply_acl ():
    # Add a new entry
    c_type = CTK.post.pop('type')
    c_id   = CTK.post.pop('id')

    if c_type == 'asset':
        content = Asset.Asset(c_id)
    elif c_type == 'collection':
        content = Collection.Collection(c_id)
    else:
        return {'ret':'fail'}

    try:
        Auth.check_if_authorized(content)
    except Error.Unauthorized:
        return {'ret': 'fail'}

    ace = {}
    for key in CTK.post:
        if CTK.post[key] != 'None':
            ace[key] = CTK.post[key]

    acl = ACL()
    acl.add(content,ace)
    return {'ret': 'ok'}
开发者ID:manolodd,项目名称:activae,代码行数:27,代码来源:PageACL.py

示例2: __init__

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
    def __init__ (self, content):
        CTK.Container.__init__ (self)

        Auth.check_if_authorized (content)
        c_id, c_type = get_id_and_type (content)

        # List current ones
        refresh = CTK.Refreshable({'id': 'acl_%s' % content['id']})
        refresh.register (lambda: ACLTable(refresh, content).Render())

        self += CTK.RawHTML ("<h2>%s Permisos asociados</h2>" % BACK_LINK)
        self += refresh
开发者ID:manolodd,项目名称:activae,代码行数:14,代码来源:PageACL.py

示例3: Add

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
    def Add (self, content):
        c_types = ['collection', 'asset']
        c_type  = c_types[isinstance (content, Asset.Asset)]

        c_id     = '%s=%s' % (c_type[0], str(content['id']))
        link     = LINK_HREF % ("%s/meta/%s" %(LOCATION,c_id),'Metadatos')
        links    = [CTK.RawHTML(link)]

        try:
            Auth.check_if_authorized (content)
            link = LINK_HREF % ("/acl/%s/%d" % (c_type, content['id']), 'Permisos')
            links.append(CTK.RawHTML(link))
        except Error.Unauthorized:
            pass

        if c_id[0] == 'c':
            link = LINK_HREF % ("%s/view/%s" % (LOCATION, c_id), 'Ver')
            links.append(CTK.RawHTML(link))

        elif c_id[0] == 'a':
            if content['attachment']:
                if not content._file['queue_flag']:
                    if self._has_valid_attachment (content):
                        links = links + self._get_attachment_links(content, c_id)
                    else:
                        # Error notice
                        dialog = CTK.Dialog ({'title': 'Activo #%d corrupto'%content['id'], 'autoOpen': False})
                        dialog += CTK.RawHTML (FAULTY_NOTE)
                        dialog.AddButton ('Cerrar', "close")
                        link = LINK_JS_ON_CLICK %(dialog.JS_to_show(), FAULTY_LINK)
                        self += dialog
                        links.append(CTK.RawHTML(link))
                else:
                    # Transcoding notice
                    dialog = CTK.Dialog ({'title': 'Procesando #%d...'%content['id'], 'autoOpen': False})
                    dialog += CTK.RawHTML (TRANSCODING_NOTE)
                    dialog.AddButton ('Cerrar', "close")
                    link = LINK_JS_ON_CLICK %(dialog.JS_to_show(), TRANSCODING_LINK)
                    self += dialog
                    links.append(CTK.RawHTML(link))

            links.append (self._get_bookmark_link (content['id']))

        table = CTK.Table({'class':"abstract_actions"})
        n = 1
        for link in links:
            table[(n,1)] = link
            n+=1
        self+= table
开发者ID:manolodd,项目名称:activae,代码行数:51,代码来源:WidgetConsume.py

示例4: edit_acl

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
def edit_acl ():
    req        = CTK.request.url.split('/')
    content_id = req[-1]
    c_type     = req[-2]
    try:
        if c_type == 'asset':
            content = Asset.Asset (content_id)
        else:
            content = Collection.Collection (content_id)
        Auth.check_if_authorized (content)
    except:
        return default_user ('Operación no autorizada')

    page = Page.Default()
    page += ACLWidget (content)
    return page.Render()
开发者ID:manolodd,项目名称:activae,代码行数:18,代码来源:PageACL.py

示例5: del_acl

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
def del_acl():
    req     = CTK.request.url.split('/')
    id_acl  = req[-1]
    c_id    = req[-2]
    c_type  = req[-3]

    if c_type == 'asset':
        content = Asset.Asset(c_id)
    else:
        content = Collection.Collection (c_id)

    try:
        Auth.check_if_authorized (content)
        acl = ACL()
        acl.delete(content, {'id_acl':id_acl})
    except:
        return {'ret': 'fail'}
    return {'ret': 'ok'}
开发者ID:manolodd,项目名称:activae,代码行数:20,代码来源:PageACL.py

示例6: Add

# 需要导入模块: import Auth [as 别名]
# 或者: from Auth import check_if_authorized [as 别名]
    def Add (self, collection):
        collection_id = collection['id']
        coll = self.collections_dict[collection_id]
        linkname, linkdel = str(collection_id),''

        if collection_id in self.acl.filter_collections ("co" , [collection_id]):
            url      = "%s/edit/%s" % (PageCollection.LOCATION, collection_id)
            linkname = LINK_HREF %(url, collection_id)

        # Delete collection link
        if collection_id in self.acl.filter_collections ("rm" , [collection_id]):
            dialog   = self.__get_del_dialog ("del/%s" %(collection_id), NOTE_DELETE)
            linkdel  = LINK_JS_ON_CLICK %(dialog.JS_to_show(), "Borrar")
            self += dialog

        entries = [CTK.RawHTML(linkname),
                   CTK.RawHTML(coll['name']),
                   CTK.RawHTML(coll['username']),
                   CTK.RawHTML(linkdel)]

        try:
            Auth.check_if_authorized (collection)
            link = LINK_HREF % ("/acl/collection/%d" % (collection['id']), 'Permisos')
            entries.append(CTK.RawHTML(link))
        except Error.Unauthorized:
            entries.append(CTK.RawHTML(''))
            pass


        if collection_id in self.acl.filter_collections ("ed" , [collection_id])\
                and Role.user_has_role (Role.ROLE_EDITOR):
            url  = '%s/edit/%d'%(PageCollection.LOCATION,collection_id)
            link = LINK_HREF%(url, 'Editar')
            entries.append(CTK.RawHTML (link))


        if collection_id in self.acl.filter_collections ("co" , [collection_id]):
            url  = "%s/meta/%s" % (PageCollection.LOCATION, collection_id)
            link = LINK_HREF%(url, 'Metadatos')
            entries.append(CTK.RawHTML (link))


        self.n += 1
        self.table[(self.n, 1)] = entries
开发者ID:manolodd,项目名称:activae,代码行数:46,代码来源:WidgetCollection.py


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