[google-app-engine-oil] push by ping.nsr...@gmail.com - Fixes the hardcoded App Engine path in gaeodoc.py. on 2010-11-27 05:40 GMT

1 view
Skip to first unread message

google-app...@googlecode.com

unread,
Nov 27, 2010, 12:40:43 AM11/27/10
to google-app...@googlegroups.com
Revision: 645a5fec4e
Author: Ping Yeh <pi...@pingyeh.net>
Date: Fri Nov 26 21:39:24 2010
Log: Fixes the hardcoded App Engine path in gaeodoc.py.
http://code.google.com/p/google-app-engine-oil/source/detail?r=645a5fec4e

Modified:
/bin/gaeodoc.py
/oildrum/lib/gaeo/app.py

=======================================
--- /bin/gaeodoc.py Fri Nov 26 08:22:34 2010
+++ /bin/gaeodoc.py Fri Nov 26 21:39:24 2010
@@ -19,14 +19,26 @@
import pydoc
import sys

-# Define the path to App Engine libraries.
-# TODO: make it work cross all platforms (it is only tested on Mac OS X
now).
-APPENGINE_PATH=('/Applications/GoogleAppEngineLauncher.app/Contents/Resources/'
- 'GoogleAppEngine-default.bundle/Contents/Resources/'
- 'google_appengine')
-
-
-def get_gaeo_path():
+
+def add_appengine_module_paths():
+ """Add paths needed to import App Engine's modules.
+
+ This function locates dev_appserver.py in the execution PATH,
+ imports it and calls its fix_sys_path() function to add necessary
paths.
+ """
+ directory = ''
+ for path in os.environ['PATH'].split(':'):
+ if os.path.exists(os.path.join(path, 'dev_appserver.py')):
+ directory = path
+ break
+ if directory:
+ sys.path.insert(0, directory)
+ dev_appserver = __import__('dev_appserver')
+ del sys.path[0]
+ dev_appserver.fix_sys_path()
+
+
+def add_gaeo_module_paths():
"""Gets the GAEO installation path.

This function derives the GAEO installation path from __file__, i.e.,
@@ -34,18 +46,15 @@
"""
binary_path, binary = os.path.split(__file__)
gaeo_path, bin = os.path.split(binary_path)
- return gaeo_path
+ sys.path.append(os.path.join(gaeo_path, 'oildrum', 'lib'))
+ sys.path.append(os.path.join(gaeo_path, 'oildrum', 'sample'))


def gaeodoc():
"""Produces pydoc for files specified in command line."""
# Prepare Python PATH for pydoc module to find relevant modules to
import.
- GAEO_PATH = get_gaeo_path()
- sys.path.append(APPENGINE_PATH)
- sys.path.append(os.path.join(APPENGINE_PATH, 'lib', 'yaml', 'lib'))
- sys.path.append(os.path.join(APPENGINE_PATH, 'lib', 'webob'))
- sys.path.append(os.path.join(GAEO_PATH, 'oildrum', 'lib'))
- sys.path.append(os.path.join(GAEO_PATH, 'oildrum', 'sample'))
+ add_appengine_module_paths()
+ add_gaeo_module_paths()

# Launch pydoc's command line interface.
pydoc.cli()
=======================================
--- /oildrum/lib/gaeo/app.py Fri Nov 26 07:12:06 2010
+++ /oildrum/lib/gaeo/app.py Fri Nov 26 21:39:24 2010
@@ -70,7 +70,8 @@
the request.
"""
super(GaeoRequest, self).__init__(environ, charset=charset,
- unicode_errors='ignore',
decode_param_names=True)
+ unicode_errors='ignore',
+ decode_param_names=True)

def get_all(self, argument_name):
"""Returns a list of query or POST arguments with the given name.

Reply all
Reply to author
Forward
0 new messages