app engine bulkloader post_import_function - how to call method on entity

139 Views Asked by At

Trying to use python GeoModel class and the bulkloader. I'm calling the following post_import_function which works fine and the entity is updated with the location field set properly.

def post_process_obj(input_dict, entity_instance, bulkload_state):
    entity_instance['location'] = db.GeoPt(entity_instance['latitude'], entity_instance['longitude'])
    return entity_instance

But what I need to do is call entity_instance.update_location() on the entity before it saves to the data store. The entity_instance though is an Entity, not a subclass of GeoModel so I'm not clear how to do this. There was a post a while back that said inline the code or call a function and pass the entity to it but I don't know what that was supposed to mean.

Thanks for any help/sample code.

1

There are 1 best solutions below

1
On BEST ANSWER

You can't do this - as you observed, you're dealing with an Entity, not an instance of your model. The only option is to take the code that you want to execute it, copy-and-paste it, and modify it to work with an entity instead.