Example #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 = YOMPAppConfig(mode=YOMPAppConfig.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
Example #2
0
  def getAllSettings(self):
    # Make sure we have the latest version of configuration
    YOMP.app.config.loadConfig()

    apikey = AuthenticatedBaseHandler.extractAuthHeader()
    authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

    if authResult is False:
      AuthenticatedBaseHandler.raiseAuthFailure()

    res = {}
    for section in self.validSections():
      res[section] = {}
      for key, value in YOMP.app.config.items(section):
        if key not in HIDDEN_SETTINGS.get(section, set()):
          res[section][key] = value
    return res
Example #3
0
  def getSectionSettings(self, section):
    # Make sure we have the latest version of configuration
    YOMP.app.config.loadConfig()
    res = {}

    if section != "usertrack":
      # Everything but usertrack requires authentication...
      apikey = AuthenticatedBaseHandler.extractAuthHeader()
      authResult = AuthenticatedBaseHandler.compareAuthorization(apikey)

      if authResult is False:
        AuthenticatedBaseHandler.raiseAuthFailure()

    if section in self.validSections():
      for key, value in YOMP.app.config.items(section):
        if key not in HIDDEN_SETTINGS.get(section, set()):
          res[key] = value
    return res