This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
django-directory/django_directory/schema.py

20 lines
557 B
Python

from . import models
__cached_schema = None
__notify = {}
def schemas_update_subscribe(who, what):
'''Register a function to be notified of schema changes'''
__notify[who] = what
def get_schemas(force=False):
'''Get and cache schema objects'''
global __cached_schema
if __cached_schema is None or force:
__cached_schema = list(models.Schema.objects.prefetch_related('views', 'object_of', 'value_of', 'views__attributes'))
if force:
for what in __notify.itervalues():
what()
return __cached_schema