I want to use bulkloader to download all entities in a model with some self-defined Property.
If I define a model like this,
class MyType:
def __init__(self, arg):
self.name = arg['name']
self.id = arg['id']
class MyProperty(db.Property):
def get_value_for_datastore(self, instance):
val = super(MyProperty, self).get_value_for_datastore(instance)
if type(val) == dict:
val = MyType(val)
return pickle.dumps(val)
def make_value_from_datastore(self, val):
return None if val is None else pickle.loads(str(val))
class MyModel(db.Model):
info = MyProperty()
then how can I download MyModel
using the bulkloader such that there will not be un-pickled value in the file? I think I should define the export_transform
for info
in bulkloader.yaml, but I don't know what it should be like.
transformers:
- kind: MyModel
connector: csv
property_map:
- property: __key__
external_name: log_id
export_transform: transform.key_id_or_name_as_string
- property: info
external_name: info
export_transform: ### HERE ###
I've seen transform.py but still have no idea about how it works. Please tell my any method that can solve my problem. Thanks.
info.name
orinfo.name,info.id
to the field "info" in the CSV file. – Highpressure