コード例 #1
0
ファイル: session.py プロジェクト: jpvanhal/cloudsizzle
 def open(self):
     """Open a new session and log in with given username and password."""
     response = get_service('Login').request(
         username=self.username, password=self.password)
     try:
         self.user_id = response['user_id']
     except KeyError:
         messages = listify(response['messages'])
         raise LoginFailed(*messages)
コード例 #2
0
ファイル: people.py プロジェクト: jpvanhal/cloudsizzle
def create(username, password, email):
    """Create a new user.

    Returns the user id of the new user, if everything goes well.

    Arguments:
    username -- The desired username. Must be unique in the system. Length
                4-20 characters.
    password -- User's password.
    email -- User's email address.

    Exceptions:
    ValueError -- Given parameters were invalid.

    """
    register_service = get_service('Register')
    response = register_service.request(
        username=username, password=password, email=email)

    if 'messages' in response:
        messages = listify(response['messages'])
        raise ValueError(*messages)

    return response['user_id']