Skip to content

Latest commit

 

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Python Integration

Overview

These examples show how to integrate Google Protocol Buffers with Ice for Python.

Ice supports metadata that makes it possible for you to specify Protocol Buffers message types in your Slice definitions, with Ice handling the serialization chores for you automatically. The metadata, which may only be used on a sequence type, has the following syntax in Python:

python:protobuf:protoc-generated-class

For example:

["python:protobuf:Person_pb2.Person"] sequence<byte> Person;

The type name specified in this example, Person_pb2.Person, corresponds to the Python class generated by the Protocol Buffers compiler (protoc) for the definition shown below:

package tutorial;
message Person { ... };

Prerequisites

You'll need to install Ice for Python in order to use any of the sample programs. Our documentation describes how to install the Python packages.

Running the Demo

Prior to running the demo, you must generate the Python code for Person.proto by running the following command in the demo directory:

$ protoc --python_out=. Person.proto

To run the demo, first from the demo directory start the server:

$ python Server.py

In a separate window, start the client:

$ python Client.py

Running the Test

To run the test, change to the test directory and run the python script found there.

$ cd test
$ python run.py