Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



The Field Class

The Field class is the base class for all fields defined on messages. This class cannot be extended by developers.

Field is provided by the protorpc.messages module.

  1. Field()
  2. Class Properties
  3. Instance Methods

Constructor

The constructor of the Field class is defined as follows:

class Field ( message_type , number , [ required = False | repeated
= False ], variant = None , default = None )

Initializes an Field instance. Each sub-class of Field must define the following:

VARIANTS
Set of variant types accepted by that field.
DEFAULT_VARIANT
Default variant type if not specified in constructor.

Arguments

number
Number of the field. Must be unique per message class.
required = False
Whether or not this field is required. Mutually exclusive with the repeated argument; do not specify repeated if you use required .
repeated = False
Whether or not this field is repeated. Mutually exclusive with the required argument; do not specify required=True if you also use repeated=True .
variant = None
Provides additional encoding information that is mainly used by protocol buffers. These variants map to the Type values in descriptor.proto . Best practice is to use default values, but you can specify values as 32-bit, 64-bit, unsigned, etc.
default = None
Default value for the field if not found in the underlying request.

Note: Default values are not permitted for repeated fields or message fields.

Raises the following exceptions:

Class Property

The FieldList class has one property:

default()
The default value for the field.

Instance Methods

FieldList instances have the following methods:

validate ( value )
Validates a value assigned to a field.

Arguments

value
The value to evaluate.

Raises a ValidationError if the value is not an expected type.

validate_default_element ( value )

Validates a value assigned to a default field. Specific to a single element.

Some fields may allow for delayed resolution of default types necessary in the case of circular definition references. In this case, the default value might be a placeholder that is resolved when needed after all the message classes are defined.

Arguments

value
Default value to validate.

Raises a ValidationError if the value is not an expected type.

validate_default ( value )

Validates that a field's default value.

Arguments

value
Default value to validate.

Raises a ValidationError if the value is not an expected type.

message_definition ()

Gets a message definition that contains this Field definition. Returns a definition for the Message object that contains the Field. Returns None if Field is defined outside of a message class.

Raises a ValidationError if the value is not an expected type.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.