import datetime
from protorpc import messages
from protorpc import message_types
from protorpc import remote
import helloworld
class Note(messages.Message):
text = messages.StringField(1, required=True)
when = messages.IntegerField(2)
class PostService(remote.Service):
# Add the remote decorator to indicate the service methods
@remote.method(Note, message_types.VoidMessage)
def post_note(self, request):
# If the Note instance has a timestamp, use that timestamp
if request.when is not None:
when = datetime.datetime.utcfromtimestamp(request.when)
# Else use the current time
else:
when = datetime.datetime.now()
note = helloworld.Greeting(content=request.text, date=when)
note.put()
return message_types.VoidMessage()