Beispiel #1
0
    def insert(self, user):
        '''
        @see: IUserService.insert
        '''
        assert isinstance(user, User), 'Invalid user %s' % user

        userDb = UserMapped()
        userDb.password = user.Password
        userDb.CreatedOn = current_timestamp()
        userDb.typeId = self._userTypeId(user.Type)
        try:
            self.session().add(copy(user, userDb, exclude=('Type',)))
            self.session().flush((userDb,))
        except SQLAlchemyError as e: handle(e, userDb)
        user.Id = userDb.Id
        return user.Id
Beispiel #2
0
    def insert(self, user):
        '''
        @see: IUserService.insert
        '''
        assert isinstance(user, User), 'Invalid user %s' % user

        userDb = UserMapped()
        userDb.password = user.Password
        try:
            self.session().add(copy(user, userDb))
            self.session().flush((userDb,))
        except SQLAlchemyError as e: handle(e, userDb)
        user.Id = userDb.Id
        return user.Id

        user.password = user.Password # We set the password value.
        return super().insert(user)
Beispiel #3
0
    def insert(self, user):
        '''
        @see: IUserService.insert
        '''
        assert isinstance(user, User), 'Invalid user %s' % user

        userDb = UserMapped()
        userDb.password = user.Password
        userDb.CreatedOn = current_timestamp()
        userDb.typeId = self._userTypeId(user.Type)
        try:
            self.session().add(copy(user, userDb, exclude=('Type', )))
            self.session().flush((userDb, ))
        except SQLAlchemyError as e:
            handle(e, userDb)
        user.Id = userDb.Id
        return user.Id
Beispiel #4
0
    def insert(self, user):
        '''
        @see: IUserService.insert
        '''
        assert isinstance(user, User), 'Invalid user %s' % user

        sql = self.session().query(UserMapped)
        sql = sql.filter(UserMapped.Name == user.Name)
        sql = sql.filter(UserMapped.DeletedOn == None)
        if sql.count() > 0: raise InputError(Ref(_('There is already a user with this name'), ref=User.Name))

        userDb = UserMapped()
        userDb.password = user.Password
        userDb.CreatedOn = current_timestamp()
        try:
            self.session().add(copy(user, userDb))
            self.session().flush((userDb,))
        except SQLAlchemyError as e: handle(e, userDb)
        user.Id = userDb.Id
        return user.Id
Beispiel #5
0
    def insert(self, user):
        '''
        @see: IUserService.insert
        '''
        assert isinstance(user, User), 'Invalid user %s' % user

        sql = self.session().query(UserMapped)
        sql = sql.filter(UserMapped.Name == user.Name)
        sql = sql.filter(UserMapped.DeletedOn == None)
        #        if sql.count() > 0: raise InputError(Ref(_('There is already a user with this name'), ref=User.Name))

        userDb = UserMapped()
        userDb.password = user.Password
        userDb.CreatedOn = current_timestamp()
        try:
            self.session().add(copy(user, userDb))
            self.session().flush((userDb, ))
        except SQLAlchemyError as e:
            handle(e, userDb)
        user.Id = userDb.Id
        return user.Id