當前位置: 首頁>>代碼示例>>Python>>正文


Python DBSession.delete方法代碼示例

本文整理匯總了Python中pygdv.model.DBSession.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.delete方法的具體用法?Python DBSession.delete怎麽用?Python DBSession.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pygdv.model.DBSession的用法示例。


在下文中一共展示了DBSession.delete方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: change_rights

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
def change_rights(project_id, circle_id, rights=None):
    '''
    Modify the right associated to a project to a group.
    If any right is added, automatically add read right.
    @param project_id : the project id
    @param circle_id : the circle id
    @param rights : the right to update
    '''
    project = DBSession.query(Project).filter(Project.id == project_id).first()
    rc_assocs = get_circle_right_assocs(circle_id, project_id)
    
    
    for rc in rc_assocs:
        if rc.circle.id == int(circle_id) :
            project._circle_right.remove(rc)
            DBSession.delete(rc)
            DBSession.flush()

    if rights is not None:
        _add_read_right(project, circle_id)
        for right_name in rights:
            if right_name != constants.right_read :
                right = DBSession.query(Right).filter(Right.name == right_name).first()
                cr_assoc = _get_circle_right_assoc(right, circle_id, project_id)
                project._circle_right.append(cr_assoc)

    DBSession.add(project)
    DBSession.flush()
開發者ID:bbcf,項目名稱:pygdv,代碼行數:30,代碼來源:project.py

示例2: e

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
def e(project=None, project_id=None, name=None, track_ids=None, circle_ids=None):
    if project is None:
        project = DBSession.query(Project).filter(Project.id == project_id).first()

    if name is not None:
        project.name = name

    if track_ids is not None:
        project.tracks = []
        for tid in track_ids:
            t = DBSession.query(Track).filter(Track.id == tid).first()
            project.tracks.append(t)

    if circle_ids is not None:
        if not isinstance(circle_ids, list):
            circle_ids = [circle_ids]
        circle_ids = [int(i) for i in circle_ids]
        to_del = []
        for shared in project._circle_right:
            if shared.circle.id not in circle_ids:
                to_del.append(shared)
        for d in to_del:
            DBSession.delete(d)
            project._circle_right.remove(d)
        DBSession.flush()

        shared_ids = [c.id for c in project.shared_circles]
        read_right = DBSession.query(Right).filter(Right.id == constants.rights['read']['id']).first()
        for new_id in circle_ids:
            if new_id not in shared_ids:
                add_right(project=project, circle_id=new_id, right=read_right)
        DBSession.flush()
    DBSession.add(project)
    DBSession.flush()
    return project
開發者ID:bbcf,項目名稱:pygdv,代碼行數:37,代碼來源:project.py

示例3: after_sha1

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
    def after_sha1(self, fname, sha1, force, callback_url, track_id, old_task_id, mail, key, sequence_id, extension, trackname):
        """
        Called after a sha1 where calculated on a file.
        If the sha1 already exist, only the databases operations are done.
        Else the input will go in the second part of the process.
        The input can be 'forced' to be recomputed
        """
        try:
            _input = DBSession.query(Input).filter(Input.sha1 == sha1).first()
            do_process = True
            if util.str2bool(force) and _input is not None:
                handler.track.delete_input(_input.sha1)
                DBSession.delete(_input)
                DBSession.flush()
            elif _input is not None:
                do_process = False
                handler.track.update(track_id=track_id,
                    params={'new_input_id': _input.id})
                handler.track.finalize_track_creation(track_id=track_id)

            if do_process:

                handler.track.update(track_id=track_id, params={'sha1': sha1})
                sequence = DBSession.query(Sequence).filter(Sequence.id == sequence_id).first()
                async = tasks.track_process.delay(mail, key, old_task_id, fname, sha1, callback_url, track_id, sequence.name, extension, trackname, callback_url)

                handler.track.update(track_id=track_id,
                    params={'new_task_id': async.task_id})
            return {'success': 'to second process'}
        except Exception as e:
            etype, value, tb = sys.exc_info()
            traceback.print_exception(etype, value, tb)


            return {'error': str(e)}
開發者ID:bbcf,項目名稱:pygdv,代碼行數:37,代碼來源:track.py

示例4: delete

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
 def delete(self, _id):
     user = handler.user.get_user_in_session(request)
     if not checker.can_edit_job(user.id, _id):
         return {'error': "You have don't have the right to delete this job"}
     job = DBSession.query(Job).filter(Job.id == _id).first()
     # TODO delete results (DB + filesystem)
     DBSession.delete(job)
     raise redirect('/jobs')
開發者ID:bbcf,項目名稱:pygdv,代碼行數:10,代碼來源:job.py

示例5: delete

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
 def delete(self, circle_id, *args, **kw):
     user = handler.user.get_user_in_session(request)
     if not checker.user_own_circle(user.id, circle_id):
         flash('you have no right to delete this circle: you are not the creator of it')
         raise redirect('/circles')
     circle = DBSession.query(Circle).filter(Circle.id == circle_id).first()
     DBSession.delete(circle)
     DBSession.flush()
     raise redirect('/circles/')
開發者ID:bbcf,項目名稱:pygdv,代碼行數:11,代碼來源:circle.py

示例6: after_process

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
 def after_process(self, mail, key, old_task_id, track_id, datatype):
     print '[x] after process [x] %s' % track_id
     task = DBSession.query(Task).filter(Task.task_id == old_task_id).first()
     if task is not None:
         DBSession.delete(task)
         DBSession.flush()
     if not track_id == 'None':
         handler.track.update(track_id=track_id, params={'datatype': datatype})
         handler.track.finalize_track_creation(track_id=track_id)
     return {'success': 'end'}
開發者ID:bbcf,項目名稱:pygdv,代碼行數:12,代碼來源:track.py

示例7: delete

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
 def delete(self, project_id, selection_id):
     user = handler.user.get_user_in_session(request)
     if not checker.check_permission(user=user, project_id=project_id, right_id=constants.right_upload_id):
         flash('You must have %s permission to delete the project.' % constants.right_upload, 'error')
         return {'delete': 'failed'}
     selection = DBSession.query(Selection).filter(Selection.id == selection_id).first()
     if not selection.project_id == project_id:
         flash('Bad project_id: %s' % project_id, 'error')
         return {'delete': 'failed'}
     DBSession.delete(selection)
     DBSession.flush()
     return {'delete': 'success'}
開發者ID:bbcf,項目名稱:pygdv,代碼行數:14,代碼來源:selection.py

示例8: delete_track

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
def delete_track(track=None, track_id=None):
    '''
    Delete the track and the input associated if this is the only track with this input.
    '''
    if track is None:
        track = DBSession.query(Track).filter(Track.id == track_id).first()
    if track is None:
        return
    _input = track.input
    if _input is not None:
        if len(_input.tracks) == 1:
            delete_input(_input.sha1)
            DBSession.delete(_input)
    DBSession.delete(track)
    DBSession.flush()
開發者ID:bbcf,項目名稱:pygdv,代碼行數:17,代碼來源:track.py

示例9: save

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
    def save(self, project_id, color, description, locations):
        user = handler.user.get_user_in_session(request)

        if not checker.check_permission(user=user, project_id=project_id, right_id=constants.right_upload_id):
            flash('You must have %s permission to delete the project.' % constants.right_upload, 'error')
            return {'save': 'failed'}

        #print "save %s, color %s, desc %s loc %s" % (project_id, color, description, locations)
        ''' For the moment, there is only one selection per project'''
        sel = DBSession.query(Selection).filter(Selection.project_id == project_id).first()
        if sel is None:
            sel = Selection()
            sel.project_id = project_id

        sel.description = description
        sel.color = color
        DBSession.add(sel)
        DBSession.flush()

        locations_ids = []
        # add locations
        for loc in json.loads(locations):
            obj = None
            if 'id' in loc:
                obj = DBSession.query(Location).join(Selection.locations).filter(
                        and_(Selection.id == sel.id, Location.id == loc.get('id'))).first()

            if obj is None:
                obj = Location()

            obj.chromosome = loc.get('chr')
            obj.start = loc.get('start')
            obj.end = loc.get('end')
            obj.description = loc.get('desc', 'No description')
            obj.selection = sel
            DBSession.add(obj)
            DBSession.flush()
            locations_ids.append(obj.id)
        # remove not saved ones
        loc_to_remove = DBSession.query(Location).filter(not_(Location.id.in_(locations_ids))).all()
        for l in loc_to_remove:
            DBSession.delete(l)
        DBSession.flush()
        return {"saved": "ok"}
開發者ID:bbcf,項目名稱:pygdv,代碼行數:46,代碼來源:selection.py

示例10: delete

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
def delete(project=None, project_id=None):
    if project is None:
        project = DBSession.query(Project).filter(Project.id == project_id).first()
    remove_sharing(project=project)
    DBSession.delete(project)
    DBSession.flush()
開發者ID:bbcf,項目名稱:pygdv,代碼行數:8,代碼來源:project.py

示例11: remove_sharing

# 需要導入模塊: from pygdv.model import DBSession [as 別名]
# 或者: from pygdv.model.DBSession import delete [as 別名]
def remove_sharing(project=None, project_id=None):
    if project is None:
        project = DBSession.query(Project).filter(Project.id == project_id).first()
    for rc in project._circle_right:
        DBSession.delete(rc)
    DBSession.flush()
開發者ID:bbcf,項目名稱:pygdv,代碼行數:8,代碼來源:project.py


注:本文中的pygdv.model.DBSession.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。