That is strange. Can you provide a minimal but complete program that reproduces this problem, so I can look at it?
On Wed, Nov 10, 2010 at 12:42 AM, Vsevolod Zadubrovsky < zadubrov...@gmail.com> wrote: > It seems to me, it doesn't work at all. > > I got this: > >(Pdb) import ooo > >(Pdb) vals_by_nums = > req.DESCRIPTOR.fields_by_name['error'].enum_type.values_by_number[req.error] > >(Pdb) options = vals_by_nums.GetOptions() > >(Pdb) options.Extensions[ooo.verbose_enum_value_option] > *** KeyError: 'Extension "verbose_enum_value_option" extends message > type "google.protobuf.EnumValueOptions", but this message is of type > "google.protobuf.EnumValueOptions".' > > I've checked the source code, and it looks like raised from here > (google.protobuf.reflection, line 224): > > if extension_handle.containing_type is not message.DESCRIPTOR: > raise KeyError('Extension "%s" extends message type "%s", but this > ' > 'message is of type "%s".' % > (extension_handle.full_name, > extension_handle.containing_type.full_name, > message.DESCRIPTOR.full_name)) > > Any ideas ? may be it is already solved in trunk version? > > Thanks > > On Nov 10, 1:50 am, Kenton Varda <ken...@google.com> wrote: > > You need to use the descriptor for the enum type. Unfortunately this > > interface isn't very well fleshed-out in Python. I think you'd have to > > write something like: > > > > > Request.DESCRIPTOR.fields_by_name['error'].enum_type.values_by_number[message.error].options.Extensions[verbose_enum_value_option] > > > > I haven't checked that that's exactly correct, but it gives you an idea. > We > > should probably improve this. > > > > On Tue, Nov 9, 2010 at 4:12 AM, Vsevolod Zadubrovsky > > <zadubrov...@gmail.com>wrote: > > > > > Hi, I'm stuck with getting the enum value option in Python. The proto > > > file is: > > > > > import "descriptor.proto"; > > > > > extend google.protobuf.EnumValueOptions { > > > optional string verbose_enum_value_option = 50005; > > > } > > > > > enum ErrorType { > > > OK = 1 [(verbose_enum_value_option) = "OK"]; > > > SOME_ERROR = 2 [(verbose_enum_value_option) = "Some Error > verbose > > > message"]; > > > } > > > > > message Request { > > > required bool success = 1; > > > optional ErrorType error = 2; > > > } > > > > > When I receive the Request message, I can access the 'error' field, > > > and its type is int, that's actually ok. But how can I get the > > > verbose_enum_value_option of 'error' field value ? > > > > > Thanks > > > > > p.s. The goal is to keep error types and their verbose error messages > > > in one place, available for every service in our project, so the error > > > messages would've been identical. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Protocol Buffers" group. > > > To post to this group, send email to proto...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com> > <protobuf%2bunsubscr...@googlegroups.com<protobuf%252bunsubscr...@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 proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@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 proto...@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.