durga package¶
Submodules¶
durga.collection module¶
-
class
durga.collection.
Collection
(url, resource)[source]¶ Bases:
object
-
create
(data)[source]¶ Create a new remote resource from a dictionary.
At first the data will be validated. After successful validation the data is converted to JSON. The response of the POST request is returned afterwards.
-
delete
()[source]¶ Delete all Elements of this Collection.
Return the response for each deleted Element as a list.
-
elements
¶
-
get_values
(data)[source]¶ Return either a dictionary, a tuple or a single field.
The data type and the fields returned are defined by using values() or values_list().
-
response
= None¶
-
update
(data)[source]¶ Update all Elements of this Collection with data from a dictionary.
The data dictionary is used to update the data of all Elements of this Collection. The updated Elements are validated and their data is converted to JSON. A PUT request is made for each Element. Finally a list of all responses is returned.
-
values
(*fields)[source]¶ Return a list of dictionaries instead of Element instances.
The optional positional arguments, *fields, can be used to limit the fields that are returned.
-
values_list
(*fields, **kwargs)[source]¶ Return a list of tuples instead of Element instances.
The optional positional arguments, *fields, can be used to limit the fields that are returned.
If only a single field is passed in, the flat parameter can be passed in too. If True, this will mean the returned results are single values, rather than one-tuples.
-
durga.element module¶
-
class
durga.element.
Element
(resource, data)[source]¶ Bases:
object
durga.exceptions module¶
-
exception
durga.exceptions.
MultipleObjectsReturnedError
[source]¶ Bases:
durga.exceptions.DurgaError
The request returned multiple objects when only one was expected.
That is, if a GET request returns more than one element.
-
exception
durga.exceptions.
ObjectNotFoundError
[source]¶ Bases:
durga.exceptions.DurgaError
The requested object does not exist.
-
exception
durga.exceptions.
ValidationError
[source]¶ Bases:
durga.exceptions.DurgaError
The value did not pass the validator.