weaver.store.mongodb

Stores to read/write data to from/to mongodb using pymongo.

Module Contents

weaver.store.mongodb.JobListAndCount[source]
weaver.store.mongodb.LOGGER[source]
class weaver.store.mongodb.MongodbStore(collection, sane_name_config=None)[source]

Bases: object

Base class extended by all concrete store implementations.

classmethod get_args_kwargs(cls, *args, **kwargs)[source]

Filters MongodbStore-specific arguments to safely pass them down its __init__.

class weaver.store.mongodb.MongodbServiceStore(*args, **kwargs)[source]

Bases: weaver.store.base.StoreServices, weaver.store.mongodb.MongodbStore

Registry for OWS services. Uses mongodb to store service url and attributes.

save_service(self, service, overwrite=True, request=None)[source]

Stores an OWS service in mongodb.

delete_service(self, name, request=None)[source]

Removes service from mongodb storage.

list_services(self, request=None)[source]

Lists all services in mongodb storage.

fetch_by_name(self, name, visibility=None, request=None)[source]

Gets service for given name from mongodb storage.

fetch_by_url(self, url, request=None)[source]

Gets service for given url from mongodb storage.

clear_services(self, request=None)[source]

Removes all OWS services from mongodb storage.

class weaver.store.mongodb.MongodbProcessStore(*args, **kwargs)[source]

Bases: weaver.store.base.StoreProcesses, weaver.store.mongodb.MongodbStore

Registry for processes. Uses mongodb to store processes and attributes.

_add_process(self, process)[source]
static _get_process_field(process, function_dict)[source]

Takes a lambda expression or a dict of process-specific lambda expressions to retrieve a field. Validates that the passed process object is one of the supported types.

Parameters:
  • process – process to retrieve the field from.
  • function_dict – lambda or dict of lambda of process type
Returns:

retrieved field if the type was supported

Raises:

ProcessInstanceError on invalid process type

_get_process_id(self, process)[source]
_get_process_type(self, process)[source]
_get_process_endpoint_wps1(self, process)[source]
save_process(self, process, overwrite=True, request=None)[source]

Stores a process in storage.

Parameters:
  • process – An instance of weaver.datatype.Process.
  • overwrite – Overwrite the matching process instance by name if conflicting.
  • request – <unused>
delete_process(self, process_id, visibility=None, request=None)[source]

Removes process from database, optionally filtered by visibility. If visibility=None, the process is deleted (if existing) regardless of its visibility value.

list_processes(self, visibility=None, request=None)[source]

Lists all processes in database, optionally filtered by visibility.

Parameters:
  • visibility – One value amongst weaver.visibility.
  • request – <unused>
fetch_by_id(self, process_id, visibility=None, request=None)[source]

Get process for given process_id from storage, optionally filtered by visibility. If visibility=None, the process is retrieved (if existing) regardless of its visibility value.

Parameters:
  • process_id – process identifier
  • visibility – one value amongst weaver.visibility.
  • request – <unused>
Returns:

An instance of weaver.datatype.Process.

get_visibility(self, process_id, request=None)[source]

Get visibility of a process.

Returns:One value amongst weaver.visibility.
set_visibility(self, process_id, visibility, request=None)[source]

Set visibility of a process.

Parameters:
  • visibility – One value amongst weaver.visibility.
  • process_id
  • request – <unused>
Raises:

TypeError or ValueError in case of invalid parameter.

clear_processes(self, request=None)[source]

Clears all processes from the store.

Parameters:request – <unused>
class weaver.store.mongodb.MongodbJobStore(*args, **kwargs)[source]

Bases: weaver.store.base.StoreJobs, weaver.store.mongodb.MongodbStore

Registry for process jobs tracking. Uses mongodb to store job attributes.

save_job(self, task_id, process, service=None, inputs=None, is_workflow=False, user_id=None, execute_async=True, custom_tags=None, access=None, notification_email=None, accept_language=None)[source]

Stores a job in mongodb.

update_job(self, job)[source]

Updates a job parameters in mongodb storage. :param job: instance of weaver.datatype.Job.

delete_job(self, job_id, request=None)[source]

Removes job from mongodb storage.

fetch_by_id(self, job_id, request=None)[source]

Gets job for given job_id from mongodb storage.

list_jobs(self, request=None)[source]

Lists all jobs in mongodb storage. For user-specific access to available jobs, use MongodbJobStore.find_jobs() instead.

find_jobs(self, request, process=None, service=None, tags=None, access=None, notification_email=None, status=None, sort=None, page=0, limit=10, group_by=None)[source]

Finds all jobs in mongodb storage matching search filters and obtain results with requested paging or grouping.

Parameters:
  • request – request that lead to this call to obtain permissions and user id.
  • process – process name to filter matching jobs.
  • service – service name to filter matching jobs.
  • tags – list of tags to filter matching jobs.
  • access – access visibility to filter matching jobs (default: PUBLIC).
  • notification_email – notification email to filter matching jobs.
  • status – status to filter matching jobs.
  • sort – field which is used for sorting results (default: creation date, descending).
  • page – page number to return when using result paging (only when not using group_by).
  • limit – number of jobs per page when using result paging (only when not using group_by).
  • group_by – one or many fields specifying categories to form matching groups of jobs (paging disabled).
Returns:

(list of jobs matching paging OR list of {categories, list of jobs, count}) AND total of matched job

Example

Using paging (default), result will be in the form:

(
    [Job(1), Job(2), Job(3), ...],
    <total>
)

Where <total> will indicate the complete count of matched jobs with filters, but the list of jobs will be limited only to page index and limit specified.

Using grouping with a list of field specified with group_by, results will be in the form:

(
    [{category: {field1: valueA, field2: valueB, ...}, [Job(1), Job(2), ...], count: <count>},
     {category: {field1: valueC, field2: valueD, ...}, [Job(x), Job(y), ...], count: <count>},
     ...
    ],
    <total>
)

Where <total> will again indicate all matched jobs by every category combined, and <count> will indicate the amount of jobs matched for each individual category. Also, category will indicate values of specified fields (from group_by) that compose corresponding jobs with matching values.

clear_jobs(self, request=None)[source]

Removes all jobs from mongodb storage.

class weaver.store.mongodb.MongodbQuoteStore(*args, **kwargs)[source]

Bases: weaver.store.base.StoreQuotes, weaver.store.mongodb.MongodbStore

Registry for quotes. Uses mongodb to store quote attributes.

save_quote(self, quote)[source]

Stores a quote in mongodb.

fetch_by_id(self, quote_id)[source]

Gets quote for given quote_id from mongodb storage.

list_quotes(self)[source]

Lists all quotes in mongodb storage.

find_quotes(self, process_id=None, page=0, limit=10, sort=None)[source]

Finds all quotes in mongodb storage matching search filters.

Returns a tuple of filtered items and their count, where items can have paging and be limited to a maximum per page, but count always indicate the total number of matches.

class weaver.store.mongodb.MongodbBillStore(*args, **kwargs)[source]

Bases: weaver.store.base.StoreBills, weaver.store.mongodb.MongodbStore

Registry for bills. Uses mongodb to store bill attributes.

save_bill(self, bill)[source]

Stores a bill in mongodb.

fetch_by_id(self, bill_id)[source]

Gets bill for given bill_id from mongodb storage.

list_bills(self)[source]

Lists all bills in mongodb storage.

find_bills(self, quote_id=None, page=0, limit=10, sort=None)[source]

Finds all bills in mongodb storage matching search filters.

Returns a tuple of filtered items and their count, where items can have paging and be limited to a maximum per page, but count always indicate the total number of matches.