-
Notifications
You must be signed in to change notification settings - Fork 57
/
registry.py
62 lines (54 loc) · 1.54 KB
/
registry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class RegistryItem(dict):
@property
def types(self) -> tuple:
return tuple(self.values())
class Registry:
apps = []
pages = RegistryItem()
documents = RegistryItem()
images = RegistryItem()
media = RegistryItem()
collections = RegistryItem()
snippets = RegistryItem()
streamfield_blocks = RegistryItem()
django_models = RegistryItem()
settings = RegistryItem()
field_middlewares = {}
# The items in the registry that should be lazy loaded.
lazy_types = (
"pages",
"documents",
"images",
"media",
"collections",
"snippets",
"django_models",
"settings",
)
# Internal use only, do not add to .models method
schema = []
@property
def class_models(self) -> dict:
models: dict = {}
models.update(self.pages)
models.update(self.documents)
models.update(self.images)
models.update(self.collections)
models.update(self.snippets)
models.update(self.django_models)
models.update(self.settings)
return models
@property
def models(self) -> dict:
models: dict = {}
models.update(self.pages)
models.update(self.documents)
models.update(self.images)
models.update(self.collections)
models.update(self.snippets)
models.update(self.streamfield_blocks)
models.update(self.django_models)
models.update(self.settings)
return models
# Singleton Registry
registry = Registry()