ripozo.viewsets.fields package¶
Submodules¶
ripozo.viewsets.fields.base module¶
-
class
ripozo.viewsets.fields.base.
BaseField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', error_message=None)[source]¶ Bases:
object
The BaseField class is simply an abstract base class that defines the necessary methods for casting and validating a field.
-
translate
(obj, skip_required=False, validate=False)[source]¶ A shortcut method to _translate and _validate the object that is being passed in. It returns this object or raises a ValueError.
Parameters: obj (object) – Returns: The translated and validated object Return type: object Raises: ripozo.exceptions.ValidationsException Raises: ripozo.exceptions.TranslationException
-
-
ripozo.viewsets.fields.base.
translate_fields
(url_params, query_args, body_args, fields=None, skip_required=False, validate=False)[source]¶ - Performs the specified action on the field. The action can be a string of
- either _translate, _validate, or translate.
Parameters: - url_params (dict) – The url parameters. Typically this is going to be things like primary keys and such
- query_args (dict) – The query args. Typically these are going to be filters on lists and such
- body_args (dict) – The arguments in the body. This may be for updates and creations
- fields (list) – The list of BaseField instances that are supposed to be validated. Only items in this list will be translated and validated
- skip_required (bool) – A flag that indicates the required fields are not required. This is helpful for updates where fields are not usually required.
- validate (bool) – A flag that indicates whether the field validations should be run. If not, it will just translate the fields.
Returns: Returns the translated url_params, query_args and body_args
Return type: Raises: RestException
Raises: ValidationException
Raises: TranslationException
ripozo.viewsets.fields.common module¶
-
class
ripozo.viewsets.fields.common.
BooleanField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', error_message=None)[source]¶ Bases:
ripozo.viewsets.fields.base.BaseField
A field used for translating and validating a boolean input It can take either a boolean or a string.
-
class
ripozo.viewsets.fields.common.
DateTimeField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', valid_formats=None, error_message=None)[source]¶ Bases:
ripozo.viewsets.fields.base.BaseField
A field for validating and translating a datetime input. By default it accepts the following formats:
%Y-%m-%dT%H:%M:%S.%fZ
If you need other formats simply pass a list of valid formats into the valid_formats parameter on initialization
-
field_type
¶ alias of
datetime
-
valid_formats
= [u'%Y-%m-%dT%H:%M:%S.%fZ']¶
-
-
class
ripozo.viewsets.fields.common.
FloatField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', error_message=None)[source]¶ Bases:
ripozo.viewsets.fields.common.IntegerField
A field used for translating and validating a float input
-
class
ripozo.viewsets.fields.common.
IntegerField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', error_message=None)[source]¶ Bases:
ripozo.viewsets.fields.base.BaseField
A field used for translating and validating an integer input
-
class
ripozo.viewsets.fields.common.
ListField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', error_message=None, indv_field=<ripozo.viewsets.fields.base.BaseField object>)[source]¶ Bases:
ripozo.viewsets.fields.base.BaseField
A field for a list of objects. A field for the individual results can also be provided. This would be run against every individual item in the list that is provided.
-
class
ripozo.viewsets.fields.common.
StringField
(name, required=False, maximum=None, minimum=None, arg_type=u'body_args', regex=None, error_message=None)[source]¶ Bases:
ripozo.viewsets.fields.base.BaseField
Used for casting and validating string fields.
-
field_type
¶ alias of
unicode
-