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 MessageField Class

The MessageField class is used to define messages for efficient transmission across network or process space. Messages are defined using field classes .

MessageField is provided by the protorpc.messages module.

  1. MessageField()
  2. Class Property

Constructor

The constructor of the MessageField class is defined as follows:

class MessageField ( message_type , number , [ required = False | repeated
= False ])

Defines fields for sub-message values.

Arguments

message_type
The message type for the field. Must be a subclass of Message .
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=True if you use required=True .
repeated = False
Whether or not this field is repeated. Mutually exclusive with the required argument; do not specify required=True if you use repeated=True .

Raises a FieldDefinitionError if the message_type is invalid.

Class Property

The MessageField class provides the following properties:

type
The Python type used for values of this field. For example, in the case of DateTimeField , type is datetime.datetime . For user defined MessageFields, type is the specified Message type.
message_type
The underlying message type used for serialization. Specifically this is the type that you can store on an instance of a Message class. For example, for DateTimeField , the type will be message_types.DateTimeMessage . For normal message fields it will be the protorpc message subclass. For example:
class Sub(messages.Message):
  x = messages.IntegerField(1)

class M(messages.Message):
  sub = messages.MessageField(Sub, 1)
  dt = message_types.DateTimeField(2)

print 'M.sub.type         =', M.sub.type
print 'M.sub.message_type =', M.sub.message_type
print 'M.dt.type          =', M.dt.type
print 'M.dt.message_type  =', M.dt.message_type


=== output ===
M.sub.type                 = <class '__main__.Sub>
M.sub.message_type = <class '__main__.Sub'>
M.dt.type                   = <type 'datetime.datetime'>
M.dt.message_type   = <class 'protorpc.message_types.DateTimeMessage'>

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.