Pregunta

I've defined some message types that I'd like to use in my protorpc service on app engine, but the service in throwing an error because it is finding members that are methods, instead of messages.Field instances. Is there a way to get around this? Because defining methods on messages is really useful. In my example, I have a credentials message, and I've defined a method to check if the credentials are correct, on the message. I know I can just define the methods as functions, but it just seams less logical.

¿Fue útil?

Solución

One of the goals of ProtoRPC is to remain as faithful to the implementation of Protocol buffers as possible. Writing a protocol buffer using .proto notation does not allow for method definitions. So if one could define methods you would end up with classes that could not correctly be represented as a .proto file. As an aside, the hope is that it makes the developer enforce a clear distinction between their message classes and client/server functionality.

We also went through a lot of effort to make sure that if we needed to make future changes (such as adding support for the protocol buffer mechanism) it easier to do so without breaking compatibility with older versions. Because it was intended for being built in to the App Engine runtime the library is updated automatically when a new version of App Engine is released, not when the developer is ready to upgrade. Restricting what can be added to messages now allows greater flexibility for the library to grow in the future (in truth, at the expense of the user of the library).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top