Mailing List Archive

ModPythonHander.py incorrectly parsing URLs?
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}
ModPythonHander.py incorrectly parsing URLs? [ In reply to ]
Tim Moloney wrote:

> 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.
>
Hi Tim,

Yes, this is a known problem. It seems like apache sometimes get
confused and fail to calculate req.path_info correctly.

In your case path_info should be something like:
"/<projname>/<otherstuff>"
But due to apache/mod_python limitations it will sometimes get:
"/projects/<projname>/..." or just "/<otherstuff>".

This is why Trac sometimes display the project index instead of the real
page.

http://mail.mems-exchange.org/pipermail/quixote-users/2004-May/002934.html
http://mail.mems-exchange.org/pipermail/quixote-users/2004-May/002940.html

The thread above explain in more detail why it isn't possible to
correctly calculate path_info without parsing the apache configuration.

The fastest and simplest solution for us is probably to add a new
config option that the mod_python front-end could use to calculate
path_info correctly.

I created ticket #552 about this issue.
http://projects.edgewall.com/trac/ticket/552

/ Jonas
--
Jonas Borgstr?m | Edgewall Software
jonas@edgewall.com | Professional GNU/Linux & Open Source Consulting.
| http://www.edgewall.com/
ModPythonHander.py incorrectly parsing URLs? [ In reply to ]
Daragh Fitzpatrick wrote:

> it would be fantastic if you could put your final notes up on the
> Trac Wiki:
> http://projects.edgewall.com/trac/wiki/TracOnFedoraCore
>
> Many thanks in advance.

By the end of next week, I hope to have both manual instructions
and a kickstart file that will install and configure a Trac server.

--
Tim Moloney
ManTech Real-time Systems Laboratory
2015 Cattlemen Road \ /
Sarasota, FL 34232 .________\(O)/________.
(941) 377-6775 x208 ' ' O(.)O ' '
ModPythonHander.py incorrectly parsing URLs? [ In reply to ]
Hi Tim,

it would be fantastic if you could put your final notes up on the
Trac Wiki:
http://projects.edgewall.com/trac/wiki/TracOnFedoraCore

Many thanks in advance.

Cheers,

:D

--------------------------------------------------------------------
Daragh Fitzpatrick Daragh@UChicago.edu (773) 702-8976

Solutions Architect NSIT Administrative Systems
Renewal Projects and Architecture University of Chicago
--------------------------------------------------------------------

-----Original Message-----
From: trac-bounces@bobcat.edgewall.com
[mailto:trac-bounces@bobcat.edgewall.com] On Behalf Of Jonas Borgstr?m
Sent: Tuesday, June 15, 2004 11:52 AM
To: moloney@mrsl.com
Cc: trac@bobcat.edgewall.com
Subject: Re: [Trac] ModPythonHander.py incorrectly parsing URLs?

Tim Moloney wrote:

> 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:

[snip!]