2014-01-14 40 views
0

当涉及到使用从我的Python API for Google App Engine生成的.JAR生成的API时,我有点困惑。调用Python API - Google App Engine

下面是一个方法和AsyncTask的示例,用于在数据存储中创建和存储Event实体。

您通常会使用请求/响应消息将数据传递给实体吗?

我有了一个insert()方法的事件类,但它不会让我过去的任何事件的细节,因为它没有任何setter方法/干将如请求/响应类

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; 
    } 
+0

AppEngine Java和Python API是分开的,并且移植Python代码将不起作用。你似乎错过了一些概念。您的示例是Java,因此您应该学习[Java Datastore API](https://developers.google.com/appengine/docs/java/datastore/)和[Samples](https://developers.google.com/appengine/ )。要回答您的问题,是的,您通常会在doPost事件处理程序中使用请求参数来将数据传递给实体,并从HTML表单或jQuery Ajax调用提交帖子。 –

回答

0

Java Using the Datastore示例是使用guestbook doPost处理程序创建自己的实体的良好起点。示例启动并运行后,可以将其扩展到任务队列。

Using Push Queues in Java中的第一个代码示例将一个命名参数添加到异步任务调用中。根据Class TaskOptions您可以链接.param(“名称”,“价值”)调用。