class StorePublisher(plugins.SingletonPlugin):

    plugins.implements(plugins.IConfigurer)
    plugins.implements(plugins.IPackageController, inherit=True)
    plugins.implements(plugins.IRoutes, inherit=True)

    def __init__(self, name=None):
        self._store_connector = StoreConnector(config)

    def update_config(self, config):
        # Add this plugin's templates dir to CKAN's extra_template_paths, so
        # that CKAN will use this plugin's custom templates.
        plugins.toolkit.add_template_directory(config, 'templates')

        # Register this plugin's fanstatic directory with CKAN.
        plugins.toolkit.add_resource('fanstatic', 'baepublisher')

    def before_map(self, m):
        # Publish data offering controller
        m.connect('dataset_publish', '/dataset/publish/{id}', action='publish',
                  controller='ckanext.baepublisher.controllers.ui_controller:PublishControllerUI',
                  ckan_icon='shopping-cart')
        return m

    ######################################################################
    ######################### IPACKAGECONTROLLER #########################
    ######################################################################

    def after_delete(self, context, pkg_dict):

        dataset = plugins.toolkit.get_action('package_show')(context, pkg_dict)
        self._store_connector.delete_attached_resources(dataset)

        return pkg_dict
Exemplo n.º 2
0
class StorePublisher(plugins.SingletonPlugin):

    plugins.implements(plugins.IConfigurer)
    plugins.implements(plugins.IPackageController, inherit=True)
    plugins.implements(plugins.IRoutes, inherit=True)

    def __init__(self, name=None):
        self._store_connector = StoreConnector(config)

    def update_config(self, config):
        # Add this plugin's templates dir to CKAN's extra_template_paths, so
        # that CKAN will use this plugin's custom templates.
        plugins.toolkit.add_template_directory(config, 'templates')

        # Register this plugin's fanstatic directory with CKAN.
        plugins.toolkit.add_resource('fanstatic', 'storepublisher')

    def before_map(self, m):
        # Publish data offering controller
        m.connect('dataset_publish', '/dataset/publish/{id}', action='publish',
                  controller='ckanext.storepublisher.controllers.ui_controller:PublishControllerUI',
                  ckan_icon='shopping-cart')
        return m

    ######################################################################
    ######################### IPACKAGECONTROLLER #########################
    ######################################################################

    def after_delete(self, context, pkg_dict):

        dataset = plugins.toolkit.get_action('package_show')(context, pkg_dict)
        self._store_connector.delete_attached_resources(dataset)

        return pkg_dict
 def __init__(self, name=None):
     self._store_connector = StoreConnector(config)
Exemplo n.º 4
0
 def __init__(self, name=None):
     self._store_connector = StoreConnector(config)