API Documentation

Db

Module that sets up SQLAlchemy.

atramhasis.db.db(request)[source]

Generate a database session and register a cleanup handler.

Parameters:request (pyramid.request.Request) – The request this db session will be tied to.
Returns:A sqlalchemy.orm.session.Session
atramhasis.db.includeme(config)[source]

Set up SQLAlchemy.

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

Errors

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.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.

Mappers

Module containing mapping functions used by Atramhasis.

atramhasis.mappers.map_concept(concept, concept_json, db_session)[source]

Map a concept from json to the database.

Parameters:
  • 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.
  • session – A sqlalchemy.orm.session.Session.
Returns:

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

Service

Module containing internal service layer used by Atramhasis.

class atramhasis.service.AtramhasisService(session, conceptscheme_id)[source]

A service object that handles queries on the database.

This service talks directly to the SQL database used by Atramhasis and returns objects from the skosprovider_sqlalchemy.models module.

Parameters:
  • session – A sqlalchemy.orm.session.Session.
  • conceptscheme_id (int) – Id of the conceptscheme this service is handling.
find(query, **kwargs)[source]

Find concepts and collections in this concept scheme.

Parameters:query (dict) – A python dictionary containing query parameters.
Returns:A list of skosprovider_sqlalchemy.models.Thing instances.
get_all(**kwargs)[source]

Get all concepts and collections in this concept scheme.

Returns:A list of skosprovider_sqlalchemy.models.Thing instances.

Utils

Module containing utility functions used by Atramhasis.

atramhasis.utils.from_thing(thing)[source]

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.

Validators

Views

General

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.

concept_view()[source]

This view displays the concept details

Parameters:request – A pyramid.request.Request
favicon_view()[source]

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

Parameters:request – A pyramid.request.Request
home_view()[source]

This view displays the homepage.

Parameters:request – A pyramid.request.Request
search_result()[source]

This view displays the search results

Parameters:request – A pyramid.request.Request

This view will set a language cookie

Parameters:request – A pyramid.request.Request

Crud

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.

add_concept()[source]

Add a new concept to a conceptscheme

Raises atramhasis.errors.ValidationError:
 If the provided json can’t be validated
delete_concept()[source]

Delete an existing concept

Raises atramhasis.errors.ConceptNotFoundException:
 If the concept can’t be found
edit_concept()[source]

Edit an existing concept

Raises:
get_concept()[source]

Get an existing concept

Raises atramhasis.errors.ConceptNotFoundException:
 If the concept can’t be found

Exception views

Module containing error views.

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

View invoked when a resource could not be found.

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.