Skip to content

Commit

Permalink
Merge a61d52f into a190f85
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed May 22, 2020
2 parents a190f85 + a61d52f commit 41ebaf1
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ def main(global_config, **settings):
# Set up atramhasis db
config.include('atramhasis:data.db')

#Add skos support
config.include('{{package}}.skos')

# Set up translations
config.add_translation_dirs('{{package}}:locale/')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,39 @@

import logging

from skosprovider.registry import Registry
from skosprovider.uri import UriPatternGenerator
from skosprovider_sqlalchemy.providers import SQLAlchemyProvider

from skosprovider_getty.providers import AATProvider, TGNProvider
from skosprovider_heritagedata.providers import HeritagedataProvider

from skosprovider_sqlalchemy.providers import SQLAlchemyProvider

import requests
from cachecontrol import CacheControl
from cachecontrol.heuristics import ExpiresAfter

from datetime import date

log = logging.getLogger(__name__)
LICENSES = [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]


def includeme(config):
def create_registry(request):
registry = Registry(instance_scope='threaded_thread')

dataseturigenerator = UriPatternGenerator('https://id.erfgoed.net/datasets/thesauri/%s')

TREES = SQLAlchemyProvider(
{'id': 'TREES', 'conceptscheme_id': 1},
config.registry.dbmaker
request.db
)

GEO = SQLAlchemyProvider(
{'id': 'GEOGRAPHY', 'conceptscheme_id': 2},
config.registry.dbmaker
request.db
)

STYLES = SQLAlchemyProvider(
Expand All @@ -40,13 +46,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2008,2,14)],
'language': ['nl-BE'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/stijlen_en_culturen/%s')
)

Expand All @@ -59,13 +62,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2011,3,16)],
'language': ['nl-BE'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/materialen/%s')
)

Expand All @@ -78,13 +78,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2010,8,13)],
'language': ['nl-BE'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/gebeurtenistypes/%s')
)

Expand All @@ -97,13 +94,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2008,2,14)],
'language': ['nl-BE'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/erfgoedtypes/%s')
)

Expand All @@ -116,13 +110,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2008,2,14)],
'language': ['nl-BE'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/dateringen/%s')
)

Expand All @@ -135,13 +126,10 @@ def includeme(config):
'publisher': ['https://id.erfgoed.net/actoren/501'],
'created': [date(2011,5,23)],
'language': ['nl-BE', 'la'],
'license': [
'https://creativecommons.org/licenses/by/4.0/',
'http://data.vlaanderen.be/doc/licentie/modellicentie-gratis-hergebruik/v1.0'
]
'license': LICENSES
}
},
config.registry.dbmaker,
request.db,
uri_generator=UriPatternGenerator('https://id.erfgoed.net/thesauri/soorten/%s')
)

Expand Down Expand Up @@ -173,16 +161,16 @@ def includeme(config):
session=eh_session
)

skosregis = config.get_skos_registry()
skosregis.register_provider(TREES)
skosregis.register_provider(GEO)
skosregis.register_provider(STYLES)
skosregis.register_provider(MATERIALS)
skosregis.register_provider(EVENTTYPES)
skosregis.register_provider(HERITAGETYPES)
skosregis.register_provider(PERIODS)
skosregis.register_provider(SPECIES)
skosregis.register_provider(AAT)
skosregis.register_provider(TGN)
skosregis.register_provider(EH_PERIOD)
skosregis.register_provider(EH_MONUMENT_TYPE)
registry.register_provider(TREES)
registry.register_provider(GEO)
registry.register_provider(STYLES)
registry.register_provider(MATERIALS)
registry.register_provider(EVENTTYPES)
registry.register_provider(HERITAGETYPES)
registry.register_provider(PERIODS)
registry.register_provider(SPECIES)
registry.register_provider(AAT)
registry.register_provider(TGN)
registry.register_provider(EH_PERIOD)
registry.register_provider(EH_MONUMENT_TYPE)
return registry
3 changes: 3 additions & 0 deletions atramhasis/scaffolds/atramhasis_demo/development.ini_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ sqlalchemy.url = sqlite:///%(here)s/{{package}}.sqlite

atramhasis.session_factory.secret = test123

skosprovider.skosregistry_location = request
skosprovider.skosregistry_factory = {{package}}.skos.create_registry

jinja2.i18n.domain = atramhasis

# Run dojo from source (src) or distribution (dist)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Runtime requirements
--requirement requirements.txt

# Atramhasis dev requirements
--requirement atramhasis-requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# -*- coding: utf-8 -*-
from skosprovider.registry import Registry
from skosprovider.uri import UriPatternGenerator
from skosprovider_sqlalchemy.providers import SQLAlchemyProvider

import logging
log = logging.getLogger(__name__)


def includeme(config):
skosregis = config.get_skos_registry()
def create_registry(request):
# create the SKOS registry
registry = Registry(instance_scope='threaded_thread')

# create your own providers
#
# TREES = SQLAlchemyProvider(
# {'id': 'TREES', 'conceptscheme_id': 1},
# request.db
# )

# Add your custom provider to the registry
# registry.register_provider(TREES)

# return the SKOS registry
return registry
3 changes: 3 additions & 0 deletions atramhasis/scaffolds/atramhasis_scaffold/development.ini_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ sqlalchemy.url = sqlite:///%(here)s/{{package}}.sqlite

atramhasis.session_factory.secret = test123

skosprovider.skosregistry_location = request
skosprovider.skosregistry_factory = {{package}}.skos.create_registry

# cache
cache.tree.backend = dogpile.cache.memory
cache.tree.arguments.cache_size = 5000
Expand Down
19 changes: 11 additions & 8 deletions atramhasis/scripts/import_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,16 @@ def main(argv=sys.argv):
conceptscheme.id
print("\n\n*** The import of the {0} file with conceptscheme label '{1}' to {2} was succesfull. ***\
\n\nTo use the data in Atramhasis, you must edit the file my_thesaurus/skos/__init__.py.\
\nAdd next lines: \
\n\ndef includeme(config):\
\n\t{3} = SQLAlchemyProvider(\
\n\t\t{{'id': '{4}', 'conceptscheme_id': {5}}},\
\n\t\tconfig.registry.dbmaker\
\n\t)\
\n\tskosregis = config.get_skos_registry()\
\n\tskosregis.register_provider({6})\n\n".
\nAdd a configuration similar to:\
\n\ndef create_registry(request):\
\n\t# create the SKOS registry\
\n\tregistry = Registry(instance_scope='threaded_thread')\
\n\t{3} = SQLAlchemyProvider(\
\n\t\t{{'id': '{4}', 'conceptscheme_id': {5}}},\
\n\t\trequest.db\
\n\t)\
\n\tregistry.register_provider({6})\
\n\treturn registry\
\n\n".
format(args.input_file, cs_label, args.to,
prov_id.replace(' ', '_'), prov_id, scheme_id, prov_id.replace(' ', '_')))

0 comments on commit 41ebaf1

Please sign in to comment.