Example #1
0
  def post(self):
    """Handels the get request for the MainHandler.

    Retrieves a list of all of the domain's users and sends it
    to the Client as a JSON object.
    """
    users_list = []
    session = Session()
    domain = session['domain']
    client = AppsClient(domain=domain)
    client.auth_token = self.Get2loToken()
    client.ssl = True
    feed = client.RetrieveAllUsers()
    for entry in feed.entry:
      users_list.append(entry.login.user_name)
    self.response.out.write(json.dumps(users_list))
Example #2
0
  def GetNicknames(self, domain, username):
    """Retrieves the list of all the nicknames for the user.

    Args:
      domain: A string determining the user's domain.
      username: A string denoting the user's username.

    Returns:
      A list of user's nicknames if successful.
      Otherwise a list with a single entry containing error message.
    """
    try:
      client = AppsClient(domain=domain)
      client.auth_token = self.Get2loToken()
      client.ssl = True
      feed = client.RetrieveNicknames(username)
      nicknames = []
      for entry in feed.entry:
        nicknames.append(entry.nickname.name)
      return nicknames
    except:
      return ['An error occured while retriving Nicknames for the user.']