API Documentation¶
uriregistry¶
-
uriregistry.
_load_configuration
(path)[source]¶ Load the configuration for the UriRegistry.
Parameters: path (str) – Path to the config file in YAML format. Returns: A dict
with the config options.
-
uriregistry.
_parse_settings
(settings)[source]¶ Parse the relevant settings for this application.
Parameters: settings (dict) –
-
uriregistry.
main
(global_config, **settings)[source]¶ This function returns a Pyramid WSGI application.
Parameters: global_config (pyramid.config.Configurator) –
Models module¶
-
class
uriregistry.models.
Application
(uri, title, service_url)[source]¶ Represents the config for an application.
Parameters: - uri (string) – A uri that identifies the application
- title (string) – A title for the application
- service_url (string) – The url for the service that can be queried
Registry module¶
-
class
uriregistry.registry.
UriRegistry
(applications=[], uris=[])[source]¶ Central registry that tracks uris and the applications they are being used in.
-
uriregistry.registry.
_build_uri_registry
(registry, registryconfig)[source]¶ Parameters: - registry (pyramid.registry.Registry) – Pyramid registry
- registryconfig (dict) – UriRegistry config in dict form.
Return type:
-
uriregistry.registry.
get_uri_registry
(registry)[source]¶ Get the
uriregistry.registry.UriRegistry
attached to this pyramid application.Return type: uriregistry.registry.UriRegistry
Views module¶
-
uriregistry.views.
_get_registry_response
(application_responses, uri)[source]¶ Generate the final response by aggregating all the application responses.
Parameters: - application_responses (list) – All
pyramid_urireferencer.models.ApplicationResponse
instances. - uri (str) – Uri that was evaluated
- base_uri (str) – Base uri of the uri that was evaluated
Returns: pyramid_urireferencer.models.RegistryResponse
with all information the registry has collected- application_responses (list) – All
pyramid_urireferencer¶
-
pyramid_urireferencer.
_add_referencer
(registry)[source]¶ Gets the Referencer from config and adds it to the registry.
-
pyramid_urireferencer.
get_referencer
(registry)[source]¶ Get the referencer class
Return type: pyramid_urireferencer.referencer.AbstractReferencer
-
pyramid_urireferencer.
includeme
(config)[source]¶ this function adds some configuration for the application
Models module¶
-
class
pyramid_urireferencer.models.
ApplicationResponse
(title, uri, service_url, success, has_references, count, items)[source]¶ Represents what a certain application will send back to the registry when asked if a certain uri is used by the application.
Parameters: - title (string) – Title of the application
- uri (string) – A uri for the application, not guaranteed to be a http url.
- service_url (string) – The url that answered the question
- success (boolean) – Was the querie successful?
- has_references (boolean) – Were any references found?
- count (int) – How many references were found?
- applications (list) – A list of items that have a reference to the uri under survey. Limited to 5 items for performance reasons.
-
static
load_from_json
(data)[source]¶ Load a
ApplicationResponse
from a dictionary or string (that will be parsed as json).
-
class
pyramid_urireferencer.models.
Item
(title, uri)[source]¶ A single item that holds a reference to the queried uri.
-
class
pyramid_urireferencer.models.
RegistryResponse
(query_uri, success, has_references, count, applications)[source]¶ Represents what the registry will send back to a client when asked if a certain uri is used somewhere.
Parameters: - query_uri (string) – Uri of the resource unser survey.
- success (boolean) – Were all the queries successful?
- has_references (boolean) – Were any references found?
- count (int) – How many references were found?
- applications (list) – A list of application results.
Referencer module¶
-
class
pyramid_urireferencer.referencer.
AbstractReferencer
[source]¶ This is an abstract class that defines what a Referencer needs to be able to handle.
It does two things:
- Check if a uri is being used in this application and report on this.
- Check if a certain uri is being used in another application by query a central registry.
-
is_referenced
(uri)[source]¶ This method checks if a certain uri is being referenced from resources in other applications.
Parameters: uri (string) – URI of the resource that needs to be checked Return type: pyramid_urireferencer.models.RegistryResponse
-
references
(uri, request)[source]¶ This method checks if a certain uri is being referenced by any other resource within this application.
Parameters: - uri (string) – URI of the resource we need to check for
- request –
pyramid.request.Request
with useful configuration information and connections of the application (registry, route_url, session) to determine the references
Return type:
-
class
pyramid_urireferencer.referencer.
Referencer
(registry_url, **kwargs)[source]¶ This is an implementation of the
AbstractReferencer
that adds a genericis_referenced()
method and a plainreferences()
method..-
is_referenced
(uri)[source]¶ This method checks if a certain uri is being referenced from resources in other applications.
Parameters: uri (string) – URI of the resource that needs to be checked Return type: pyramid_urireferencer.models.RegistryResponse
-
Rendererers module¶
-
pyramid_urireferencer.renderers.
application_adapter
(obj, request)[source]¶ Adapter for rendering a
pyramid_urireferencer.models.ApplicationResponse
to json.Parameters: obj (pyramid_urireferencer.models.ApplicationResponse) – The response to be rendered. Return type: dict
-
pyramid_urireferencer.renderers.
registry_adapter
(obj, request)[source]¶ Adapter for rendering a
pyramid_urireferencer.models.RegistryResponse
to json.Parameters: obj (pyramid_urireferencer.models.RegistryResponse) – The response to be rendered. Return type: dict