0

我在使用 bulkloader.yaml 上传数据时尝试使用 post_import_function。根据此链接,在 App Engine bulkuploader yaml 中使用 post_import_function,我使用类型 google.appengine.api.datastore.Entity 进行实体操作。如链接中所示,这是“dict”的子类。但是我不确定如何将方法应用于该实体。

我的代码看起来像(我正在使用 Geomodel):

   def post_import_restaurants(input_dict, instance, bulkload_state_copy):

        lat = instance['lat']
        lng = instance['lng']
        latlng = "%s,%s" % (lat,lng)
        instance['location'] = db.GeoPt(latlng)
        instance.update_location()
        return instance

instance.update_location(),是我遇到问题的地方。我不知道如何写这个声明。

4

1 回答 1

0

您不能将方法添加到Entity. 只需内联代码,或将其编写为您将实体传递给的单独函数。

于 2011-05-14T23:30:44.113 回答