예제 #1
0
    def set(self, name, value):
        """Sets a single setting.

        :param name: Setting name
        :param value: Setting value; must be JSON-serializable
        """
        self._check_name(name)
        Setting.set(self.module, name, self._convert_from_python(name, value))
        self._flush_cache()
예제 #2
0
파일: proxy.py 프로젝트: imfht/flaskapps
    def set(self, name, value):
        """Set a single setting.

        :param name: Setting name
        :param value: Setting value; must be JSON-serializable
        """
        self._check_name(name)
        Setting.set(self.module, name, self._convert_from_python(name, value))
        self._flush_cache()
예제 #3
0
def test_set_enum():
    class Useless(int, Enum):
        thing = 1337

    Setting.set_multi('foo', {'foo': Useless.thing})
    Setting.set('foo', 'bar', Useless.thing)
    for key in {'foo', 'bar'}:
        value = Setting.get('foo', key)
        assert value == Useless.thing
        assert value == Useless.thing.value
        assert not isinstance(value, Useless)  # we store it as a plain value!