Warning

You are reading the documentation for the latest committed changes of the Protocol Buffers package for Python. Some features may not yet be released. Read the documentation for the latest released package at googleapis.dev.

google.protobuf.service_reflection

Contains metaclasses used to create protocol service and service stub classes from ServiceDescriptor objects at runtime.

The GeneratedServiceType and GeneratedServiceStubType metaclasses are used to inject all useful functionality into the classes output by the protocol compiler at compile-time.

class google.protobuf.service_reflection.GeneratedServiceStubType(name, bases, dictionary)

Metaclass for service stubs created at runtime from ServiceDescriptors.

This class has similar responsibilities as GeneratedServiceType, except that it creates the service stub classes.

mro()

Return a type’s method resolution order.

class google.protobuf.service_reflection.GeneratedServiceType(name, bases, dictionary)

Metaclass for service classes created at runtime from ServiceDescriptors.

Implementations for all methods described in the Service class are added here by this class. We also create properties to allow getting/setting all fields in the protocol message.

The protocol compiler currently uses this metaclass to create protocol service classes at runtime. Clients can also manually create their own classes at runtime, as in this example:

mydescriptor = ServiceDescriptor(.....)
class MyProtoService(service.Service):
  __metaclass__ = GeneratedServiceType
  DESCRIPTOR = mydescriptor
myservice_instance = MyProtoService()
# ...
mro()

Return a type’s method resolution order.