当前位置: 首页>>代码示例>>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;未经允许,请勿转载。