2011-05-14 43 views
0

我想在使用bulkloader.yaml上傳數據時使用post_import_function。根據此鏈接,Using post_import_function in App Engine bulkuploader yaml,我正在使用類型google.appengine.api.datastore.Entity來進行實體操作。在鏈接中,這是'dict'的一個子類。不過,我不確定如何將方法應用於此實體。post_import_function在App Engine bulkuploader yaml

我的代碼看起來像(我用的地質模型):

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(),就是我有問題。我不知道如何寫這個聲明。

回答

0

您不能將方法添加到Entity。只需內聯代碼,或者將其作爲您將實體傳遞給的單獨函數來編寫。

+0

感謝您的意見。內聯代碼工作! – Sunil 2011-05-15 03:22:15