Exemplo n.º 1
0
  def put(self, key=config.CONFIG_SINGLETON_KEY):
    model_key = ndb.Key(config.Configuration, key)
    old_model = model_key.get()
    if not old_model:
      raise NotFound('{} with key {} does not exist'.format('Configuration', key))
    # the history mechanism doesn't work unless we make a copy.  So a put is always a clone, never
    # an actual update.
    model = config.Configuration(**old_model.to_dict())
    model.key = model_key
    model.configuration = request.get_json(force=True)
    self.validate(model)

    date = None
    if config.getSettingJson(config.ALLOW_NONPROD_REQUESTS, False):
      date = request.headers.get('x-pretend-date', None)
    if date is not None:
      date = parse_date(date)

    client_id = app_util.get_oauth_id()

    config.store(model, date=date, client_id=client_id)
    return model.configuration
Exemplo n.º 2
0
def lookup_user_info(user_email):
  return config.getSettingJson(config.USER_INFO, {}).get(user_email)
Exemplo n.º 3
0
 def wrapped(*args, **kwargs):
   if not config.getSettingJson(config.ALLOW_NONPROD_REQUESTS, False):
     raise Forbidden('Request not allowed in production environment (according to config).')
   return func(*args, **kwargs)
Exemplo n.º 4
0
def _is_self_request():
  return (request.remote_addr is None
      and config.getSettingJson(config.ALLOW_NONPROD_REQUESTS, False)
      and not request.headers.get('unauthenticated'))
Exemplo n.º 5
0
def _consider_fake_date():
    if config.getSettingJson(config.ALLOW_NONPROD_REQUESTS, False):
        date = request.headers.get('x-pretend-date', None)
        if date:
            return api_util.parse_date(date)
    return None