Created
August 14, 2012 17:51
-
-
Save x1ddos/3351222 to your computer and use it in GitHub Desktop.
Bulkload with correctly unindexed properties: http://alex.cloudware.it/2012/08/unindexed-entity-properties-with-bulk.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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