Beispiel #1
0
def get_formats(config: CKANConfig) -> dict[str, list[str]]:
    out = {}

    out["text_formats"] = config.get_value("ckan.preview.text_formats").split()
    out["xml_formats"] = config.get_value("ckan.preview.xml_formats").split()
    out["json_formats"] = config.get_value("ckan.preview.json_formats").split()
    out["jsonp_formats"] = config.get_value(
        "ckan.preview.jsonp_formats").split()

    return out
Beispiel #2
0
    def update_config(self, config: CKANConfig):
        DatastoreBackend.register_backends()
        DatastoreBackend.set_active_backend(config)

        templates_base = config.get_value('ckan.base_templates_folder')

        p.toolkit.add_template_directory(config, templates_base)
        self.backend = DatastoreBackend.get_active_backend()
Beispiel #3
0
    def update_config(self, config: CKANConfig):
        u'''
        Set up the resource library, public directory and
        template directory for the view
        '''

        # https://datatables.net/reference/option/lengthMenu
        self.page_length_choices = config.get_value(
            u'ckan.datatables.page_length_choices')

        self.page_length_choices = [int(i) for i in self.page_length_choices]
        self.state_saving = config.get_value(u'ckan.datatables.state_saving')

        # https://datatables.net/reference/option/stateDuration
        self.state_duration = config.get_value(
            u"ckan.datatables.state_duration")
        self.data_dictionary_labels = config.get_value(
            u"ckan.datatables.data_dictionary_labels")
        self.ellipsis_length = config.get_value(
            u"ckan.datatables.ellipsis_length")
        self.date_format = config.get_value(u"ckan.datatables.date_format")
        self.default_view = config.get_value(u"ckan.datatables.default_view")

        toolkit.add_template_directory(config, u'templates')
        toolkit.add_public_directory(config, u'public')
        toolkit.add_resource(u'public', u'ckanext-datatablesview')
Beispiel #4
0
def _add_served_directory(config_: CKANConfig, relative_path: str,
                          config_var: str):
    """Add extra public/template directories to config."""
    import inspect
    import os

    assert config_var in ("extra_template_paths", "extra_public_paths")
    # we want the filename that of the function caller but they will
    # have used one of the available helper functions
    filename = inspect.stack()[2].filename

    this_dir = os.path.dirname(filename)
    absolute_path = os.path.join(this_dir, relative_path)
    if absolute_path not in config_.get_value(config_var).split(","):
        if config_.get_value(config_var):
            config_[config_var] += "," + absolute_path
        else:
            config_[config_var] = absolute_path
    return absolute_path
Beispiel #5
0
    def configure(self, config: CKANConfig):
        self.config = config

        for config_option in (
                u'ckan.site_url',
                u'ckan.datapusher.url',
        ):
            if not config.get_value(config_option):
                raise Exception(
                    u'Config option `{0}` must be set to use the DataPusher.'.
                    format(config_option))
Beispiel #6
0
 def update_config(self, config: CKANConfig):
     p.toolkit.add_template_directory(config, 'theme/templates')
     self.formats = config.get_value('ckan.preview.video_formats').split()
Beispiel #7
0
 def update_config(self, config: CKANConfig):
     templates_base = config.get_value(u'ckan.base_templates_folder')
     p.toolkit.add_template_directory(config, templates_base)