App Engine 批量上传器 yaml 中的 post_import_function
我尝试在使用bulkloader.yaml上传数据时使用post_import_function。根据此链接,在 App Enginebulkuploader 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()
,这是我遇到问题的地方。我不知道如何写这个声明。
I am trying to use post_import_function while uploading data using bulkloader.yaml. As per this link, Using post_import_function in App Engine bulkuploader yaml , I am using type google.appengine.api.datastore.Entity for entity operations. As in the link, this is a subclass of 'dict'. However I am not sure how do I apply methods to this entity.
My code looks like (I am using 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()
, is where I am having issues. And I am not sure how to write this statement.
您无法向
实体
添加方法。只需内联代码,或者将其编写为将实体传递给的单独函数。You can't add methods to an
Entity
. Just inline the code, or write it as a separate function that you pass the entity to.