weaver.store.mongodb
¶
Stores to read/write data to from/to mongodb using pymongo.
Module Contents¶
-
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__
.
-
classmethod
-
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.
-
-
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.
-
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
-
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>
- process – An instance of
-
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.
-
static
-
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
.
-
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 topage
index andlimit
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 (fromgroup_by
) that compose corresponding jobs with matching values.
-
-
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.
-
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 theircount
, whereitems
can have paging and be limited to a maximum per page, butcount
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.
-
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 theircount
, whereitems
can have paging and be limited to a maximum per page, butcount
always indicate the total number of matches.
-