Example #1
0
def dumpConfig(adminTree):
    adminConfig = {}
    for key in dir(adminTree):
        app = getattr(adminTree, key)
        if "adminInfo" in dir(app) and app.adminInfo:
            if callable(app.adminInfo):
                info = app.adminInfo()
                if info is not None:
                    adminConfig[key] = info
            else:
                adminConfig[key] = app.adminInfo.copy()
                adminConfig[key]["name"] = str(adminConfig[key]["name"])
                adminConfig[key]["views"] = []
                if "views" in app.adminInfo:
                    for v in app.adminInfo["views"]:
                        tmp = v.copy()
                        tmp["name"] = str(tmp["name"])
                        adminConfig[key]["views"].append(tmp)
    res = {
        "capabilities": conf["viur.capabilities"],
        "modules": adminConfig,
        "configuration": {}
    }
    for k, v in conf.items():
        if k.lower().startswith("admin."):
            res["configuration"][k[6:]] = v

    currentRequest.get().response.headers["Content-Type"] = "application/json"
    return json.dumps(res)
Example #2
0
def dumpConfig(adminTree):
    adminConfig = {}
    for key in dir(adminTree):
        app = getattr(adminTree, key)
        if "adminInfo" in dir(app) and app.adminInfo:
            if callable(app.adminInfo):
                info = app.adminInfo()
                if info is not None:
                    adminConfig[key] = info
            else:
                adminConfig[key] = app.adminInfo.copy()
                adminConfig[key]["name"] = str(adminConfig[key]["name"])
                adminConfig[key]["views"] = []
                if "views" in app.adminInfo:
                    for v in app.adminInfo["views"]:
                        tmp = v.copy()
                        tmp["name"] = str(tmp["name"])
                        adminConfig[key]["views"].append(tmp)
    res = {
        "capabilities": conf["viur.capabilities"],
        "modules": adminConfig,
        "configuration": {}
    }
    for k, v in conf.items():
        if k.lower().startswith("admin."):
            res["configuration"][k[6:]] = v

    if "viur.defaultlangs" in conf:
        res["viur.defaultlangs"] = conf["viur.defaultlangs"]
    if "viur.defaultlangsvalues" in conf:
        res["viur.defaultlangsvalues"] = conf["viur.defaultlangsvalues"]
    return json.dumps(res)