Created
December 20, 2015 16:36
-
-
Save nopdotcom/9af7d7bf156f64e5f0c7 to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Using dev_appserver.py from IPython" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"GAE_ROOT=\"/Users/nop/google-cloud-sdk/platform/google_appengine\"\n", | |
"import sys; sys.path.append(GAE_ROOT)\n", | |
"del sys.modules['google']\n", | |
"import wrapper_util\n", | |
"_PATHS = wrapper_util.Paths(GAE_ROOT)\n", | |
"sys.path = _PATHS.v1_extra_paths + sys.path" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"from google.appengine.tools.remote_api_shell import ndb, remote_api_stub, \\\n", | |
" memcache, urlfetch, users, db, ndb" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"----------" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This needs the following hack in your `appengine_config.py`:\n", | |
"```\n", | |
"if (os.environ.get('SERVER_SOFTWARE') and\n", | |
" os.environ['SERVER_SOFTWARE'].startswith('Development')):\n", | |
" remoteapi_CUSTOM_ENVIRONMENT_AUTHENTICATION = (\n", | |
" 'SERVER_SOFTWARE', [os.environ['SERVER_SOFTWARE']])\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This is the path to your *application*, not to the API server." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<google.appengine.tools.appengine_rpc_httplib2.HttpRpcServerOAuth2 at 0x112ab3110>" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"remote_api_stub.ConfigureRemoteApiForOAuth(\"localhost:9999\", \"/_ah/remote_api\", secure=False)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'value'" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"memcache.set(\"key\", \"value\")\n", | |
"memcache.get(\"key\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment