Commit c7bafc71 authored by Alain Takoudjou's avatar Alain Takoudjou

Update wsgi support in Trac

parent 714c964e
......@@ -84,13 +84,13 @@ class Recipe(GenericBaseRecipe):
shutil.rmtree(project_dir)
self.logger.error("Failed to initialize Trac.\nThe error was: %s" % result)
return []
os.mkdir(self.options['wsgi-dir'])
os.mkdir(self.options['git-dir'])
os.mkdir(self.options['svn-dir'])
os.mkdir(self.options['wsgi-dir'])
os.unlink(config)
shutil.copy(self.options['trac-ini'].strip(), config)
shutil.copy(self.options['trac-wsgi'].strip(),
os.path.join(self.options['wsgi-dir'], 'trac.wsgi'))
os.path.join(self.options['wsgi-dir'], 'trac.wsgi'))
else:
self.logger.info("The directory %s already exist, skip project installation"
% project_dir)
......
......@@ -198,7 +198,7 @@ url = ${template-httpd-conf:location}/${template-httpd-conf:filename}
output = $${rootdirectory:etc}/apache.conf
document_root = $${rootdirectory:srv}/site/
wsgi_location = $${inittrac:wsgi-dir}
wsgi_location = $${rootdirectory:srv}/site/apache
gitweb-static-dir = ${gitweb:location}/share/gitweb/static/
gitweb-script = $${gitweb-cgi:output}
git-http-backend = $${git-http-backend-cgi:output}
......@@ -238,10 +238,11 @@ mysql_port = $${stunnel:local-port}
[trac-wsgi]
recipe = slapos.recipe.template
url = ${tracWsgi:location}/${tracWsgi:filename}
output = $${directory:tracconfig}/trac-apache.wsgi
output = $${directory:tracconfig}/trac.wsgi
mode = 0700
htdocs = $${trac-config:project_dir}
trac_env = $${trac-config:project_dir}
python_bin = ${python2.7:location}/bin/python2.7
[trac-svn-hook-script]
recipe = slapos.recipe.template
......@@ -284,7 +285,7 @@ svn_python = ${subversion-1.9:location}/lib/svn-python
recipe = slapos.recipe.template
url = ${template-gitweb-conf:location}/${template-gitweb-conf:filename}
output = $${rootdirectory:etc}/gitweb.conf
url-list = $${trac-config:project_url}/git git://[$${slap-network-information:global-ipv6}]
url-list = $${trac-config:project_url}/git http://[$${slap-network-information:global-ipv6}]:8080/git git://[$${slap-network-information:global-ipv6}]
base-directory = $${trac-config:project_dir}/git
[gitweb-cgi]
......@@ -356,7 +357,6 @@ user-list = $${slap-parameter:trac-user-list}
recipe = slapos.cookbook:wrapper
command-line = ${apache:location}/bin/httpd -DFOREGROUND -f "$${httpd-conf:output}"
environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path}
PATH=${python2.7:location}/bin:%(PATH)s
wrapper-path = $${basedirectory:services}/httpd
wait-for-files = $${inittrac:file-status}
......
......@@ -5,10 +5,10 @@ develop =
# ${trac-plugins-egg:location}/accountmanager
parts =
apache-wsgi
slapos-cookbook
gitweb
gitweb
subversion-1.9
apache-wsgi
instance-egg
instance
instance-trac
......@@ -29,8 +29,9 @@ parts =
extends =
../../stack/slapos.cfg
../../component/apache/buildout.cfg
../../component/python-2.7/buildout.cfg
../../component/apache/buildout.cfg
../../component/apache-wsgi/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/subversion/buildout.cfg
../../component/gzip/buildout.cfg
......@@ -39,7 +40,6 @@ extends =
../../component/stunnel/buildout.cfg
../../component/lxml-python/buildout.cfg
../../component/mysql-python/buildout.cfg
../../component/apache-wsgi/buildout.cfg
../../component/git/buildout.cfg
../../component/pwgen/buildout.cfg
../../component/shellinabox/buildout.cfg
......@@ -89,7 +89,7 @@ md5sum = bc6ed91a1862a10af661713aa0691848
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-trac.cfg
output = ${buildout:directory}/template-trac.cfg
md5sum = a29c55056b5ce5a7409b14c54cfc00ad
md5sum = 2ffa830873895fd4a014bf038119ff82
mode = 0644
[instance-mariadb]
......@@ -113,7 +113,7 @@ md5sum = 10286b368b9b6eacae2cdd6caf362759
[tracWsgi]
<= template-download
filename = trac.wsgi.in
md5sum = 622ca33ed7299409afec43bb79e4c7e9
md5sum = 5226978477d3336f21f0d8684d23a55a
[trac-svn-hook]
<= template-download
......@@ -138,7 +138,7 @@ md5sum = 7ec8822bd5676c3506f079e33ed9f771
[template-httpd-conf]
<= template-download
filename = apache.in
md5sum = be3418e3053ec7f74a3df21830a7edc0
md5sum = 452ff6c77211e312be0227155a83931c
[template-gitweb-cgi]
<= template-download
......
......@@ -15,6 +15,8 @@ LogLevel warn
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %{REMOTE_USER}i %l %u %t \"%r\" %>s %b" common
CustomLog "${:access_log}" common
ScriptSock "${:cgid-sock}"
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
# Directory protection
<Directory />
......@@ -50,9 +52,6 @@ WSGIScriptAlias / ${:wsgi_location}/trac.wsgi
</LimitExcept>
</Location>
ScriptSock "${:cgid-sock}"
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
Alias "/static/" "${:gitweb-static-dir}"
<Directory "${:gitweb-static-dir}">
Options FollowSymLinks
......
import sys
sys.stdout = sys.stderr
#!${:python_bin}
# -*- coding: utf-8 -*-
import os
os.environ['TRAC_ENV'] = '${:htdocs}'
os.environ['PYTHON_EGG_CACHE'] = '${:htdocs}/eggs'
import trac.web.main
application = trac.web.main.dispatch_request
\ No newline at end of file
def application(environ, start_request):
if not 'trac.env_parent_dir' in environ:
environ.setdefault('trac.env_path', '${:trac_env}')
if 'PYTHON_EGG_CACHE' in environ:
os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
elif 'trac.env_path' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_path'], '.egg-cache')
elif 'trac.env_parent_dir' in environ:
os.environ['PYTHON_EGG_CACHE'] = \
os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
from trac.web.main import dispatch_request
return dispatch_request(environ, start_request)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment