Brak opisu
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.

settings.py 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #-*- coding: utf-8 -*-
  2. try:
  3. import settings_local
  4. except ImportError:
  5. settings_local = None
  6. class Settings:
  7. # List of accepted settings
  8. datasource = None
  9. @staticmethod
  10. # @throw AttributeError if the setting is not defined in this class
  11. def get(attribute):
  12. value = None
  13. # find the value in settings itself, if not set search in settings_local
  14. value = getattr(Settings, attribute)
  15. if value is None:
  16. try:
  17. value = getattr(settings_local, attribute)
  18. except AttributeError:
  19. pass
  20. if value is not None:
  21. try:
  22. func = getattr(Settings, attribute + '_args')
  23. value = func(value)
  24. except AttributeError:
  25. pass
  26. return value
  27. @staticmethod
  28. # @throw AttributeError if the setting is not defined in this class
  29. def set(attribute, value):
  30. setattr(Settings, attribute, value)
  31. @staticmethod
  32. def datasource_args(value):
  33. return value