Browse Source

Update config.py

I want to load all of my `CELERY_` options from the config and leave `CELERY_` on there.
pull/1213/head
Bryan Stitt 10 years ago committed by defuz
parent
commit
56a7e8361d
  1. 5
      flask/config.py

5
flask/config.py

@ -213,7 +213,7 @@ class Config(dict):
self[key] = value self[key] = value
return True return True
def get_namespace(self, namespace, lowercase=True): def get_namespace(self, namespace, lowercase=True, trim_namespace=True):
"""Returns a dictionary containing a subset of configuration options """Returns a dictionary containing a subset of configuration options
that match the specified namespace/prefix. Example usage:: that match the specified namespace/prefix. Example usage::
@ -236,6 +236,8 @@ class Config(dict):
:param namespace: a configuration namespace :param namespace: a configuration namespace
:param lowercase: a flag indicating if the keys of the resulting :param lowercase: a flag indicating if the keys of the resulting
dictionary should be lowercase dictionary should be lowercase
:param trim_namespace: a flag indicating if the keys of the resulting
dictionary should not include the namespace
.. versionadded:: 1.0 .. versionadded:: 1.0
""" """
@ -243,6 +245,7 @@ class Config(dict):
for k, v in iteritems(self): for k, v in iteritems(self):
if not k.startswith(namespace): if not k.startswith(namespace):
continue continue
if trim_namespace:
key = k[len(namespace):] key = k[len(namespace):]
if lowercase: if lowercase:
key = key.lower() key = key.lower()

Loading…
Cancel
Save