Esempio n. 1
0
            instance_identifier = uuid.uuid4()
            self.settings.set("instance_identifier", str(instance_identifier))
        else:
            instance_identifier = uuid.UUID(instance_identifier)
        return instance_identifier


def i18n_unserialise(value):
    try:
        return LazyI18nString(json.loads(value))
    except ValueError:
        return LazyI18nString(str(value))


hierarkey.add_type(LazyI18nString,
                   serialize=lambda s: json.dumps(s.data),
                   unserialize=i18n_unserialise)

hierarkey.add_default("show_schedule", "True", bool)
hierarkey.add_default("schedule_display", "proportional", str)
hierarkey.add_default("show_featured", "pre_schedule",
                      str)  # always, never, pre-schedule
hierarkey.add_default("show_widget_if_not_public", "False", bool)
hierarkey.add_default("export_html_on_schedule_release", "False", bool)
hierarkey.add_default("imprint_url", None, str)
hierarkey.add_default("html_export_url", "", str)
hierarkey.add_default("custom_domain", "", str)
hierarkey.add_default("use_tracks", "True", bool)
hierarkey.add_default("present_multiple_times", "False", bool)

hierarkey.add_default("display_header_pattern", "", str)
Esempio n. 2
0
settings_hierarkey = Hierarkey(attribute_name='settings')

for k, v in DEFAULTS.items():
    settings_hierarkey.add_default(k, v['default'], v['type'])


def i18n_uns(v):
    try:
        return LazyI18nString(json.loads(v))
    except ValueError:
        return LazyI18nString(str(v))


settings_hierarkey.add_type(LazyI18nString,
                            serialize=lambda s: json.dumps(s.data),
                            unserialize=i18n_uns)
settings_hierarkey.add_type(
    RelativeDateWrapper,
    serialize=lambda rdw: rdw.to_string(),
    unserialize=lambda s: RelativeDateWrapper.from_string(s))


@settings_hierarkey.set_global(cache_namespace='global')
class GlobalSettingsObject(GlobalSettingsBase):
    slug = '_global'


class SettingsSandbox:
    """
    Transparently proxied access to event settings, handling your prefixes for you.
Esempio n. 3
0
settings_hierarkey = Hierarkey(attribute_name='settings')

for k, v in DEFAULTS.items():
    settings_hierarkey.add_default(k, v['default'], v['type'])


def i18n_uns(v):
    try:
        return LazyI18nString(json.loads(v))
    except ValueError:
        return LazyI18nString(str(v))


settings_hierarkey.add_type(LazyI18nString,
                            serialize=lambda s: json.dumps(s.data),
                            unserialize=i18n_uns)
settings_hierarkey.add_type(RelativeDateWrapper,
                            serialize=lambda rdw: rdw.to_string(),
                            unserialize=lambda s: RelativeDateWrapper.from_string(s))


@settings_hierarkey.set_global(cache_namespace='global')
class GlobalSettingsObject(GlobalSettingsBase):
    slug = '_global'


class SettingsSandbox:
    """
    Transparently proxied access to event settings, handling your prefixes for you.