From 9c2b56cbd18a98c88b94e6bb0919993235a30775 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Wed, 1 Apr 2009 00:29:50 +0000 Subject: [PATCH] Factor out the setup() method in interactive Also allow specifying a custom context dictionary in remote, which will be used by the stats module to add helper methods. Patch by: Sverre Rabbelier --- scripts/interactive.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/interactive.py b/scripts/interactive.py index 78242346..12ab7b22 100755 --- a/scripts/interactive.py +++ b/scripts/interactive.py @@ -80,13 +80,20 @@ def deepFetch(queryGen,key=None,batchSize = 100): key = results[-1].key() -def remote(args): +def remote(args, context=None): """Starts a shell with the datastore as remote_api_stub. + + Args: + args: arguments from the user + context: locals that should be added to the shell """ from google.appengine.ext import db from google.appengine.ext.remote_api import remote_api_stub + if not context: + context = {} + app_id = args[0] if len(args) > 1: @@ -96,14 +103,12 @@ def remote(args): remote_api_stub.ConfigureRemoteDatastore(app_id, '/remote_api', auth_func, host) - context = { - 'deepFetch': deepFetch, - } + context['deepFetch'] = deepFetch code.interact('App Engine interactive console for %s' % (app_id,), None, context) -def main(args): +def setup(): """Sets up the sys.path and environment for development. """ @@ -127,6 +132,11 @@ def main(args): import main as app_main +def main(args): + """Convenience wrapper that calls setup and remote. + """ + + setup() remote(args) -- 2.11.4.GIT