ripozo package¶
Subpackages¶
- ripozo.dispatch package
- ripozo.managers package
- ripozo.viewsets package
Submodules¶
ripozo.decorators module¶
-
class
ripozo.decorators.
ClassPropertyDescriptor
(fget, fset=None)[source]¶ Bases:
object
Straight up stolen from stack overflow Implements class level properties http://stackoverflow.com/questions/5189699/how-can-i-make-a-class-property-in-python
-
class
ripozo.decorators.
apimethod
(route='', endpoint=None, **options)[source]¶ Bases:
object
Decorator for declaring routes on a ripozo resource
ripozo.exceptions module¶
-
exception
ripozo.exceptions.
AdapterFormatAlreadyRegisteredException
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.DispatchException
An exception that is raised when an adapter format has already been register with the adapter instance. This is done to prevent accidental overrides of format types.
-
exception
ripozo.exceptions.
BaseRestEndpointAlreadyExists
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.RestException
This exception is raised when the ResourceBaseMetaClass finds an endpoint has already been registered for the application
-
exception
ripozo.exceptions.
DispatchException
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.RestException
An exception for when something is wrong with the Dispatcher
-
exception
ripozo.exceptions.
FieldException
(message, status_code=400, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.RestException
,ValueError
An exception specifically for Field errors. Specifically, when validation or casting fail.
-
exception
ripozo.exceptions.
ManagerException
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.RestException
A base exception for when the manager has an exception specific to it. For example, not finding a model.
-
exception
ripozo.exceptions.
NoResourceNameDeclaredException
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.RestException
An exception raised when neither the _resource_name or the _manager attributes are set on a ResourceBase subclass. When this happens it is impossible for the ResourceBase subclass to determine what to call the resource it is handling
-
exception
ripozo.exceptions.
NotFoundException
(message, status_code=404, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.ManagerException
This exception is raised when the manager can’t find a model that was requested.
-
exception
ripozo.exceptions.
RestException
(message=None, status_code=500, *args, **kwargs)[source]¶ Bases:
Exception
The base exception for any of the package specific exceptions
-
exception
ripozo.exceptions.
TranslationException
(message, status_code=400, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.ValidationException
An exception that is raised when casting fails on a field.
-
exception
ripozo.exceptions.
ValidationException
(message, status_code=400, *args, **kwargs)[source]¶ Bases:
ripozo.exceptions.FieldException
An exception for when validation fails on a field.
ripozo.utilities module¶
-
ripozo.utilities.
convert_to_underscore
(toconvert)[source]¶ Converts a string from CamelCase to underscore
- Parameters
toconvert (str) – The string to convert from CamelCase to underscore (i.e. camel_case)
- Returns
The converted string
- Return type
str
-
ripozo.utilities.
join_url_parts
(*parts)[source]¶ Joins each of the parts with a ‘/’. Additionally, it prevents something like ‘something/’ and ‘/another’ from turning into ‘something//another’ instead it will return ‘something/another’.
- Parameters
parts (list) – a list of strings to join together with a ‘/’
- Returns
The url
- Return type
unicode
-
ripozo.utilities.
make_json_safe
(obj)[source]¶ Makes an object json serializable. This is designed to take a list or dictionary, and is fairly limited.
- Parameters
obj (object) –
- Returns
- Return type
object|six.text_type|list|dict
-
ripozo.utilities.
picky_processor
(processor, include=None, exclude=None)[source]¶ A wrapper for pre and post processors that selectively runs pre and post processors. If the include keyword argument is set, then any method on the Resource that has the same name as the processor will be run. Otherwise it will not be run. On the other hand, if the exclude keyword argument is set then any method on then this preprocessor will not be run for any method on the resource that does have the same name as the strings in the exclude list
- Parameters
processor (method) – A pre or post processor on a ResourceBase subclass. This is the function that will be run if the it passes the include and exclude parameters
include (list) – A list of name strings that are methods on the class that for which this processor will be run.
exclude (list) –
- Returns
The wrapped function that only runs if the include and exclude parameters are fulfilled.
- Return type
method
-
ripozo.utilities.
serialize_fields
(field_names, field_values)[source]¶ Takes two lists and iterates through them to combine them into a dictionary
- Parameters
field_names (list) – The names of the fields that were retrieved. Order is important. These will be the dictionary keys
field_values (list) – The values that were retrieved. These will be the dictionary values
- Returns
A dictionary of the combined lists
- Return type
dict
-
ripozo.utilities.
titlize_endpoint
(endpoint)[source]¶ Capitalizes the endpoint and makes it look like a title Just to prettify the output of the actions. It capitalizes the first letter of every word and replaces underscores with spaces. It is opinionated in how it determines words. It simply looks for underscores and splits based on that.
- Parameters
endpoint (unicode) – The endpoint name on the resource
- Returns
The prettified endpoint name
- Return type
unicode