When running a Python Web Application on App Engine, we need to set up some mechanism to execute some code before (or during) the application's initialization. This means that, in the optimal solution, the code that we need to run is executed as early as possible. The purpose of this is to allow for the App Engine remote_api to be initialized before the local datastore is accessed, so as to prevent datastore access conflicts.
This is a very rough example of what we're looking for:
imports (including remote_api)
def some_initialization_function_or_similar (args):
some_init_function_calls(...)
setup_remote_api(...)
access_datastore_the_first_time(...)
Please take this question as reference to the scenario we're looking at: Using GAE remote api for debugging from localhost - Connecting too late?