Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes Class Reference

List of all members.

Public Member Functions

def parse_protobuf

Static Public Attributes

 protobuf_check_initialization = True

Detailed Description

Add protobuf parsing method to a request object.  This will parse the
input data through `protobuf`_ if possible.

:exc:`~werkzeug.exceptions.BadRequest` will be raised if the content-type
is not protobuf or if the data itself cannot be parsed property.

.. _protobuf:

Definition at line 51 of file

Member Function Documentation

Parse the data into an instance of proto_type.

Definition at line 67 of file

00068     def parse_protobuf(self, proto_type):
00069         """Parse the data into an instance of proto_type."""
00070         if 'protobuf' not in self.environ.get('CONTENT_TYPE', ''):
00071             raise BadRequest('Not a Protobuf request')
00073         obj = proto_type()
00074         try:
00075             obj.ParseFromString(
00076         except Exception:
00077             raise BadRequest("Unable to parse Protobuf request")
00079         # Fail if not all required fields are set
00080         if self.protobuf_check_initialization and not obj.IsInitialized():
00081             raise BadRequest("Partial Protobuf request")
00083         return obj

Here is the call graph for this function:

Member Data Documentation

Definition at line 65 of file

The documentation for this class was generated from the following file: