Skip to content

Instantly share code, notes, and snippets.

@x1ddos
Created August 14, 2012 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x1ddos/3351222 to your computer and use it in GitHub Desktop.
Save x1ddos/3351222 to your computer and use it in GitHub Desktop.
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