简体   繁体   中英

Calling Python API - Google App Engine

I am a little confused when it comes to using the API generated from the .JAR that was generated from using my Python API for Google App Engine.

Below there is an example of a method and an AsyncTask to create and store an Event entity in the Datastore.

Would you typically use the Request/Response Messages to pass data to the entity?

I have an Event class that has an insert() method but it doesn't let me pass any of the event details to it because it lacks any setters/getters like the Request/Response classes

private void sendResultToServer(String eventDesc, String eventName,
        String eventTime) {
    ImhotepApiMessagesEventRequest newEvent = new ImhotepApiMessagesEventRequest();
    newEvent.setEventDesc(eventDesc);
    newEvent.setEventTitle(eventName);
    newEvent.setEventTime(eventTime);
    new SendResultToServerTask().execute(newEvent, null, null);
}

/**
 * Handles the request to the Event Endpoint, to save a event, without
 * blocking the UI.
 */
private class SendResultToServerTask extends
        AsyncTask<ImhotepApiMessagesEventRequest, Void, Void> {

    @Override
    protected Void doInBackground(
            ImhotepApiMessagesEventRequest... params) {
        // TODO Auto-generated method stub
        service.event();
        return null;
    }

The Java Using the Datastore example is a good starting point for creating your own Entities with the guestbook doPost handler. After the example is up and running you could extend it towards Task Queues.

The first code example in Using Push Queues in Java adds a named parameter to an asynchronous task invocation. According to Class TaskOptions you can chain .param("name","value") calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM