# HG changeset patch # User Sverre Rabbelier # Date 1238545790 0 # Node ID 1fb1c628ad60bc546c5bc5e881e0d711ab581258 # Parent e7cf95cc4c1849588cf39ab74b29c09646b7d1b7 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 diff -r e7cf95cc4c18 -r 1fb1c628ad60 scripts/interactive.py --- a/scripts/interactive.py Wed Apr 01 00:29:34 2009 +0000 +++ b/scripts/interactive.py Wed Apr 01 00:29:50 2009 +0000 @@ -80,13 +80,20 @@ 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 @@ 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 @@ import main as app_main +def main(args): + """Convenience wrapper that calls setup and remote. + """ + + setup() remote(args)