Nessuna descrizione
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 998B

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