Esempio n. 1
0
  def updateSettings(self, section=None):
    if section != "usertrack":
      # Everything but usertrack requires authentication...
      apikey = AuthenticatedBaseHandler.extractAuthHeader()
      authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

      if authResult is False:
        AuthenticatedBaseHandler.raiseAuthFailure()

    dirty = False
    data = web.data()
    if data:
      sections = {}
      if section:
        sections = {section: utils.jsonDecode(data)}
      else:
        sections = utils.jsonDecode(data)

      config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY)

      for s in sections:
        if s in self.validSections():
          for key in sections[s]:
            if not config.has_section(s):
              config.add_section(s)
            config.set(s, key, sections[s][key])
            dirty = True
        else:
          return False
      if dirty:
        config.save()

      return dirty
 def tearDown(self):
   config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY)
   if not config.has_section("aws"):
     config.add_section("aws")
   config.set("aws", "aws_secret_access_key", self.default_aws_secret_key)
   config.set("aws", "aws_access_key_id", self.default_aws_access_key)
   config.save()
    def updateSettings(self, section=None):
        if section != "usertrack":
            # Everything but usertrack requires authentication...
            apikey = AuthenticatedBaseHandler.extractAuthHeader()
            authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

            if authResult is False:
                AuthenticatedBaseHandler.raiseAuthFailure()

        dirty = False
        data = web.data()
        if data:
            sections = {}
            if section:
                sections = {section: utils.jsonDecode(data)}
            else:
                sections = utils.jsonDecode(data)

            config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY)

            for s in sections:
                if s in self.validSections():
                    for key in sections[s]:
                        if not config.has_section(s):
                            config.add_section(s)
                        config.set(s, key, sections[s][key])
                        dirty = True
                else:
                    return False
            if dirty:
                config.save()

            return dirty