Kitware / tangelo

A simple, quick, powerful web framework
http:/tangelohub.org/tangelo/
Apache License 2.0
185 stars 35 forks source link

[RFE] support a _common.yaml #504

Open mathstuf opened 9 years ago

mathstuf commented 9 years ago

Multiple endpoints might want a common configuration settings, so it would be nice to have a _common.yaml file be loaded and then per-endpoint configurations be (recursively) merged in.

Sketch for recursive merging:

def merge(base, *args):
    out = base.copy()
    for arg in args:
        for key, value in arg.items():
            if key not in out:
                out[key] = value
            elif type(key) == list:
                if type(out[key]) == list:
                    out[key] += value
                else:
                    raise
            elif type(key) == dict:
                if type(out[key]) == dict:
                    out[key] = merge(out[key], value)
                else:
                    raise
            else:
                out[key] = value
    return out
mathstuf commented 9 years ago

Using tangelo.yaml available would also suffice (tangelo.global_config()?).