Created
January 14, 2015 17:43
-
-
Save theacodes/37c116b02f6de80f1d11 to your computer and use it in GitHub Desktop.
Ferris 3 example with custom properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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