Skip to content

Instantly share code, notes, and snippets.

@theacodes
Created January 14, 2015 17:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theacodes/37c116b02f6de80f1d11 to your computer and use it in GitHub Desktop.
Save theacodes/37c116b02f6de80f1d11 to your computer and use it in GitHub Desktop.
Ferris 3 example with custom properties
import ferris3
import endpoints
import protopigeon
from protorpc import messages
from google.appengine.ext import ndb
class ExampleProperty(ndb.StringProperty):
def _to_base_type(self, value):
return "---" + str(value) + "---"
def _from_base_type(self, value):
return value.strip('-')
class ExampleModel(ndb.Model):
normal = ndb.StringProperty()
custom = ExampleProperty()
class ExamplePropertyConverter(protopigeon.converters.Converter):
@staticmethod
def to_field(Model, property, count):
return messages.StringField(count, repeated=property._repeated, required=property._required)
protopigeon.converters.converters["ExampleProperty"] = ExamplePropertyConverter
@ferris3.auto_service
class CustomService(ferris3.Service):
list = ferris3.hvild.list(ExampleModel)
insert = ferris3.hvild.insert(ExampleModel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment