Pythonic interface to a single Fedora Commons repository instance.
Default type to use for methods that return fedora objects - DigitalObject
Find objects in Fedora. Find query should be generated via keyword args, based on the fields in Fedora documentation. By default, the query uses a contains (~) search for all search terms. Calls ApiFacade.findObjects(). Results seem to return consistently in ascending PID order.
Example usage - search for all objects where the owner contains ‘jdoe’:
repository.find_objects(ownerId='jdoe')
Supports all search operators provided by Fedora findObjects query (exact, gt, gte, lt, lte, and contains). To specify the type of query for a particular search term, call find_objects like this:
repository.find_objects(ownerId__exact='lskywalker')
repository.find_objects(date__gt='20010302')
Parameters: |
|
---|---|
Return type: | generator for list of objects |
Request next available pid or pids from Fedora, optionally in a specified namespace. Calls ApiFacade.getNextPID().
Deprecated since version 0.14: Mint pids for new objects with eulfedora.models.DigitalObject.get_default_pid() instead, or call ApiFacade.getNextPID() directly.
Parameters: |
|
---|---|
Return type: | string or list of strings |
Initialize a single object from Fedora, or create a new one, with the same Fedora configuration and credentials.
Parameters: |
|
---|---|
Return type: | single object of the type specified |
Create : | boolean: create a new object? (if not specified, defaults to False when pid is specified, and True when it is not) |
Find objects in Fedora with the specified content model.
Parameters: |
|
---|---|
Return type: | list of objects |
Ingest a new object into Fedora. Returns the pid of the new object on success. Calls ApiFacade.ingest().
Parameters: |
|
---|---|
Return type: | string |
Purge an object from Fedora. Calls ApiFacade.purgeObject().
Parameters: |
|
---|---|
Return type: | boolean |
instance of ResourceIndex, with the same root url and credentials
fields that can be searched against in find_objects()
human-readable aliases for oddly-named fedora search fields
Python object for accessing Fedora’s Resource Index.
Specify whether or not RI search queries should specify flush=true to obtain the most recent results. If flush is specified to the query method, that takes precedence.
Irrelevant if Fedora RIsearch is configured with syncUpdates = True.
Run a query in a format supported by the Fedora Resource Index (e.g., SPO os Sparql) and return the results.
Parameters: |
|
---|---|
Return type: | rdflib.ConjunctiveGraph when type is triples; list of dictionaries (keys based on return fields) when type is tuples |
Search for all subjects related to the specified subject and predicate.
Parameters: |
|
---|---|
Return type: | generator of RDF statements |
Search for all subjects related to the specified subject and object.
Parameters: |
|
---|---|
Return type: | generator of RDF statements |
Search for all subjects related to the specified predicate and object.
Parameters: |
|
---|---|
Return type: | generator of RDF statements |
Run a Sparql query.
Parameters: | query – sparql query string |
---|---|
Return type: | list of dictionary |
Create and run a subject-predicate-object (SPO) search. Any search terms that are not specified will be replaced as a wildcard in the query.
Parameters: |
|
---|---|
Return type: | rdflib.ConjunctiveGraph |
Encode search terms for an SPO query.
Parameters: | val – string to be encoded |
---|---|
Return type: | string |
The following management commands will be available when you include eulfedora in your django INSTALLED_APPS and rely on the existdb settings described above.
For more details on these commands, use manage.py <command> help
- syncrepo - load simple content models and fixture object to the configured fedora repository
eulfedora adds custom template tags for use in templates.
Catch fedora failures and permission errors encountered during template rendering:
{% load fedora %}
{% fedora_access %}
<p>Try to access data on fedora objects which could be
<span class='{{ obj.inaccessible_ds.content.field }}'>inaccessible</span>
or when fedora is
<span class='{{ obj.regular_ds.content.other_field }}'>down</span>.</p>
{% permission_denied %}
<p>Fall back to this content if the main body results in a permission
error while trying to access fedora data.</p>
{% fedora_failed %}
<p>Fall back to this content if the main body runs into another error
while trying to access fedora data.</p>
{% end_fedora_access %}
The permission_denied and fedora_failed sections are optional. If only permission_denied is present then non-permission errors will result in the entire block rendering empty. If only fedora_failed is present then that section will be used for all errors whether permission-related or not. If neither is present then all errors will result in the entire block rendering empty.
Note that when Django’s TEMPLATE_DEBUG setting is on, it precludes all error handling and displays the Django exception screen for all errors, including fedora errors, even if you use this template tag. To disable this Django internal functionality and see the effects of the fedora_access tag, add the following to your Django settings:
TEMPLATE_DEBUG = False