API Documentation



This module adds DataManagers for Atramhasis. These are service layer objects that abstract all interactions with the database away from the views.

class atramhasis.data.datamanagers.AuditManager(session)[source]

A data manager for logging the visit.

get the most popular concepts for a conceptscheme :param conceptscheme_id: id of the conceptscheme :param max: maximum number of results, default 5 :param period: ‘last_day’ or ‘last_week’ or ‘last_month’ or ‘last_year’, default ‘last_month’ :return: List of the most popular concepts of a conceptscheme over a certain period


save a certain visit :param visit_log: log of visit to save :return: The saved visit log

class atramhasis.data.datamanagers.ConceptSchemeManager(session)[source]

A DataManager for ConceptSchemes <skosprovider_sqlalchemy.models.ConceptScheme>.

find(conceptscheme_id, query)[source]

Find concepts and collections in this concept scheme.

  • conceptscheme_id – a concepscheme id
  • query – A python dictionary containing query parameters.

A list of skosprovider_sqlalchemy.models.Thing instances.

Parameters:conceptscheme_id – a concepscheme id
Returns:the concepscheme for the given id

Get all concepts and collections in this concept scheme.

Parameters:conceptscheme_id – a concepscheme id
Returns:A list of skosprovider_sqlalchemy.models.Thing instances.
Parameters:conceptscheme_id – a concepscheme id
Returns:all collections for the scheme_tree
Parameters:conceptscheme_id – a concepscheme id
Returns:all concepts for the scheme_tree
Parameters:conceptscheme – conceptscheme to save
Returns:saved conceptscheme
class atramhasis.data.datamanagers.CountsManager(session)[source]

A data manager that deals with triple counts.


Save a certain counts object

Parameters:counts (atramhasis.data.models.ConceptschemeCounts) – Counts object to save
Returns:The saved count
class atramhasis.data.datamanagers.DataManager(session)[source]

A DataManager abstracts all interactions with the database for a certain model.

class atramhasis.data.datamanagers.LanguagesManager(session)[source]

A DataManager for Languages <skosprovider_sqlalchemy.models.Language>.

Parameters:language – the language to delete
Returns:list of all languages
get_all_sorted(sort_coll, sort_desc)[source]
  • sort_coll – sort on this column
  • sort_desc – descending or not

sorted list of languages

Parameters:language – language to save
Returns:saved language
class atramhasis.data.datamanagers.SkosManager(session)[source]

A DataManager for Concepts and Collections <skosprovider_sqlalchemy.models.Thing>.

Parameters:thing – the thing to delete
Parameters:list_type – a specific list type
Returns:all results for the specific list type
get_thing(concept_id, conceptscheme_id)[source]
  • concept_id – a concept id
  • conceptscheme_id – a conceptscheme id

the selected thing (Concept or Collection)

Parameters:thing – thing to save
Returns:saved thing


Module that sets up the datamanagers and the database connections.


Generate a datamanager with a database session and register a cleanup handler.

Parameters:request (pyramid.request.Request) – The request this db session will be tied to.
Returns:A dictionary containing different datamanagers.

Set up SQLAlchemy.

Parameters:config (pyramid.config.Configurator) – Pyramid configuration.


Module containing errors generated by Atramhasis.

exception atramhasis.errors.ConceptNotFoundException(c_id)[source]

A Concept or Collection could not be found.

exception atramhasis.errors.ConceptSchemeNotFoundException(scheme_id)[source]

A ConceptScheme could not be found.

exception atramhasis.errors.DbNotFoundException(value='No database found, please check your application setup')[source]

Atramhasis could not find a database.

exception atramhasis.errors.LanguageNotFoundException(scheme_id)[source]

A Language could not be found.

exception atramhasis.errors.SkosRegistryNotFoundException(value='No SKOS registry found, please check your application setup')[source]

Atramhasis could not find a SKOS registry.

exception atramhasis.errors.ValidationError(value, errors)[source]

Some data that was validated is invalid.


Module containing mapping functions used by Atramhasis.


Check if a value has html inside. Only tags checked <strong> <em> <a>.

Parameters:value – a string
Returns:a boolean (True, HTML present | False, no HTML present)
atramhasis.mappers.map_concept(concept, concept_json, skos_manager)[source]

Map a concept from json to the database.

  • concept (skosprovider_sqlalchemy.models.Thing) – A concept or collection as known to the database.
  • concept_json (dict) – A dict representing the json sent to our REST service.
  • skos_manager – A skos_manager to acces db operations

The skosprovider_sqlalchemy.models.Thing enhanced with the information from the json object.

atramhasis.mappers.map_conceptscheme(conceptscheme, conceptscheme_json)[source]

Map a conceptscheme from json to the database.


The skosprovider_sqlalchemy.models.ConceptScheme enhanced with the information from the json object.


class atramhasis.protected_resources.ProtectedResourceEvent(uri, request)[source]

Event triggered when calling a protected operation on a resource

exception atramhasis.protected_resources.ProtectedResourceException(value, referenced_in)[source]

raise this exception when the resource is still used somewhere

referenced_in should contain locations where the resource is still referenced


use this decorator to prevent an operation from being executed when the related resource is still in use


Routes for the Atramhasis views.

New in version 0.4.4.


Setup the routing for Atramhasis.

Parameters:config (pyramid.config.Configurator) – The application config.


Module containing utility functions used by Atramhasis.


Map a skosprovider_sqlalchemy.models.Thing to a skosprovider.skos.Concept or a skosprovider.skos.Collection, depending on the type.

Parameters:thing (skosprovider_sqlalchemy.models.Thing) – Thing to map.
Return type:Concept or Collection.

aspect oriented way to check if provider is internal when calling the decorated function

Parameters:fn – the decorated function
Returns:around advice
Raises:pyramid.httpexceptions.HTTPMethodNotAllowed – when provider is not internal


Module that validates incoming JSON.

atramhasis.validators.broader_hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct)[source]

Checks that the broader concepts of a concepts are not alreadt narrower concepts of that concept.

atramhasis.validators.collection_members_unique_rule(errors, node_location, members)[source]

Checks that a collection has no duplicate members.

atramhasis.validators.collection_type_rule(errors, node_location, skos_manager, conceptscheme_id, members)[source]

Checks that the targets of member_of are collections and not concepts.

atramhasis.validators.concept_matches_rule(errors, node_location, matches, concept_type)[source]

Checks that only concepts have matches.

atramhasis.validators.concept_matches_unique_rule(errors, node_location, matches)[source]

Checks that a concept has not duplicate matches.

This means that a concept can only have one match (no matter what the type) with another concept. We don’t allow eg. a concept that has both a broadMatch and a relatedMatch with the same concept.

atramhasis.validators.concept_relations_rule(errors, node_location, relations, concept_type)[source]

Checks that only concepts have narrower, broader and related relations.

atramhasis.validators.concept_schema_validator(node, cstruct)[source]

This validator validates an incoming concept or collection

This validator will run a list of rules against the concept or collection to see that there are no validation rules being broken.

  • node (colander.SchemaNode) – The schema that’s being used while validating.
  • cstruct – The concept or collection being validated.
atramhasis.validators.concept_type_rule(errors, node_location, skos_manager, conceptscheme_id, items)[source]

Checks that the targets of narrower, broader and related are concepts and not collections.

atramhasis.validators.conceptscheme_schema_validator(node, cstruct)[source]

This validator validates the incoming conceptscheme labels

  • node (colander.SchemaNode) – The schema that’s being used while validating.
  • cstruct – The conceptscheme being validated.
atramhasis.validators.hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct, property1, property2, property2_list_name, concept_type, error_message)[source]

Checks that the property1 of a concept are not already in property2 hierarchy


Prepare the value by stripping all html except certain tags.

Parameters:value – The value to be cleaned.
Return type:str
atramhasis.validators.label_lang_rule(errors, node, languages_manager, labels)[source]

Checks that languages of a label are valid.

Checks that they are valid IANA language tags. If the language tag was not already present in the database, it adds them.

atramhasis.validators.label_type_rule(errors, node, skos_manager, labels)[source]

Checks that a label has the correct type.

atramhasis.validators.languagetag_checkduplicate(node, language_tag, languages_manager, errors)[source]

Check that a languagetag isn’t duplicated.

atramhasis.validators.languagetag_isvalid_rule(node, language_tag, errors)[source]

Check that a languagetag is a valid IANA language tag.

atramhasis.validators.languagetag_validator(node, cstruct)[source]

This validator validates a languagetag.

The validator will check if a tag is a valid IANA language tag. The the validator is informed that this should be a new language tag, it will also check if the tag doesn’t already exist.

  • node (colander.SchemaNode) – The schema that’s being used while validating.
  • cstruct – The value being validated.
atramhasis.validators.max_preflabels_rule(errors, node, labels)[source]

Checks that there’s only one prefLabel for a certain language.

atramhasis.validators.members_hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct)[source]

Checks that a collection does not have members that are in themselves already “parents” of that collection.

atramhasis.validators.members_only_in_collection_rule(errors, node, concept_type, members)[source]

Checks that only collections have members.

atramhasis.validators.min_labels_rule(errors, node, cstruct)[source]

Checks that a label or collection always has a least one label.

atramhasis.validators.narrower_hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct)[source]

Checks that the narrower concepts of a concept are not already broader concepts of that concept.

atramhasis.validators.semantic_relations_rule(errors, node_location, skos_manager, conceptscheme_id, members, collection_id)[source]

Checks that the elements in a group of concepts or collections are not the the group itself, that they actually exist and are within the same conceptscheme.

atramhasis.validators.subordinate_arrays_hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct)[source]

Checks that the subordinate arrays of a concept are not themselves parents of that concept.

atramhasis.validators.subordinate_arrays_only_in_concept_rule(errors, node, concept_type, subordinate_arrays)[source]

Checks that only a concept has subordinate arrays.

atramhasis.validators.subordinate_arrays_type_rule(errors, node_location, skos_manager, conceptscheme_id, subordinate_arrays)[source]

Checks that subordinate arrays are always collections.

atramhasis.validators.superordinates_hierarchy_rule(errors, node_location, skos_manager, conceptscheme_id, cstruct)[source]

Checks that the superordinate concepts of a collection are not themselves members of that collection.

atramhasis.validators.superordinates_only_in_concept_rule(errors, node, concept_type, superordinates)[source]

Checks that only collections have superordinates.

atramhasis.validators.superordinates_type_rule(errors, node_location, skos_manager, conceptscheme_id, superordinates)[source]

Checks that superordinates are always concepts.



class atramhasis.views.views.AtramhasisAdminView(request)[source]

This object groups HTML views part of the admin user interface.

class atramhasis.views.views.AtramhasisListView(request)[source]

This object groups list views part for the user interface.

class atramhasis.views.views.AtramhasisView(request)[source]

This object groups HTML views part of the public user interface.


This view displays a list of available conceptschemes.


This view returns the favicon when requested from the web root.


This view displays the homepage.


This view displays the search results

This view will set a language cookie


Module containing views related to the REST service.

class atramhasis.views.crud.AtramhasisCrud(context, request)[source]

This object groups CRUD REST views part of the private user interface.


Edit an existing concept

Raises:atramhasis.errors.ValidationError – If the provided json can’t be validated


Module containing error views.

atramhasis.views.exception_views.data_integrity(exc, request)[source]

View invoked when IntegrityError was raised.

atramhasis.views.exception_views.failed(exc, request)[source]

View invoked when bad data was submitted to Atramhasis.

atramhasis.views.exception_views.failed_not_found(exc, request)[source]

View invoked when a resource could not be found.

atramhasis.views.exception_views.failed_not_method_not_allowed(exc, request)[source]

View invoked when a method is not allowed.

atramhasis.views.exception_views.failed_skos(exc, request)[source]

View invoked when Atramhasis can’t find a SKOS registry.

atramhasis.views.exception_views.failed_validation(exc, request)[source]

View invoked when bad data was submitted to Atramhasis.

atramhasis.views.exception_views.protected(exc, request)[source]

when a protected operation is called on a resource that is still referenced

atramhasis.views.exception_views.provider_unavailable(exc, request)[source]

View invoked when ProviderUnavailableException was raised.