Exemplo n.º 1
0
    def teardown_class(cls):
        plugins.unload('example_idatasetform_v4')
        helpers.reset_db()
        ckan.lib.search.clear_all()

        config.clear()
        config.update(cls.original_config)
Exemplo n.º 2
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c    
    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    
    
    def mapResource(config_key, member_name, collection_name):
        try:
            service_doc_id = config[config_key]
            service_doc = h.getServiceDocument(service_doc_id)
            if service_doc is not None and service_doc["active"]:
                map.resource(member_name, collection_name)
                map.connect("/"+collection_name,controller=collection_name,action='options',conditions=dict(method=['OPTIONS']))
                if member_name == 'swordservice':
                    map.connect("/swordpub",controller='swordservice',action='create')
                
                if member_name == 'distribute':
                    map.connect("/destination", controller='distribute', action='destination',
                                          conditions=dict(method='GET'))
                log.info("Enabling service route for: {0} member: {1} collection: {2}".format(service_doc_id, member_name, collection_name))
            else:
                log.info("Service route for {0} is disabled".format(service_doc_id))
        except:
                log.exception("Exception caught: Not enabling service route for config: {0} member: {1} collection: {2}".format(config_key, member_name, collection_name))
            
    
    map.resource('filter', 'filters', controller='contrib/filters', 
        path_prefix='/contrib', name_prefix='contrib_')
    map.resource("register","register")
    mapResource('lr.status.docid', 'status','status')
    mapResource('lr.distribute.docid','distribute','distribute')
    if not LRNode.nodeDescription.gateway_node:
        mapResource('lr.publish.docid', 'publish','publish')
        mapResource('lr.obtain.docid', 'obtain','obtain')        
        mapResource('lr.description.docid', 'description','description')
        mapResource('lr.services.docid', 'services','services')
        mapResource('lr.policy.docid', 'policy','policy')
        mapResource('lr.harvest.docid','harvest','harvest')
        # Value added services
        mapResource('lr.oaipmh.docid', 'OAI-PMH', 'OAI-PMH')
        mapResource('lr.slice.docid', 'slice', 'slice')
        mapResource('lr.sword.docid', 'swordservice','swordservice')    
    map.connect("/extract/{dataservice}/{view}",controller='extract', action='get', list='to-json')
    map.connect("/extract/{dataservice}/{view}/format/{list}",controller='extract', action='get')
    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')
    
    # CUSTOM ROUTES HERE
    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')
    return map
Exemplo n.º 3
0
    def teardown_class(cls):
        config.clear()
        config.update(cls._original_config)
        new_authz.clear_auth_functions_cache()
        PylonsTestCase.teardown_class()

        model.repo.rebuild_db()
Exemplo n.º 4
0
    def teardown_class(cls):
        model.Session.remove()
        # model.repo.rebuild_db()

        config.clear()
        config.update(cls.original_config)
        logic._actions['package_create'] = original_package_create
Exemplo n.º 5
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c
    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])

    def mapResource(config_key, member_name, collection_name):
        try:
            service_doc_id = config[config_key]
            service_doc = h.getServiceDocument(service_doc_id)
            if service_doc is not None and service_doc["active"]:
                map.resource(member_name, collection_name)
                if member_name == 'swordservice':
                    map.connect("/swordpub",
                                controller='swordservice',
                                action='create')
                log.info(
                    "Enabling service route for: {0} member: {1} collection: {2}"
                    .format(service_doc_id, member_name, collection_name))
            else:
                log.info(
                    "Service route for {0} is disabled".format(service_doc_id))
        except:
            log.exception(
                "Exception caught: Not enabling service route for config: {0} member: {1} collection: {2}"
                .format(config_key, member_name, collection_name))

    map.resource('filter',
                 'filters',
                 controller='contrib/filters',
                 path_prefix='/contrib',
                 name_prefix='contrib_')
    mapResource('lr.status.docid', 'status', 'status')
    mapResource('lr.distribute.docid', 'distribute', 'distribute')
    if not LRNode.nodeDescription.gateway_node:
        mapResource('lr.publish.docid', 'publish', 'publish')
        mapResource('lr.obtain.docid', 'obtain', 'obtain')
        mapResource('lr.description.docid', 'description', 'description')
        mapResource('lr.services.docid', 'services', 'services')
        mapResource('lr.policy.docid', 'policy', 'policy')
        mapResource('lr.harvest.docid', 'harvest', 'harvest')
        # Value added services
        mapResource('lr.oaipmh.docid', 'OAI-PMH', 'OAI-PMH')
        mapResource('lr.slice.docid', 'slice', 'slice')
        mapResource('lr.sword.docid', 'swordservice', 'swordservice')
    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')
    return map
Exemplo n.º 6
0
    def teardown_class(cls):
        config.clear()
        config.update(cls._original_config)
        new_authz.clear_auth_functions_cache()
        PylonsTestCase.teardown_class()

        model.repo.rebuild_db()
Exemplo n.º 7
0
    def teardown_class(cls):
        helpers.reset_db()
        model.repo.rebuild_db()
        ckan.lib.search.clear_all()

        config.clear()
        config.update(cls.original_config)
Exemplo n.º 8
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     model.repo.rebuild_db()
     # Reenable Solr indexing
     if (sys.version_info[0] == 2 and sys.version_info[1] == 6
             and not p.plugin_loaded('synchronous_search')):
         p.load('synchronous_search')
Exemplo n.º 9
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     model.repo.rebuild_db()
     # Reenable Solr indexing
     if (sys.version_info[0] == 2 and sys.version_info[1] == 6
             and not p.plugin_loaded('synchronous_search')):
         p.load('synchronous_search')
Exemplo n.º 10
0
        def wrapper(*args, **kwargs):
            _original_config = config.copy()
            config[key] = value

            return_value = func(*args, **kwargs)

            config.clear()
            config.update(_original_config)

            return return_value
Exemplo n.º 11
0
        def wrapper(*args, **kwargs):
            _original_config = config.copy()
            config[key] = value

            return_value = func(*args, **kwargs)

            config.clear()
            config.update(_original_config)

            return return_value
Exemplo n.º 12
0
        def wrapper(*args, **kwargs):
            _original_config = config.copy()
            config[key] = value
            new_authz.clear_auth_functions_cache()

            return_value = func(*args, **kwargs)

            config.clear()
            config.update(_original_config)
            new_authz.clear_auth_functions_cache()

            return return_value
Exemplo n.º 13
0
        def wrapper(*args, **kwargs):
            _original_config = config.copy()
            config[key] = value
            new_authz.clear_auth_functions_cache()

            return_value = func(*args, **kwargs)

            config.clear()
            config.update(_original_config)
            new_authz.clear_auth_functions_cache()

            return return_value
Exemplo n.º 14
0
    def test_profiles_via_config_option(self):

        original_config = config.copy()

        config[RDF_PROFILES_CONFIG_OPTION] = 'profile_conf_1 profile_conf_2'
        try:
            RDFParser()
        except RDFProfileException as e:

            eq_(str(e), 'Unknown RDF profiles: profile_conf_1, profile_conf_2')

        config.clear()
        config.update(original_config)
Exemplo n.º 15
0
    def test_profiles_via_config_option(self):

        original_config = config.copy()

        config[RDF_PROFILES_CONFIG_OPTION] = 'profile_conf_1 profile_conf_2'
        try:
            RDFParser()
        except RDFProfileException as e:

            eq_(str(e), 'Unknown RDF profiles: profile_conf_1, profile_conf_2')

        config.clear()
        config.update(original_config)
Exemplo n.º 16
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='fts3rest', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = fts3rest.lib.helpers

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # If fts3.config is set, load configuration from there
    if config.get('fts3.config'):
        fts3cfg = fts3rest.lib.helpers.fts3_config_load(
            config.get('fts3.config'))
        config.update(fts3cfg)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8',
        default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # Setup the SQLAlchemy database engine
    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)

    return config
Exemplo n.º 17
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='fts3rest', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = fts3rest.lib.helpers
    
    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)
    
    # If fts3.config is set, load configuration from there
    if config.get('fts3.config'):
        fts3cfg = fts3rest.lib.helpers.fts3_config_load(config.get('fts3.config'))
        config.update(fts3cfg)            

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # Setup the SQLAlchemy database engine
    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    
    return config
Exemplo n.º 18
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c
    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])

    map.resource('filter',
                 'filters',
                 controller='contrib/filters',
                 path_prefix='/contrib',
                 name_prefix='contrib_')

    map.resource('distribute', 'distribute')
    if not LRNode.nodeDescription.gateway_node:
        map.resource('publish', 'publish')
        map.resource('obtain', 'obtain')
        map.resource('status', 'status')
        map.resource('description', 'description')
        map.resource('services', 'services')
        map.resource('policy', 'policy')
        map.resource('harvest', 'harvest')
        # Value added services
        map.resource('OAI-PMH', 'OAI-PMH')
        map.resource('sword', 'sword')
        map.resource('slice', 'slices')

    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE

    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')

    return map
Exemplo n.º 19
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c

    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config["pylons.paths"]["controllers"], always_scan=config["debug"])

    map.resource("filter", "filters", controller="contrib/filters", path_prefix="/contrib", name_prefix="contrib_")

    map.resource("distribute", "distribute")
    if not LRNode.nodeDescription.gateway_node:
        map.resource("publish", "publish")
        map.resource("obtain", "obtain")
        map.resource("status", "status")
        map.resource("description", "description")
        map.resource("services", "services")
        map.resource("policy", "policy")
        map.resource("harvest", "harvest")
        # Value added services
        map.resource("OAI-PMH", "OAI-PMH")
        map.resource("sword", "sword")
        map.resource("slice", "slices")

    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect("/error/{action}", controller="error")
    map.connect("/error/{action}/{id}", controller="error")

    # CUSTOM ROUTES HERE

    map.connect("/{controller}/{action}")
    map.connect("/{controller}/{action}/{id}")

    return map
Exemplo n.º 20
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c    
    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])

    map.resource('filter', 'filters', controller='contrib/filters', 
        path_prefix='/contrib', name_prefix='contrib_')
    map.resource('status','status')
    map.resource('distribute','distribute')    
    if not LRNode.nodeDescription.gateway_node:
        map.resource('publish','publish')
        map.resource('obtain','obtain')        
        map.resource('description','description')
        map.resource('services','services')
        map.resource('policy','policy')
        map.resource('harvest','harvest')
        # Value added services
        map.resource('OAI-PMH', 'OAI-PMH')
        map.resource('swordservice','swordservice')
        map.resource('slice', 'slice')
    
    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE

    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')

    return map
Exemplo n.º 21
0
 def teardown_class(cls):
     # Restore the Pylons config to its original values, in case any tests
     # changed any config settings.
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 22
0
                        help='Make the output more human readable')
    parser.add_argument('-p', '--profile', nargs='*',
                        action='store',
                        help='RDF Profiles to use, defaults to euro_dcat_ap')
    parser.add_argument('-m', '--compat-mode',
                        action='store_true',
                        help='Enable compatibility mode')

    parser.add_argument('-s', '--subcatalogs', action='store_true', dest='subcatalogs',
                        default=False,
                        help="Enable subcatalogs handling (dct:hasPart support)")
    args = parser.parse_args()

    contents = args.file.read()

    config.update({DCAT_EXPOSE_SUBCATALOGS: args.subcatalogs})

    if args.mode == 'produce':
        serializer = RDFSerializer(profiles=args.profile,
                                   compatibility_mode=args.compat_mode)

        dataset = json.loads(contents)
        out = serializer.serialize_dataset(dataset, _format=args.format)
        print out
    else:
        parser = RDFParser(profiles=args.profile,
                           compatibility_mode=args.compat_mode)

        parser.parse(contents, _format=args.format)

        ckan_datasets = [d for d in parser.datasets()]
Exemplo n.º 23
0
 def teardown_class(cls):
     helpers.rebuild_all_dbs(cls.Session)
     p.unload('datastore')
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 24
0
    def teardown_class(cls):
        config.clear()
        config.update(cls._original_config)
        PylonsTestCase.teardown_class()

        model.repo.rebuild_db()
Exemplo n.º 25
0
# the developer. Basically, it grabs the current variable_provider from the
# config, puts the tgext.menu variable provider into the config, and then
# returns the results from its own plus the original variable provider.
#
# By doing this, the developer does not have to remember to update the
# variable provider to provide the functions that the README says should be
# available in all templates.
def menu_variable_provider():
    menu_vars = Bunch (
        url_from_menu = url_from_menu,
        render_menu = render_menu,
        render_navbar = render_navbar,
        render_sidebar = render_sidebar,
    )
    
    try:
        from genshi import HTML
        menu_vars['HTML'] = HTML
    except ImportError:
        pass
    
    if app_variable_provider:
        menu_vars.update(app_variable_provider())

    return menu_vars

app_variable_provider = config.get('tgext_menu_sub_variable_provider', None)
config.update(Bunch(
    variable_provider = menu_variable_provider
    ))
Exemplo n.º 26
0
    def teardown_class(cls):
        config.clear()
        config.update(cls._original_config)

        model.repo.rebuild_db()
Exemplo n.º 27
0
 def teardown_class(cls):
     # Restore the Pylons config to its original values, in case any tests
     # changed any config settings.
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 28
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     plugins.reset()
     create_test_data.CreateTestData.delete()
Exemplo n.º 29
0
# The below code is a bit of magic to make the usage of tgext.menu easier on
# the developer. Basically, it grabs the current variable_provider from the
# config, puts the tgext.menu variable provider into the config, and then
# returns the results from its own plus the original variable provider.
#
# By doing this, the developer does not have to remember to update the
# variable provider to provide the functions that the README says should be
# available in all templates.
def menu_variable_provider():
    menu_vars = Bunch(
        url_from_menu=url_from_menu,
        render_menu=render_menu,
        render_navbar=render_navbar,
        render_sidebar=render_sidebar,
    )

    try:
        from genshi import HTML
        menu_vars['HTML'] = HTML
    except ImportError:
        pass

    if app_variable_provider:
        menu_vars.update(app_variable_provider())

    return menu_vars


app_variable_provider = config.get('tgext_menu_sub_variable_provider', None)
config.update(Bunch(variable_provider=menu_variable_provider))
Exemplo n.º 30
0
 def teardown_class(self):
     config.clear()
     config.update(self._original_config)
     mock_mail_server.SmtpServerHarness.teardown_class()
     pylons_controller.PylonsTestCase.teardown_class()
     model.repo.rebuild_db()
Exemplo n.º 31
0
    def teardown_class(cls):
        model.Session.remove()
        model.repo.rebuild_db()

        config.clear()
        config.update(cls.original_config)
Exemplo n.º 32
0
def make_map(config):
    """Create, configure and return the routes Mapper"""
    from pylons import config as c

    c.update(config)
    from lr.model import LRNode

    map = Mapper(directory=config["pylons.paths"]["controllers"], always_scan=config["debug"])

    def mapResource(config_key, member_name, collection_name):
        try:
            service_doc_id = config[config_key]
            service_doc = h.getServiceDocument(service_doc_id)
            if service_doc is not None and service_doc["active"]:
                map.resource(member_name, collection_name)
                map.connect(
                    "/" + collection_name,
                    controller=collection_name,
                    action="options",
                    conditions=dict(method=["OPTIONS"]),
                )
                if member_name == "swordservice":
                    map.connect("/swordpub", controller="swordservice", action="create")

                if member_name == "distribute":
                    map.connect(
                        "/destination", controller="distribute", action="destination", conditions=dict(method="GET")
                    )
                log.info(
                    "Enabling service route for: {0} member: {1} collection: {2}".format(
                        service_doc_id, member_name, collection_name
                    )
                )
            else:
                log.info("Service route for {0} is disabled".format(service_doc_id))
        except:
            log.exception(
                "Exception caught: Not enabling service route for config: {0} member: {1} collection: {2}".format(
                    config_key, member_name, collection_name
                )
            )

    map.resource("filter", "filters", controller="contrib/filters", path_prefix="/contrib", name_prefix="contrib_")
    map.resource("register", "register")
    map.connect("/newauth/", controller="newauth", action="update")
    map.resource("pubkey", "pubkey")
    mapResource("lr.status.docid", "status", "status")
    mapResource("lr.distribute.docid", "distribute", "distribute")
    if not LRNode.nodeDescription.gateway_node:
        mapResource("lr.publish.docid", "publish", "publish")
        mapResource("lr.obtain.docid", "obtain", "obtain")
        mapResource("lr.description.docid", "description", "description")
        mapResource("lr.services.docid", "services", "services")
        mapResource("lr.policy.docid", "policy", "policy")
        mapResource("lr.harvest.docid", "harvest", "harvest")
        # Value added services
        mapResource("lr.oaipmh.docid", "OAI-PMH", "OAI-PMH")
        mapResource("lr.slice.docid", "slice", "slice")
        mapResource("lr.sword.docid", "swordservice", "swordservice")
    map.connect("/extract/{dataservice}/{view}", controller="extract", action="get", list="to-json")
    map.connect("/extract/{dataservice}/{view}/format/{list}", controller="extract", action="get")
    map.minimization = False
    map.explicit = False

    # The ErrorController route (handles 404/500 error pages); it should
    # likely stay at the top, ensuring it can always be resolved
    map.connect("/error/{action}", controller="error")
    map.connect("/error/{action}/{id}", controller="error")

    # CUSTOM ROUTES HERE
    map.connect("/{controller}/{action}")
    map.connect("/{controller}/{action}/{id}")

    map.resource("auth", "auth")
    return map
Exemplo n.º 33
0
 def teardown_class(cls):
     helpers.rebuild_all_dbs(cls.Session)
     p.unload('datastore')
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 34
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     model.repo.rebuild_db()
Exemplo n.º 35
0
class CustomOrgController(org.OrganizationController,
                          search_controller.HDXSearchController):
    def org_read(self, id, org_meta=None):
        '''

        :param id: The id of the organization
        :type id: str
        :param org_meta: Information about the organization
        :type org_meta: org_meta_dao.OrgMetaDao
        :return:
        '''

        if not org_meta:
            log.info(
                "No org meta. Should have been created in organization_controller.py. Trying to create one now. "
            )
            org_meta = org_meta_dao.OrgMetaDao(id, c.user or c.author,
                                               c.userobj)
        c.org_meta = org_meta

        org_info = self.get_org(org_meta)

        if self._is_facet_only_request():
            c.full_facet_info = self.get_dataset_search_results(
                org_info['name'])
            response.headers['Content-Type'] = CONTENT_TYPES['json']
            return json.dumps(c.full_facet_info)
        else:
            template_data = self.generate_template_data(org_info)

            result = render('organization/custom/custom_org.html',
                            extra_vars=template_data)

            return result

    def assemble_viz_config(self, vis_json_config, org_id=None):
        try:
            visualization = json.loads(vis_json_config)
        except Exception, e:
            log.warning(e)
            return "{}"

        config = {
            'title': visualization.get('viz-title', ''),
            'data_link_url': visualization.get('viz-data-link-url', '#'),
            'type': visualization.get('visualization-select', '')
        }

        if visualization.get('visualization-select', '') == 'ROEA':
            config.update({
                'data':
                "/api/action/datastore_search?resource_id=" +
                visualization.get('viz-resource-id', '') + "&limit=10000000",
                'geo':
                h.url_for(controller='package',
                          action='resource_download',
                          id=visualization.get('viz-geo-dataset-id', ''),
                          resource_id=visualization.get(
                              'viz-geo-resource-id', '')),
                'source':
                visualization.get('viz-data-source', '')
            })

        if visualization.get(
                'visualization-select', '') == 'embedded' or visualization.get(
                    'visualization-select', '') == 'embedded-preview':
            config.update({
                'title':
                visualization.get('vis-title', ''),
                'data_link_url':
                visualization.get('vis-data-link-url', ''),
                'vis_url':
                visualization.get('vis-url', ''),
                'height':
                visualization.get('vis-height', '600px')
                if visualization.get('vis-height', '600px') != '' else '600px',
                'width':
                visualization.get('vis-width', '100%')
                if visualization.get('vis-width', '100%') != '' else '100%',
                'selector':
                visualization.get('vis-preview-selector', ''),
                'embedded_preview':
                h.url_for('image_serve',
                          label=org_id + '_embedded_preview.png')
            })

        if visualization.get('visualization-select', '') == 'WFP':
            config.update({
                'embedded':
                "true",
                'datastore_id':
                visualization.get('viz-resource-id', '')
            })

        else:
            if visualization.get('datatype_1', '') == 'filestore':
                datatype = "filestore"
                data = h.url_for(controller='package',
                                 action='resource_download',
                                 id=visualization.get('dataset_id_1', ''),
                                 resource_id=visualization.get(
                                     'resource_id_1', ''))
            else:
                datatype = "datastore"
                data = "/api/action/datastore_search?resource_id=" + visualization.get(
                    'resource_id_1', '') + "&limit=10000000"

            if visualization.get('datatype_2', '') == 'filestore':
                geotype = "filestore"
                geo = h.url_for(controller='package',
                                action='resource_download',
                                id=visualization.get('dataset_id_2', ''),
                                resource_id=visualization.get(
                                    'resource_id_2', ''))
            else:
                geotype = "datastore"
                geo = "/api/action/datastore_search?resource_id=" + visualization.get(
                    'resource_id_2', '') + "&limit=10000000"

            # beware that visualisation type constants are also used
            # in the template to select different resource bundles
            if visualization.get('visualization-select', '') == '3W-dashboard':
                config.update({
                    'datatype':
                    datatype,
                    'data':
                    data,
                    'whoFieldName':
                    visualization.get('who-column', ''),
                    'whatFieldName':
                    visualization.get('what-column', ''),
                    'whereFieldName':
                    visualization.get('where-column', ''),
                    'startFieldName':
                    visualization.get('start-column', ''),
                    'endFieldName':
                    visualization.get('end-column', ''),
                    'formatFieldName':
                    visualization.get('format-column', ''),
                    'geotype':
                    geotype,
                    'geo':
                    geo,
                    'joinAttribute':
                    visualization.get('where-column-2', ''),
                    'nameAttribute':
                    visualization.get('map_district_name_column', ''),
                    'colors':
                    visualization.get('colors', '')
                })

        return config
Exemplo n.º 36
0
 def fake_conf(**kwargs):
     from pylons import config
     config = {}
     config['use_gravatar'] = True
     config.update(kwargs)
     return config
Exemplo n.º 37
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
     CreateTestData.delete()
Exemplo n.º 38
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 39
0
 def teardown_class(cls):
     config.clear()
     config.update(cls._original_config)
Exemplo n.º 40
0
 def fake_conf(**kwargs):
     from pylons import config
     config = {}
     config['use_gravatar'] = True
     config.update(kwargs)
     return config
Exemplo n.º 41
0
    def teardown_class(cls):
        config.clear()
        config.update(cls._original_config)
        PylonsTestCase.teardown_class()

        model.repo.rebuild_db()
Exemplo n.º 42
0
 def teardown_class(self):
     config.clear()
     config.update(self._original_config)
     mock_mail_server.SmtpServerHarness.teardown_class()
     pylons_controller.PylonsTestCase.teardown_class()
     model.repo.rebuild_db()
Exemplo n.º 43
0
                        help='Make the output more human readable')
    parser.add_argument('-p', '--profile', nargs='*',
                        action='store',
                        help='RDF Profiles to use, defaults to euro_dcat_ap')
    parser.add_argument('-m', '--compat-mode',
                        action='store_true',
                        help='Enable compatibility mode')

    parser.add_argument('-s', '--subcatalogs', action='store_true', dest='subcatalogs',
                        default=False,
                        help="Enable subcatalogs handling (dct:hasPart support)")
    args = parser.parse_args()

    contents = args.file.read()

    config.update({DCAT_EXPOSE_SUBCATALOGS: args.subcatalogs})

    if args.mode == 'produce':
        serializer = RDFSerializer(profiles=args.profile,
                                   compatibility_mode=args.compat_mode)

        dataset = json.loads(contents)
        out = serializer.serialize_dataset(dataset, _format=args.format)
        print out
    else:
        parser = RDFParser(profiles=args.profile,
                           compatibility_mode=args.compat_mode)

        parser.parse(contents, _format=args.format)

        ckan_datasets = [d for d in parser.datasets()]