I'm new to Trac and I've been experiementing a little bit with it.
Recently, I've been trying to get the mod_python support working.
I have it mostly working but I'm seeing a problem with the way that
ModPythonHandler.py is parsing the URL. Here's what I see:
URL: http://localhost/projects/
Result: correct
Description: displays the index of projects
URL: http://localhost/projects/example
Result: correct
Description: displays the WikiStart page of the example project
URL: http://localhost/projects/example/wiki/TracGuide
Result: incorrect - wrong output
Description: displays the index of projects
URL: http://localhost/projects/example/example
Result: incorrect - invalid URL
Description: displays the WikiStart page of the example project
URL: http://localhost/projects/example/example/wiki/TracGuide
Result: incorrect - wrong URL
Description: displays the TracGuide page
I've configured my Trac server following as described in my notes
that I've attached.
I realize that mod_python support is still experiemental but I was
wondering if this behavior is a known problem or if I've misconfigured
somthing.
Thanks.
--
Tim Moloney
ManTech Real-time Systems Laboratory
2015 Cattlemen Road \ /
Sarasota, FL 34232 .________\(O)/________.
(941) 377-6775 x208 ' ' O(.)O ' '
-------------- next part --------------
Installing And Configuring A Trac Server
==========================================
Base Operating System
-----------------------
- Install Fedora Core 2 (everything for now, will be trimmed down later)
- Update the following RPMs:
- subversion, subversion-devel, subversion-perl, mod_dav_svn to 1.0.4-1
- neon, neon-devel to 0.24.5
Configuring Subversion
------------------------
mkdir /var/svn
chown -R apache.apache /var/svn
cat >> /etc/httpd/conf.d/subversion.conf <<EOF
<Location /var/svn>
DAV svn
SVNParentPath /var/svn
</Location>
# TODO: Add user authentication here.
EOF
service httpd restart
Installing SQLite
-------------------
wget http://www.sqlite.org/sqlite-2.8.14-1.i386.rpm
wget http://www.sqlite.org/sqlite-devel-2.8.14-1.i386.rpm
sudo rpm -Uvh sqlite*
sudo chmod 755 /usr/lib/python2.3/site-packages/_sqlite.so
Installing PySQLite
---------------------
wget http://unc.dl.sourceforge.net/pysqlite/pysqlite-0.5.0.tar.gz
tar zxvf pysqlite-0.5.0.tar.gz
cd pysqlite
python setup.py build
sudo python setup.py install
cd ..
\rm -rf pysqlite
Installing ClearSilver
------------------------
wget http://www.clearsilver.net/downloads/clearsilver-0.9.10.tar.gz
tar zxvf clearliver-0.9.10.tar.gz
cd clearsilver-0.9.10
make
mv scripts/document.py scripts/document.py.orig
sed -e '1s%/local%%' < scripts/document.py.orig > scripts/document.py
chmod 750 scripts/document.py
sudo make install
cd ..
\rm -rf clearsilver-0.9.10
Installing Trac
-----------------
wget http://ftp.edgewall.com/pub/trac/trac-0.7.1.tar.gz
tar zxvf trac-0.7.1.tar.gz
cd trac-0.7.1
python setup.py build
sudo python setup.py install
cd ..
\rm -rf trac-0.7.1
Configuring Trac (using separate python processes)
----------------------------------------------------
mkdir /var/lib/trac
chown -R apache.apache /var/lib/trac
mkdir /var/www/html/projects
cp /usr/share/trac/cgi-bin/trac.cgi /var/www/html/projects
cat > /var/www/html/projects/index.cgi <<EOF
#!/usr/bin/python
import os
#
# Configuration
#
title = 'Trac Projects'
project_dir = '/var/lib/trac'
project_dir_url = '/projects'
#
# Send the HTTP headers.
#
print 'Content-Type: text/html\r\n\r\n',
#
# Send the static part of the web page.
#
print '<html>'
print ' <head>'
print ' <title>%s</title>' % title
print ' </head>'
print ' <body>'
print ' <h2>%s</h2>' % title
print ' <ul>'
#
# Send the dynamic part of the web page.
#
for file in os.listdir(project_dir):
if (os.path.isdir(os.path.join(project_dir, file))):
print ' <li><a href="%s/%s">%s</a></li>' % \
(project_dir_url, file, file)
else:
print file
#
# Close everything.
#
print ' </ul>'
print ' </body>'
print '</html>'
EOF
chmod 755 /var/www/html/projects/index.cgi
chown -R apache.apache /var/www/html/projects
cat >> /etc/httpd/conf/httpd.conf <<EOF
#
# Trac
#
Alias /trac/ "/usr/share/trac/htdocs/"
<Directory "/usr/share/trac/htdocs/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteRule ^/projects/+$ /projects/index.cgi [L]
RewriteCond /var/lib/trac/$1 -d
RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:/var/lib/trac/$1]
RewriteRule ^/projects/(.*) /projects/index.cgi
<Directory "/var/www/html/projects">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .cgi
Order allow,deny
Allow from all
</Directory>
<LocationMatch "/projects/[[:alnum:]]+/login">
AuthType Basic
AuthName "trac"
AuthUserFile /path/to/trac.htpasswd
Require valid-user
</LocationMatch>
EOF
service httpd restart
Creating A Trac Project (using separate python processes)
-----------------------------------------------------------
PROJ=<project>
svnadmin create /var/svn/${PROJ}
chown -R apache.apache /var/svn/${PROJ}
trac-admin /var/lib/trac/${PROJ} initenv <<EOF
${PROJ}
/var/svn/${PROJ}
EOF
chown -R apache.apache /var/lib/trac/${PROJ}
Configuring Trac (using mod_python)
-------------------------------------
mv /usr/share/trac/wiki-default/WikiStart /usr/share/trac/wiki-default/TracStart
cat >> /usr/share/trac/wiki-default/WikiStart <<EOF
= WikiStart Placeholder =
This placeholder page is the default page for your new project.
Your project is being administered by [http://trac.edgewall.com/ Trac].
TracStart provides more information about Trac.
EOF
mkdir /var/www/projects
chown -R apache.apache /var/www/projects
cat >> /etc/httpd/conf/httpd.conf <<EOF
#
# Trac
#
Alias /trac/ "/usr/share/trac/htdocs/"
<Directory "/usr/share/trac/htdocs/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<LocationMatch /projects>
SetHandler mod_python
PythonHandler trac.ModPythonHandler
PythonOption TracEnvParentDir "/var/www/projects"
</LocationMatch>
# TODO: Add user authentication here.
EOF
service httpd restart
Creating A Trac Project (using mod_python)
--------------------------------------------
PROJ=<project>
svnadmin create /var/svn/${PROJ}
chown -R apache.apache /var/svn/${PROJ}
trac-admin /var/www/projects/${PROJ} initenv <<EOF
${PROJ}
/var/svn/${PROJ}
EOF
chown -R apache.apache /var/www/projects/${PROJ}
Recently, I've been trying to get the mod_python support working.
I have it mostly working but I'm seeing a problem with the way that
ModPythonHandler.py is parsing the URL. Here's what I see:
URL: http://localhost/projects/
Result: correct
Description: displays the index of projects
URL: http://localhost/projects/example
Result: correct
Description: displays the WikiStart page of the example project
URL: http://localhost/projects/example/wiki/TracGuide
Result: incorrect - wrong output
Description: displays the index of projects
URL: http://localhost/projects/example/example
Result: incorrect - invalid URL
Description: displays the WikiStart page of the example project
URL: http://localhost/projects/example/example/wiki/TracGuide
Result: incorrect - wrong URL
Description: displays the TracGuide page
I've configured my Trac server following as described in my notes
that I've attached.
I realize that mod_python support is still experiemental but I was
wondering if this behavior is a known problem or if I've misconfigured
somthing.
Thanks.
--
Tim Moloney
ManTech Real-time Systems Laboratory
2015 Cattlemen Road \ /
Sarasota, FL 34232 .________\(O)/________.
(941) 377-6775 x208 ' ' O(.)O ' '
-------------- next part --------------
Installing And Configuring A Trac Server
==========================================
Base Operating System
-----------------------
- Install Fedora Core 2 (everything for now, will be trimmed down later)
- Update the following RPMs:
- subversion, subversion-devel, subversion-perl, mod_dav_svn to 1.0.4-1
- neon, neon-devel to 0.24.5
Configuring Subversion
------------------------
mkdir /var/svn
chown -R apache.apache /var/svn
cat >> /etc/httpd/conf.d/subversion.conf <<EOF
<Location /var/svn>
DAV svn
SVNParentPath /var/svn
</Location>
# TODO: Add user authentication here.
EOF
service httpd restart
Installing SQLite
-------------------
wget http://www.sqlite.org/sqlite-2.8.14-1.i386.rpm
wget http://www.sqlite.org/sqlite-devel-2.8.14-1.i386.rpm
sudo rpm -Uvh sqlite*
sudo chmod 755 /usr/lib/python2.3/site-packages/_sqlite.so
Installing PySQLite
---------------------
wget http://unc.dl.sourceforge.net/pysqlite/pysqlite-0.5.0.tar.gz
tar zxvf pysqlite-0.5.0.tar.gz
cd pysqlite
python setup.py build
sudo python setup.py install
cd ..
\rm -rf pysqlite
Installing ClearSilver
------------------------
wget http://www.clearsilver.net/downloads/clearsilver-0.9.10.tar.gz
tar zxvf clearliver-0.9.10.tar.gz
cd clearsilver-0.9.10
make
mv scripts/document.py scripts/document.py.orig
sed -e '1s%/local%%' < scripts/document.py.orig > scripts/document.py
chmod 750 scripts/document.py
sudo make install
cd ..
\rm -rf clearsilver-0.9.10
Installing Trac
-----------------
wget http://ftp.edgewall.com/pub/trac/trac-0.7.1.tar.gz
tar zxvf trac-0.7.1.tar.gz
cd trac-0.7.1
python setup.py build
sudo python setup.py install
cd ..
\rm -rf trac-0.7.1
Configuring Trac (using separate python processes)
----------------------------------------------------
mkdir /var/lib/trac
chown -R apache.apache /var/lib/trac
mkdir /var/www/html/projects
cp /usr/share/trac/cgi-bin/trac.cgi /var/www/html/projects
cat > /var/www/html/projects/index.cgi <<EOF
#!/usr/bin/python
import os
#
# Configuration
#
title = 'Trac Projects'
project_dir = '/var/lib/trac'
project_dir_url = '/projects'
#
# Send the HTTP headers.
#
print 'Content-Type: text/html\r\n\r\n',
#
# Send the static part of the web page.
#
print '<html>'
print ' <head>'
print ' <title>%s</title>' % title
print ' </head>'
print ' <body>'
print ' <h2>%s</h2>' % title
print ' <ul>'
#
# Send the dynamic part of the web page.
#
for file in os.listdir(project_dir):
if (os.path.isdir(os.path.join(project_dir, file))):
print ' <li><a href="%s/%s">%s</a></li>' % \
(project_dir_url, file, file)
else:
print file
#
# Close everything.
#
print ' </ul>'
print ' </body>'
print '</html>'
EOF
chmod 755 /var/www/html/projects/index.cgi
chown -R apache.apache /var/www/html/projects
cat >> /etc/httpd/conf/httpd.conf <<EOF
#
# Trac
#
Alias /trac/ "/usr/share/trac/htdocs/"
<Directory "/usr/share/trac/htdocs/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteRule ^/projects/+$ /projects/index.cgi [L]
RewriteCond /var/lib/trac/$1 -d
RewriteRule ^/projects/([[:alnum:]]+)(/?.*) /projects/trac.cgi$2 [S=1,E=TRAC_ENV:/var/lib/trac/$1]
RewriteRule ^/projects/(.*) /projects/index.cgi
<Directory "/var/www/html/projects">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .cgi
Order allow,deny
Allow from all
</Directory>
<LocationMatch "/projects/[[:alnum:]]+/login">
AuthType Basic
AuthName "trac"
AuthUserFile /path/to/trac.htpasswd
Require valid-user
</LocationMatch>
EOF
service httpd restart
Creating A Trac Project (using separate python processes)
-----------------------------------------------------------
PROJ=<project>
svnadmin create /var/svn/${PROJ}
chown -R apache.apache /var/svn/${PROJ}
trac-admin /var/lib/trac/${PROJ} initenv <<EOF
${PROJ}
/var/svn/${PROJ}
EOF
chown -R apache.apache /var/lib/trac/${PROJ}
Configuring Trac (using mod_python)
-------------------------------------
mv /usr/share/trac/wiki-default/WikiStart /usr/share/trac/wiki-default/TracStart
cat >> /usr/share/trac/wiki-default/WikiStart <<EOF
= WikiStart Placeholder =
This placeholder page is the default page for your new project.
Your project is being administered by [http://trac.edgewall.com/ Trac].
TracStart provides more information about Trac.
EOF
mkdir /var/www/projects
chown -R apache.apache /var/www/projects
cat >> /etc/httpd/conf/httpd.conf <<EOF
#
# Trac
#
Alias /trac/ "/usr/share/trac/htdocs/"
<Directory "/usr/share/trac/htdocs/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<LocationMatch /projects>
SetHandler mod_python
PythonHandler trac.ModPythonHandler
PythonOption TracEnvParentDir "/var/www/projects"
</LocationMatch>
# TODO: Add user authentication here.
EOF
service httpd restart
Creating A Trac Project (using mod_python)
--------------------------------------------
PROJ=<project>
svnadmin create /var/svn/${PROJ}
chown -R apache.apache /var/svn/${PROJ}
trac-admin /var/www/projects/${PROJ} initenv <<EOF
${PROJ}
/var/svn/${PROJ}
EOF
chown -R apache.apache /var/www/projects/${PROJ}