This feature was just implemented internally, and I believe it should make
the next release (2.5.0). It's in progress, but not quite ready to hit svn
yet.


On Thu, Aug 30, 2012 at 6:53 AM, Jan Koriťák <je...@pudr.com> wrote:

> Hello,
>
> I am using Python to write a tool to control our backends which
> communicate using protocol buffers.
>
> We would like our tool to be independent on current version of backends
> and therefore independent on .proto files that were used to build the
> particular version of the backend.
>
> Therefore the tool receives serialized FileDescriptorSet over network,
> which should allow to create messages from the same descriptors, that are
> used at the backend side.
>
> This is possible to implement in C++ (and we actually use it in another
> component) using DynamicMessage. (Create DescriptorPool, load all the 
> FileDescriptors
> to the pool using BuildFile(), and then retrieve Descriptor from the
> pool. Then it is possible to create message using DynamicMessageFactory)
>
> However, after thorough research on the web and of the source code of
> protocol buffers python bindings, I couldn't figure out how to do this
> (version 2.4.0).
>
> I was able to deserialize FileDescriptorSet, iterate over FileDescriptorProtos
> and get DescriptorProto object. However I didn't find a way to construct 
> Descriptor
> objects, which are needed to create classes for message types(with 
> GeneratedProtocolMessageType
> as a metaclass).
>
> I tried another way, when I found some access to C++ library API in
> google.protobuf.internal (which is probably not a good idea to use). I
> tried to indirectly use the C++ descriptor pool by cpp_message.BuildFile(),
> but there is no way to get the Descriptor object back from the pool (it
> would be C++ object anyway). However there is a method
> cpp_message.NewCMessage, which can construct a message using descriptors
> from the pool. I was able to construct messages that way, but I was unable
> to set any fields. Only method that appeared usable was SetScalar, which
> requires C++ decriptor, which I was unable to get. Not to mention all of
> the Python magic is gone when dealing directly with the C++ API.
>
> Is there any way to create messages of arbitrary type, which is
> distributed over network, in Python ? I see those possibilities in both
> Java and C++, is Python library lacking such funcionality ?
>
> Thank you very much, hope I was clear enough.
> Best regards,¨
>
> Jan Koritak
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/protobuf/-/LEFgfPpImWEJ.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to