Пример #1
0
    def add(self, path = '', part = 1, type = (), properties = {}):

        db = get_session()

        f = db.query(File).filter_by(path = path).first()
        if not f:
            f = File()
            db.add(f)

        f.path = path
        f.part = part
        f.type_id = self.getType(type).id

        db.commit()

        db.expunge(f)
        return f
Пример #2
0
    def add(self, path='', part=1, type=(), properties={}):

        db = get_session()

        f = db.query(File).filter_by(path=path).first()
        if not f:
            f = File()
            db.add(f)

        f.path = path
        f.part = part
        f.type_id = self.getType(type).id

        db.commit()

        db.expunge(f)
        return f
Пример #3
0
    def add(self,
            path='',
            part=1,
            type_tuple=(),
            available=1,
            properties=None):
        if not properties: properties = {}

        type_id = self.getType(type_tuple).get('id')
        db = get_session()

        f = db.query(File).filter(File.path == toUnicode(path)).first()
        if not f:
            f = File()
            db.add(f)

        f.path = toUnicode(path)
        f.part = part
        f.available = available
        f.type_id = type_id

        db.commit()

        file_dict = f.to_dict()

        return file_dict
Пример #4
0
    def add(self,
            path='',
            part=1,
            type_tuple=(),
            available=1,
            properties=None):
        if not properties: properties = {}

        try:
            db = get_session()
            type_id = self.getType(type_tuple).get('id')

            f = db.query(File).filter(File.path == toUnicode(path)).first()
            if not f:
                f = File()
                db.add(f)

            f.path = toUnicode(path)
            f.part = part
            f.available = available
            f.type_id = type_id

            db.commit()

            file_dict = f.to_dict()

            return file_dict
        except:
            log.error('Failed adding file: %s, %s',
                      (path, traceback.format_exc()))
            db.rollback()
        finally:
            db.close()
Пример #5
0
    def add(self, path = '', part = 1, type_tuple = (), available = 1, properties = None):
        if not properties: properties = {}

        try:
            db = get_session()
            type_id = self.getType(type_tuple).get('id')

            f = db.query(File).filter(File.path == toUnicode(path)).first()
            if not f:
                f = File()
                db.add(f)

            f.path = toUnicode(path)
            f.part = part
            f.available = available
            f.type_id = type_id

            db.commit()

            file_dict = f.to_dict()

            return file_dict
        except:
            log.error('Failed adding file: %s, %s', (path, traceback.format_exc()))
            db.rollback()
        finally:
            db.close()
Пример #6
0
    def add(self, path='', part=1, type=(), available=1, properties={}):
        db = get_session()

        f = db.query(File).filter(
            or_(File.path == toUnicode(path), File.path == path)).first()
        if not f:
            f = File()
            db.add(f)

        f.path = path
        f.part = part
        f.available = available
        f.type_id = self.getType(type).id

        db.commit()

        file_dict = f.to_dict()

        return file_dict
Пример #7
0
    def add(self, path="", part=1, type=(), available=1, properties={}):
        db = get_session()

        f = db.query(File).filter(File.path == toUnicode(path)).first()
        if not f:
            f = File()
            db.add(f)

        f.path = toUnicode(path)
        f.part = part
        f.available = available
        f.type_id = self.getType(type).id

        db.commit()

        file_dict = f.to_dict()

        return file_dict