Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/render/xml/__init__.py: 0%
29 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
1from .default import DefaultRender as default, serializeXML
2from .user import UserRender as user
3from viur.core import Module, conf, securitykey
4from viur.core.decorators import *
5import datetime
7__all__ = [default]
10@exposed
11def genSkey(*args, **kwargs):
12 return f"<securityKey>{securitykey.create()}</securityKey>"
15@exposed
16def timestamp(*args, **kwargs):
17 d = datetime.datetime.now()
18 return serializeXML(d.strftime("%Y-%m-%dT%H-%M-%S"))
21@exposed
22def dumpConfig():
23 res = {}
24 for key in dir(conf.main_app.xml):
25 module = getattr(conf.main_app.xml, key)
26 if not isinstance(module, Module):
27 continue
28 if admin_info := module.describe():
29 res[key] = admin_info
31 res = {
32 "modules": res,
33 "configuration": {
34 k.removeprefix("admin."): v for k, v in conf.items() if k.lower().startswith("admin.")
35 }
36 }
37 return res
40def _postProcessAppObj(obj):
41 obj["skey"] = genSkey
42 obj["timestamp"] = timestamp
43 obj["config"] = dumpConfig
44 return obj