Piki is a minimal wiki
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parameter.py 715B

123456789101112131415161718192021222324252627282930313233343536
  1. import config
  2. from django.conf import settings
  3. import importlib
  4. import os
  5. CMS_MODE = "CMS_MODE"
  6. def no_access(*args, **kwargs):
  7. return False
  8. DEFAULTS = {
  9. CMS_MODE: False,
  10. }
  11. def __get_object_by_name__(object_name):
  12. class_data = object_name.split(".")
  13. module_path = ".".join(class_data[:-1])
  14. class_str = class_data[-1]
  15. #
  16. module = importlib.import_module(module_path)
  17. return getattr(module, class_str)
  18. def get(key):
  19. # take data from config, settings or defaults
  20. try:
  21. data = getattr(config, key)
  22. except AttributeError:
  23. try:
  24. data = getattr(settings, key)
  25. except AttributeError:
  26. data = DEFAULTS.get(key)
  27. return data