API Documentation¶
Providers module¶
-
class
skosprovider_sqlalchemy.providers.
SQLAlchemyProvider
(metadata, session_maker, **kwargs)[source]¶ A
skosprovider.providers.VocabularyProvider
that uses SQLAlchemy as backend.-
expand_strategy
= 'recurse'¶ Determines how the expand method will operate. Options are:
- recurse: Determine all narrower concepts by recursivly querying the database. Can take a long time for concepts that are at the top of a large hierarchy.
- visit: Query the database’s
Visitation
table. This table contains a nested set representation of each conceptscheme. Actually creating the data in this table needs to be scheduled.
-
Models module¶
-
class
skosprovider_sqlalchemy.models.
Initialiser
(session)[source]¶ Initialises a database.
Adds necessary values for labelType, noteType and language to the database.
The list of languages added by default is very small and will probably need to be expanded for your local needs.
-
class
skosprovider_sqlalchemy.models.
Label
(label, labeltype_id=u'prefLabel', language_id=None)[source]¶ A label for a
Concept
,Collection
orConceptScheme
.
-
class
skosprovider_sqlalchemy.models.
LabelType
(name, description)[source]¶ A labelType according to SKOS.
-
class
skosprovider_sqlalchemy.models.
Match
(**kwargs)[source]¶ A match between a
Concept
in one ConceptScheme and those in another one.
-
class
skosprovider_sqlalchemy.models.
MatchType
(name, description)[source]¶ A matchType according to SKOS.
-
class
skosprovider_sqlalchemy.models.
Note
(note, notetype_id, language_id, markup=None)[source]¶ A note for a
Concept
,Collection
orConceptScheme
.
-
class
skosprovider_sqlalchemy.models.
NoteType
(name, description)[source]¶ A noteType according to SKOS.
-
class
skosprovider_sqlalchemy.models.
Source
(citation, markup=None)[source]¶ The source where a certain piece of information came from.
-
class
skosprovider_sqlalchemy.models.
Thing
(**kwargs)[source]¶ Abstract class for both
Concept
andCollection
.
-
class
skosprovider_sqlalchemy.models.
Visitation
(**kwargs)[source]¶ Holds several nested sets.
The visitation object and table hold several nested sets. Each
skosprovider_sqlalchemy.models.Visitation
holds the positional information for one conceptplacement in a certain nested set.Each conceptscheme gets its own separate nested set.
-
skosprovider_sqlalchemy.models.
label
(labels=[], language=u'any', sortLabel=False)[source]¶ Provide a label for a list of labels.
Deprecated since version 0.5.0: Please use
skosprovider.skos.label()
. Starting with skosprovider 0.6.0, the function can function onskosprovider_sqlalchemy.models.Label
instances as well.Parameters: - labels (list) – A list of
labels
. - language (str) – The language for which a label should preferentially be returned. This should be a valid IANA language tag.
- sortLabel (boolean) – Should sortLabels be considered or not? If True, sortLabels will be preferred over prefLabels. Bear in mind that these are still language dependent. So, it’s possible to have a different sortLabel per language.
Return type: A
Label
or None if no label could be found.- labels (list) – A list of
Listener that ensures related concepts have a bidirectional relationship.
Listener to remove a related concept from both ends of the relationship.
Utils module¶
-
class
skosprovider_sqlalchemy.utils.
VisitationCalculator
(session)[source]¶ Generates a nested set for a conceptscheme.
-
skosprovider_sqlalchemy.utils.
import_provider
(provider, conceptscheme, session)[source]¶ Import a provider into a SQLAlchemy database.
Parameters: - provider – The
skosprovider.providers.VocabularyProvider
to import. Since the SQLAlchemy backend uses integers as keys, this backend should have id values that can be cast to int. - conceptscheme – A
skosprovider_sqlalchemy.models.Conceptscheme
to import the provider into. This should be an empty scheme so that there are no possible id clashes. - session – A
sqlalchemy.orm.session.Session
.
- provider – The