简体   繁体   English

调用Python API-Google App Engine

[英]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. 对于使用从.JAR生成的API而言,我有些困惑,该API是使用我的Google App Engine的Python API生成的。

Below there is an example of a method and an AsyncTask to create and store an Event entity in the Datastore. 下面有一个示例和一个AsyncTask,用于在数据存储区中创建和存储事件实体。

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 我有一个具有insert()方法的Event类,但是它不允许我将任何事件详细信息传递给它,因为它缺少诸如Request / Response类的任何设置方法/获取方法

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. Java 使用数据存储区示例是使用 guestbook doPost处理程序创建自己的实体的良好起点。 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. Java使用推入队列中的第一个代码示例将命名参数添加到异步任务调用中。 According to Class TaskOptions you can chain .param("name","value") calls. 根据Class TaskOptions,您可以链接.param(“ name”,“ value”)调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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