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


Python Auth类代码示例

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


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

示例1: apply_acl

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,代码行数:25,代码来源:PageACL.py

示例2: del_asset

def del_asset():
    """Delete asset"""

    # Target asset
    asset_id = CTK.request.url.split('/')[-1]
    try:
        asset_id = __check_asset_id(asset_id)
        asset    = Asset (asset_id)
        if not asset['id']:
            return CTK.HTTP_Redir('/')
    except:
            return CTK.HTTP_Redir('/')

    # Authentication
    fail_admin = Auth.assert_is_role (Role.ROLE_ADMIN)
    user_id    = Auth.get_user_id()
    is_creator = (asset['creator_id'] == user_id)

    if fail_admin and not is_creator:
        return fail_admin

    op  = OpAsset (asset)
    result = op.delete()

    if result['ret'] == False:
        return default()

    if result['type'] == 'total':
        return CTK.HTTP_Redir(LOCATION)

    return default (ERROR_IN_USE)
开发者ID:manolodd,项目名称:activae,代码行数:31,代码来源:PageAsset.py

示例3: publish_asset_apply

def publish_asset_apply ():
    # Authentication
    fail = Auth.assert_is_role (Role.ROLE_PUBLISHER)
    if fail: return fail

    acl = ACL()
    ret = []
    for key in CTK.post:
        if not key.startswith('published_'):
            continue
        flag     = int(CTK.post[key])
        asset_id = key[len('published_'):]
        asset    = Asset(asset_id)

        if asset['published_flag'] == flag:
            continue

        asset['published_flag'] = flag
        asset['publisher_id']   = Auth.get_user_id()
        asset['date_available'] = "CURRENT_TIMESTAMP()"
        op = OpAsset(asset)
        ret.append(op.update())

        if ret[-1] == False:
            break

        if asset['published_flag']:
            acl.set_published_asset_acl(asset, True)
        else:
            acl.set_published_asset_acl(asset, False)

    if False in ret:
        return {'ret': "error"}

    return {'ret': "ok"}
开发者ID:manolodd,项目名称:activae,代码行数:35,代码来源:PageAsset.py

示例4: _get_owner_email

    def _get_owner_email (self, asset):
        user_id = asset['publisher_id']
        if not user_id:
            return

        user_name = Auth.get_user_name (user_id)
        user      = Auth.get_user (user_name)

        return user['email']
开发者ID:manolodd,项目名称:activae,代码行数:9,代码来源:processors.py

示例5: __init__

    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,代码行数:12,代码来源:PageACL.py

示例6: GET

 def GET(self):
   if( web.ctx.session.loggedIn == 1 ):
     p1 = Party('1', 'Steve Party')
     p2 = Party('2', 'Kurtis Party')
     parray = list()
     parray.append(p1)
     parray.append(p2)
     web.header('Content-Type', 'application/json')
     return json.dumps(parray, cls=PartyJSONEncoder)
   else:
     Auth.doUnAuth('Getting parties')
     return None
开发者ID:briggs11,项目名称:UDJ,代码行数:12,代码来源:Parties.py

示例7: GET

 def GET(self):
   if( 
     web.ctx.session.loggedIn == 1 and
     web.ctx.session.loggedIn != Party.INVALID_PARTY_ID
   ):
     data = web.input()
     db = MahData.getDBConnection()
     results = db.select('main_playlist_view')
     parray = getArrayFromResults(results)
     web.header('Content-Type', 'application/json')
     return json.dumps(parray, cls=PlaylistJSONEncoder)
   else:
     Auth.doUnAuth('Getting playlist')
开发者ID:Choiseul11,项目名称:UDJ,代码行数:13,代码来源:Playlist.py

示例8: Add

    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,代码行数:49,代码来源:WidgetConsume.py

示例9: POST

 def POST(self):
   if( 
     web.ctx.session.loggedIn == 1 and
     web.ctx.session.loggedIn != Party.INVALID_PARTY_ID
   ):
     db = MahData.getDBConnection()
     jsonSyncInfo = json.loads(web.input().syncinfo)
     serverClientMap = processSyncInfo(jsonSyncInfo, db)
     results = db.select('main_playlist_view')
     parray = getArrayFromResults(results)
     parray = addClientIds(parray, jsonSyncInfo['added'])
     web.header('Content-Type', 'application/json')
     return json.dumps(parray, cls=PlaylistJSONEncoder)
   else:
     Auth.doUnAuth('Syncing playlist')
开发者ID:Choiseul11,项目名称:UDJ,代码行数:15,代码来源:Playlist.py

示例10: edit_format_apply

def edit_format_apply():
    # Authentication
    fail = Auth.assert_is_role (Role.ROLE_ADMIN)
    if fail: return fail

    format_id = CTK.post.pop('formatid')
    if not format_id:
        return CTK.HTTP_Error(406)

    # Update the database
    q = ''
    for key in ['lossy_flag', 'format']:
        if key in CTK.post:
            q += "UPDATE formats SET %s='%s' WHERE id = %s;" % \
                (key, CTK.post[key], format_id)

    if 'target' in CTK.post:
        q += "INSERT INTO transcode_targets (source_id, target_id) VALUES ('%s','%s');" % \
            (format_id,CTK.post['target'])
    if q:
        q = "START TRANSACTION; %s COMMIT;" % q
        if not transaction_check_success (q):
            return {'ret': "error"}

    return {'ret': "ok",
            'redirect': '%s/edit/%s'%(LOCATION,format_id)}
开发者ID:manolodd,项目名称:activae,代码行数:26,代码来源:PageAdminFormats.py

示例11: edit_acl

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,代码行数:16,代码来源:PageACL.py

示例12: check_in

def check_in(in_path="/DataFiles/sub_paricipants.txt",out_path="/DataFiles/participants/"):
    screen_names=['auth_user1','auth_user2']
    
    checked_participants_file='/DataFiles/participants/checked.txt'
    notauthorized_participants_file='/DataFiles/participants/notAuthorized.txt'

    while len(screen_names)>0:
        screen_name=screen_names.pop()

        print screen_name

        participants=return_participants(file_path=in_path)
        #print len(participants)
        if os.path.exists(checked_participants_file):
            with open(checked_participants_file,'rb') as  handle:
                checked_partice=cpik.loads(handle.read())
                participants=participants-checked_partice

        if os.path.exists(notauthorized_participants_file):
            with open(notauthorized_participants_file,'rb') as  handle:
                checked_partice=cpik.loads(handle.read())
                participants=participants-checked_partice

        if len(participants)==0:
            if os.path.exists (checked_participants_file):
                os.remove(checked_participants_file)
            if os.path.exists (notauthorized_participants_file):
                os.remove(notauthorized_participants_file)                
            print 'successfully finittto! beginning next round!'
        api=Auth.get_authentication(screen_name=screen_name)
        status=recored_participants_graphs(api=api,participants=participants)
开发者ID:mehdyh59,项目名称:UCAMB_SocialInfluence,代码行数:31,代码来源:Participants_Graph.py

示例13: scrape

def scrape(partic_file='DataFiles/paricipants.txt'):
    participants=return_participants(file_path=partic_file)
    my_screenname='Auth_user'
    out_path='DataFiles/Tweets/'
    api=Auth.get_authentication(screen_name=my_screenname)
    max_twt_count=10
    count=5
    bb=0

    
    for part in participants:
        counter=0
        tweets=[]
        max_twt_id=None
        
        try:
            user_id=int(part)
            user=api.GetUser(user_id)
            tweets_count=user.statuses_count
        except twitter.TwitterError, ex:
            print ex.message
            continue
        threshold=min([max_twt_count,tweets_count])
        while counter<threshold:
            try:
                temp=api.GetUserTimeline(user_id=user_id,max_id=max_twt_id,include_entities=True,count=count,include_rts=True)
                counter+=len(temp)
                tweets+=temp
                max_twt_id=return_maxID(tweets=temp)
            except twitter.TwitterError , ex:
                print ex.message
                break
            if max_twt_id==None:
                break
开发者ID:mehdyh59,项目名称:UCAMB_SocialInfluence,代码行数:34,代码来源:Tweets_scrape.py

示例14: page_forbidden

def page_forbidden (limiter):
    # Authentication
    fail = Auth.assert_is_role (Role.ROLE_UPLOADER)
    if fail: return fail

    for key,value in limiter.limits.items():
        if value==0:
            limiter.limits[key] = NO_LIMIT

    rows = [('Número de archivos',       limiter.usage['files'], limiter.limits['files']),
            ('Total del sistema',        limiter.usage['total'], limiter.limits['total']),
            ('Tamaño máximo de archivo', limiter.usage['size'],  limiter.limits['size'])]

    header = ['Restricción', 'Uso', 'Límite']
    table = CTK.Table()
    table[(1,1)] = [CTK.RawHTML(x) for x in header]
    table.set_header (row=True, num=1)

    for x in range(len(rows)):
        table[(x+2,1)] = [CTK.RawHTML (str(column)) for column in rows[x]]

    page  = Page.Default()
    page += CTK.RawHTML ("<h1>%s: Subir ficheros</h1>" %(MENU_LINK))
    page += CTK.RawHTML ("<h2>Se han excedido los límites</h2>")
    page += table

    return page.Render()
开发者ID:manolodd,项目名称:activae,代码行数:27,代码来源:PageUpload.py

示例15: del_format

def del_format():
    # Authentication
    fail = Auth.assert_is_role (Role.ROLE_ADMIN)
    if fail: return fail

    # Target format
    format_id = CTK.request.url.split('/')[-1]

    # Check whether it can be deleted
    q = ("SELECT COUNT(*) as total "
         "FROM view_asset_formats "
         "WHERE formats_id = %(format_id)s;" %(locals()))
    re = Query(q)

    usage = re['total'][0]
    if usage != 0:
        subs = [{'n':'','s':''},{'n':'n','s':''}][(usage > 1)]
        subs['num'] = usage
        msg  = ("Imposible realizar la operación ya que existe%(n)s "
                "%(num)d activo%(s)s en ese formato" % subs)

        return default (msg)

    # Delete
    q  = "DELETE FROM transcode_targets WHERE source_id = %(format_id)s OR target_id = %(format_id)s;" %(locals())
    q += "DELETE FROM formats WHERE id = %(format_id)s;" %(locals())
    q  = "START TRANSACTION; %s COMMIT;" % q

    ok = transaction_check_success (q)

    if not ok:
        msg = 'No se pudo eliminar el formato.'
        return default (msg)
    return default()
开发者ID:manolodd,项目名称:activae,代码行数:34,代码来源:PageAdminFormats.py


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