cmn package¶
Subpackages¶
Submodules¶
cmn.admin module¶
cmn.apps module¶
cmn.forms module¶
cmn.forms
Forms common to ws applications
cmn.models module¶
cmn.serializers module¶
cmn.serializers
Serializers common to ws applications
- class cmn.serializers.FormatSerializer(*args, **kwargs)¶
Bases:
rest_framework.serializers.Serializer
Option ‘format’
- validate(attrs)¶
- class cmn.serializers.JwtSerializer(*args, **kwargs)¶
Bases:
rest_framework.serializers.Serializer
Option ‘jwt’ for JWT (JSON Web Token)
- validate(attrs)¶
- cmn.serializers.get_key_option_values(data, key)¶
Returns list of values of key option
cmn.tests module¶
cmn.views module¶
cmn.views_mixins module¶
cmn.views_mixins
Mixins common to ws applications views
- class cmn.views_mixins.DataViewMixin¶
Bases:
object
Additional methods for views needing data
- data_from_request(request)¶
- request_data(request)¶
- request_data_unwritable(request)¶
Disallows request.data modification
- request_data_writable(request)¶
Allows request.data modification
- request_query_params(request)¶
- class cmn.views_mixins.FileViewMixin¶
Bases:
object
Additional methods for views returning files
- binaryfile_response(file_path)¶
- file_response(file_path)¶
- textfile_response(file_path)¶
- txtfile_response(file_path)¶
- zipfile_response(file_path)¶
- class cmn.views_mixins.FormatContentNegotiation¶
Bases:
cmn.views_mixins.FormatViewMixin
,cmn.views_mixins.DataViewMixin
,rest_framework.negotiation.DefaultContentNegotiation
ContentNegotiation based on ‘format’ as GET/POST parameter
- select_parser(request, parsers)¶
Given a list of parsers and a media type, return the appropriate parser to handle the incoming request.
- select_renderer(request, renderers, format_suffix)¶
Given a request and a list of renderers, return a two-tuple of: (renderer, media type).
- class cmn.views_mixins.FormatViewMixin¶
Bases:
object
Additional methods for views having ‘format’ option
- get_format_value(data)¶
Returns the ‘format’ value
Reads and adapts the ‘format’ value found in data
Available values : ‘json’, ‘api’, ‘yaml’, ‘xml’
Note: problem with ‘yaml’ and ‘xml’ (…import six…)
Bases:
object
Additional methods for views having some unavailable requests
Builds and returns response to an unavailable request
Returns error_message and more_message into error message
Module contents¶
cmn
This package is part of ws web services
- copyright
Copyright (C) 2020-2024 INRAE http://www.inrae.fr
- license
GPLv3, see LICENSE file for more details
- authors
see AUTHORS file
Common application
The cmn common application contains resources for other applications.