Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.ext.db
- import: google.appengine.api.datastore
- import: google.appengine.api.users
- import: postimport
transformers:
- kind: MyModel
connector: simplexml
connector_options:
xpath_to_nodes: /whatever
style: element_centric
post_import_function: postimport.unindex_properties
property_map:
- ...props definitions...
from google.appengine.api import datastore
_UNINDEXED_PROPS = {
'MyModel': ['prop1', 'prop2', 'prop3'],
'MyOtherModel': ['some_prop']
}
def unindex_properties(input_dict, entity, bulkload_state_copy):
"""
Runs on after every entity import and sets correct unindexed properties.
"""
if isinstance(entity, datastore.Entity):
kind = entity.kind()
if kind in _UNINDEXED_PROPS:
props = _UNINDEXED_PROPS[kind]
entity.set_unindexed_properties(props)
return entity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment