[protobuf] attributeError - cannot write to readonly attribute. Right way to access fields in multi level messages

2013-12-11 Thread Aditya Sakhuja
I am trying to correctly model a container queue_object using protobufs. It wraps ‘args’ message object and acts as the container for ‘eventing_template’ message object. Finally, ‘Data’ message object is extended by ‘admin’ and ‘analytics’ message object. Couple of things I am head heavy with rig

[protobuf] Use default value for string field in protobuf 2.5

2013-12-11 Thread chenjxu
Dears, I have a test.proto file like this: message Test { optional string str_1 = 1; optional string str_2 = 2 [default="3.0"]; } A default value is set for string field str_2. In the main file I defined a global Test instance and access str_2 in main function like this: #include "..."

[protobuf] Python windows adding erronous 0x0D bytes in message and then failing to parse

2013-12-11 Thread Andrew Beck
Using python 2.7.6 on darwin and windows, both using protoc 2.5.0 and libs from 2.5.0, the python code on windows (see test.py in the attached zip) contains two extra bytes valued 0x0D in the message compared to the darwin version. These extra bytes are preventing c++ libprotobuf from parsing th

[protobuf] AttributeError: 'event_template' object attribute 'appname' is read-only and modeling questions

2013-12-11 Thread Aditya Sakhuja
I am trying to correctly model a container queue_object using protobufs. It wraps ‘args’ message object and acts as the container for ‘eventing_template’ message object. Finally, ‘Data’ message object is extended by ‘admin’ and ‘analytics’ message object. Couple of things I am head heavy w

Re: [protobuf] Python windows adding erronous 0x0D bytes in message and then failing to parse

2013-12-11 Thread Oliver Jowett
Don't you want mode "wb"? Sounds like a classic case of opening a file in text mode and getting LF -> CRLF translation happening on Windows. Oliver On 11 December 2013 06:04, Andrew Beck wrote: > Using python 2.7.6 on darwin and windows, both using protoc 2.5.0 and libs > from 2.5.0, the pytho

Re: [protobuf] Use default value for string field in protobuf 2.5

2013-12-11 Thread Feng Xiao
On Wed, Dec 11, 2013 at 3:03 AM, wrote: > Dears, > I have a test.proto file like this: > > message Test { > optional string str_1 = 1; > optional string str_2 = 2 [default="3.0"]; > } > > A default value is set for string field str_2. In the main file I defined > a global Test instance an

Re: [protobuf] Python windows adding erronous 0x0D bytes in message and then failing to parse

2013-12-11 Thread Andrew Beck
Argh, yes 0x0D is CR Thanks for the help :) On Thursday, December 12, 2013 3:50:23 AM UTC+8, Oliver wrote: > > Don't you want mode "wb"? Sounds like a classic case of opening a file in > text mode and getting LF -> CRLF translation happening on Windows. > > Oliver > > > On 11 December 2013 06:04