You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/20 19:46:49 UTC
[16/17] git commit: [#6701] Added support for virtualenv to
ApacheAccessHandler
[#6701] Added support for virtualenv to ApacheAccessHandler
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4c90effb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4c90effb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4c90effb
Branch: refs/heads/cj/6701
Commit: 4c90effbd0bef38f62aa2aa2dae32dcb2fcd6e97
Parents: a71aa70
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Mar 18 22:49:45 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Mar 20 18:43:46 2014 +0000
----------------------------------------------------------------------
scripts/ApacheAccessHandler.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4c90effb/scripts/ApacheAccessHandler.py
----------------------------------------------------------------------
diff --git a/scripts/ApacheAccessHandler.py b/scripts/ApacheAccessHandler.py
index 585c6b2..946898b 100644
--- a/scripts/ApacheAccessHandler.py
+++ b/scripts/ApacheAccessHandler.py
@@ -22,6 +22,7 @@ Here is a quick example for your apache settings (assuming ProxyPass)
AuthBasicAuthoritative off
PythonOption ALLURA_PERM_URL https://127.0.0.1/auth/repo_permissions
PythonOption ALLURA_AUTH_URL https://127.0.0.1/auth/do_login
+ PythonOption ALLURA_VIRTUALENV /var/local/env-allura
</Location>
"""
@@ -29,14 +30,26 @@ Here is a quick example for your apache settings (assuming ProxyPass)
from mod_python import apache
import os
-import requests
import json
+requests = None # will be imported on demand, to allow for virtualenv
+
+
def log(req, message):
req.log_error("Allura Access: %s" % message, apache.APLOG_WARNING)
+def load_requests_lib(req):
+ virtualenv_path = req.get_options().get('ALLURA_VIRTUALENV', None)
+ if virtualenv_path:
+ activate_this = '%s/bin/activate_this.py' % virtualenv_path
+ execfile(activate_this, {'__file__': activate_this})
+ global requests
+ import requests as requests_lib
+ requests = requests_lib
+
+
# This came straight from accessfs.py
def mangle(path):
'''Convert paths from the form /SCM/neighborhood/project/a/b/c to
@@ -109,6 +122,7 @@ def check_permissions(req):
def handler(req):
+ load_requests_lib(req)
req.add_common_vars()
if not check_repo_path(req):