Example #1
0
    def createUser(self, params):
        user_dao = self.locator.getDAO("user")

        if user_dao.isExistfromKey("user_id", params["user_id"]):
            raise ERROR_EXIST_RESOURCE(key="user_id", value=params["user_id"])

        if not utils.checkIDFormat(params["user_id"]):
            raise ERROR_INVALID_ID_FORMAT()

        if not utils.checkPasswordFormat(params["password"]):
            raise ERROR_INVALID_PASSWORD_FORMAT()

        dic = {}
        dic["user_id"] = params["user_id"]
        dic["password"] = make_password(params["password"])

        if params.has_key("name"):
            dic["name"] = params["name"]

        if params.has_key("email"):
            dic["email"] = params["email"]

        if params.has_key("language"):
            dic["language"] = params["language"]
        else:
            dic["language"] = global_conf.DEFAULT_LANGUAGE

        if params.has_key("timezone"):
            dic["timezone"] = params["timezone"]
        else:
            dic["timezone"] = global_conf.DEFAULT_TIMEZONE

        user = user_dao.insert(dic)

        return self.locator.getInfo("UserInfo", user.user_id)
Example #2
0
    def createUser(self, params):
        user_dao = self.locator.getDAO('user')

        if user_dao.isExistfromKey('user_id', params['user_id']):
            raise ERROR_EXIST_RESOURCE(key='user_id', value=params['user_id'])

        if not utils.checkIDFormat(params['user_id']):
            raise ERROR_INVALID_ID_FORMAT()

        if not utils.checkPasswordFormat(params['password']):
            raise ERROR_INVALID_PASSWORD_FORMAT()

        dic = {}
        dic['user_id'] = params['user_id']
        dic['password'] = make_password(params['password'])

        if params.has_key('name'):
            dic['name'] = params['name']

        if params.has_key('email'):
            dic['email'] = params['email']

        if params.has_key('language'):
            dic['language'] = params['language']
        else:
            dic['language'] = global_conf.DEFAULT_LANGUAGE

        if params.has_key('timezone'):
            dic['timezone'] = params['timezone']
        else:
            dic['timezone'] = global_conf.DEFAULT_TIMEZONE

        user = user_dao.insert(dic)

        return self.locator.getInfo('UserInfo', user.user_id)
Example #3
0
    def createUser(self, params):
        user_dao = self.locator.getDAO('user') 

        if user_dao.isExist(user_id=params['user_id']):
            raise ERROR_EXIST_RESOURCE(key='user_id', value=params['user_id'])

        if not utils.checkIDFormat(params['user_id']):
            raise ERROR_INVALID_ID_FORMAT()

        if not utils.checkPasswordFormat(params['password']):
            raise ERROR_INVALID_PASSWORD_FORMAT()

        dic = {}
        dic['user_id'] = params['user_id']
        dic['password'] = make_password(params['password'])

        if params.has_key('name'):
            dic['name'] = params['name']

        if params.has_key('email'):
            dic['email'] = params['email']

        if params.has_key('language'):
            dic['language'] = params['language']
        else:
            dic['language'] = self.GLOBAL_CONF['DEFAULT_LANGUAGE']

        if params.has_key('timezone'):
            dic['timezone'] = params['timezone']
        else:
            dic['timezone'] = self.GLOBAL_CONF['DEFAULT_TIMEZONE']

        user = user_dao.insert(dic)

        return self.locator.getInfo('UserInfo', user)
Example #4
0
    def createUser(self, params):
        user_dao = self.locator.getDAO('user')

        if user_dao.isExist(user_id=params['user_id']):
            raise ERROR_EXIST_RESOURCE(key='user_id', value=params['user_id'])

        if not utils.checkIDFormat(params['user_id']):
            raise ERROR_INVALID_ID_FORMAT()

        if not utils.checkPasswordFormat(params['password']):
            raise ERROR_INVALID_PASSWORD_FORMAT()

        dic = {}
        dic['user_id'] = params['user_id']
        dic['password'] = make_password(params['password'])

        if params.has_key('name'):
            dic['name'] = params['name']

        if params.has_key('email'):
            dic['email'] = params['email']

        if params.has_key('language'):
            dic['language'] = params['language']
        else:
            dic['language'] = self.GLOBAL_CONF['DEFAULT_LANGUAGE']

        if params.has_key('timezone'):
            dic['timezone'] = params['timezone']
        else:
            dic['timezone'] = self.GLOBAL_CONF['DEFAULT_TIMEZONE']

        if params.has_key('group_id'):
            group_dao = self.locator.getDAO('group')

            groups = group_dao.getVOfromKey(uuid=params['group_id'])

            if groups.count() == 0:
                raise ERROR_INVALID_PARAMETER(key='group_id',
                                              value=params['group_id'])

            dic['group'] = groups[0]

        user = user_dao.insert(dic)

        return self.locator.getInfo('UserInfo', user)