From 13c782eaa6f7d22f5eabe55843b88b3bf8cd0ed8 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 27 Aug 2013 16:57:54 -0500 Subject: [PATCH] handlers check for 'applications' folder --- VERSION | 2 +- handlers/README | 6 +++--- handlers/cgihandler.py | 4 ++++ handlers/fcgihandler.py | 4 ++++ handlers/gaehandler.py | 6 ++++++ handlers/isapiwsgihandler.py | 2 ++ handlers/modpythonhandler.py | 4 ++++ handlers/scgihandler.py | 4 ++++ handlers/wsgihandler.py | 4 ++++ 9 files changed, 32 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 3990eafc..3f60c786 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.6.0-development+timestamp.2013.08.27.16.49.41 +Version 2.6.0-development+timestamp.2013.08.27.16.57.03 diff --git a/handlers/README b/handlers/README index d999feca..271d0358 100644 --- a/handlers/README +++ b/handlers/README @@ -1,3 +1,3 @@ -This folder contains example files. -They much be copied to the web2py root folder in order to work properly. -They should not be linked in the handlers folder. +This folder contains example handlers. +They must be copied to the web2py root folder in order to work properly. +They should not be used in their current location. diff --git a/handlers/cgihandler.py b/handlers/cgihandler.py index 0929ed15..0d1da193 100755 --- a/handlers/cgihandler.py +++ b/handlers/cgihandler.py @@ -56,6 +56,10 @@ import wsgiref.handlers path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] import gluon.main diff --git a/handlers/fcgihandler.py b/handlers/fcgihandler.py index 7d5719fb..85e5117d 100755 --- a/handlers/fcgihandler.py +++ b/handlers/fcgihandler.py @@ -34,6 +34,10 @@ import os path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] import gluon.main diff --git a/handlers/gaehandler.py b/handlers/gaehandler.py index 30c49ecc..ae1ce542 100755 --- a/handlers/gaehandler.py +++ b/handlers/gaehandler.py @@ -33,6 +33,12 @@ import wsgiref.handlers import datetime path = os.path.dirname(os.path.abspath(__file__)) + +# os.chdir(path) ? + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] sys.modules['cPickle'] = sys.modules['pickle'] diff --git a/handlers/isapiwsgihandler.py b/handlers/isapiwsgihandler.py index e3f38789..5bf9a7ed 100644 --- a/handlers/isapiwsgihandler.py +++ b/handlers/isapiwsgihandler.py @@ -10,6 +10,8 @@ def __ExtensionFactory__(): import sys path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') sys.path = [path] + [p for p in sys.path if not p == path] import gluon.main import isapi_wsgi diff --git a/handlers/modpythonhandler.py b/handlers/modpythonhandler.py index de4ee65f..271cb861 100755 --- a/handlers/modpythonhandler.py +++ b/handlers/modpythonhandler.py @@ -34,6 +34,10 @@ from mod_python import apache path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] import gluon.main diff --git a/handlers/scgihandler.py b/handlers/scgihandler.py index 2c3fb03c..0f2cadb8 100755 --- a/handlers/scgihandler.py +++ b/handlers/scgihandler.py @@ -47,6 +47,10 @@ import os path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] import gluon.main diff --git a/handlers/wsgihandler.py b/handlers/wsgihandler.py index eadf2ab1..a136daa6 100644 --- a/handlers/wsgihandler.py +++ b/handlers/wsgihandler.py @@ -26,6 +26,10 @@ import os path = os.path.dirname(os.path.abspath(__file__)) os.chdir(path) + +if not os.path.exists('applications'): + raise RuntimeError('Running from the wrong folder') + sys.path = [path] + [p for p in sys.path if not p == path] sys.stdout = sys.stderr