tracd --port 8000 -r --group=www-data --user=www-data /var/wiki/funambulus_trac
Alias /funambulus/chrome/common /var/wiki/funambulus_trac/www/htdocs/common
Alias /funambulus/chrome/site /var/wiki/funambulus_trac/www/htdocs/site
<Directory "/var/wiki/funambulus_trac/www/htdocs">
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
WSGIScriptAlias /funambulus /var/wiki/funambulus_trac/www/cgi-bin/trac.wsgi
<Directory /var/wiki/funambulus_trac/www/cgi-bin>
Options -Indexes -MultiViews -SymLinksIfOwnerMatch
AllowOverride All
WSGIApplicationGroup %{GLOBAL}
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
import os
def application(environ, start_request):
if not 'trac.env_parent_dir' in environ:
environ.setdefault('trac.env_path', '/var/wiki/funambulus_trac')
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)
I've added TRAC_ADMIN temporarily to anonymous role to help with debugging, in case someone wants to take a look.
Does anyone have pointers as to where to start looking to resolve this? I've not done much web development with Python / WSGI, but since everything seems to be working fine without WSGI - I could use some pointers.
Thanks,
Vijay Varadan
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:py="http://genshi.edgewall.org/"
xmlns:i18n="http://genshi.edgewall.org/i18n"
py:strip="">
From: RjOllos <rjo...@gmail.com>
To: Trac Users <trac-...@googlegroups.com>
Sent: Saturday, February 13, 2016 10:43 AM
Subject: [Trac] Re: Missing header and footer when running with WSGI
environ.setdefault('trac.env_ path', '/var/wiki/funambulus_trac')
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)
When I access trac through WSGI, the header and footer are missing everywhere. The site seems to work fine otherwise.I've added TRAC_ADMIN temporarily to anonymous role to help with debugging, in case someone wants to take a look.Does anyone have pointers as to where to start looking to resolve this? I've not done much web development with Python / WSGI, but since everything seems to be working fine without WSGI - I could use some pointers.Thanks,Vijay Varadan
I'm unsure what the issue it, but I can reproduce by putting a file name theme.html in $env/templates, with the following content:<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<html xmlns="http://www.w3.org/1999/xhtml"xmlns:xi="http://www.w3.org/2001/XInclude"xmlns:py="http://genshi.edgewall.org/"xmlns:i18n="http://genshi.edgewall.org/i18n"py:strip=""></html>Continuing to investigate ...- Ryan
--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.
From: 'Dick Martin Shorter' via Trac Users <trac-...@googlegroups.com>
To: "trac-...@googlegroups.com" <trac-...@googlegroups.com>
Sent: Saturday, February 13, 2016 11:12 AM
Subject: Re: [Trac] Re: Missing header and footer when running with WSGI
From: Vijay Varadan
Sent: Saturday, February 13, 1:35 PM
Subject: [Trac] Re: Missing header and footer when running with WSGI
To: Trac Users
Hey Ryan,
I added the WSGIDaemonProcess line, modifying the python-path to work for my system. It looks like this:
WSGIDaemonProcess funambulus python-path=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages maximum-requests=1000 processes=2 threads=25 inactivity-timeout=120
I left the port at default.
But, it's still the same. No header or footer
Good point about the python path needing to be changed. Did you try to use the virtualhost configuration I provided, or did you just edit yours? I don't know what might be wrong with your virtualhost configuration, but the one I provided at least has been tested.
Make sure you have nothing in your environment templates directory.
<VirtualHost vijay.tech:8080>
ServerName vijay.tech
ServerAlias www.vijay.tech
DocumentRoot /var/www/tech/vijay/www/public_html
Options -Indexes -MultiViews
<Directory "/var/www/tech/vijay/www/public_html/">
Options -Indexes -MultiViews +SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Alias /funambulus/chrome/common /var/wiki/funambulus_trac/www/htdocs/common
Alias /funambulus/chrome/site /var/wiki/funambulus_trac/www/htdocs/site
<Directory "/var/wiki/funambulus_trac/www/htdocs">
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
WSGIDaemonProcess funambulus8080 python-path=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages maximum-requests=1000 processes=2 threads=25 inactivity-timeout=120
WSGIScriptAlias /funambulus /var/wiki/funambulus_trac/www/cgi-bin/trac.wsgi
<Directory /var/wiki/funambulus_trac/www/cgi-bin>
Options -Indexes -MultiViews -SymLinksIfOwnerMatch
AllowOverride All
WSGIApplicationGroup %{GLOBAL}
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
I'm also unsure of the consequences of defining WSGIDaemonProcess within the VirtualHost and omitting WSGIProcessGroup. Maybe it's fine.
WSGIDaemonProcess funambulus8080 python-path=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages maximum-requests=1000 processes=2 threads=25 inactivity-timeout=120
<VirtualHost vijay.tech:8080>
ServerName vijay.tech
ServerAlias www.vijay.tech
DocumentRoot /var/www/tech/vijay/www/public_html
Options -Indexes -MultiViews
WSGIScriptAlias /funambulus /var/wiki/funambulus_trac/www/cgi-bin/trac.wsgi
<Directory /var/wiki/funambulus_trac/www/cgi-bin>
WSGIProcessGroup funambulus8080
WSGIApplicationGroup %{GLOBAL}
# For Apache 2.4
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
I'm also unsure of the consequences of defining WSGIDaemonProcess within the VirtualHost and omitting WSGIProcessGroup. Maybe it's fine.
I've used it with Bloodhound instances and you can either define the WSGIDaemonProcess outside VirtualHost and use WSGIProcessGroup or you can directly use WSGIDaemonProcess within VirtualHost without the WSGIDaemonProcess WSGIProcessGroup directive.
--
You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/AQpVWTXVwsg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to trac-users+...@googlegroups.com.
I'm also unsure of the consequences of defining WSGIDaemonProcess within the VirtualHost and omitting WSGIProcessGroup. Maybe it's fine.
I've used it with Bloodhound instances and you can either define the WSGIDaemonProcess outside VirtualHost and use WSGIProcessGroup or you can directly use WSGIDaemonProcess within VirtualHost without the
WSGIDaemonProcessWSGIProcessGroup directive.
I did a fresh install of trac in the following environment:Ubuntu 14.04.3python 2.7.,6PostgreSQL 9.3.11psycopg2 2.6.1Genshi 0.7-3Babel 1.3setuptools 3.3
Hey Ryan,
Does "fresh install" mean that this is a new virtual machine that is guaranteed to have no other modifications other than the changes you've made in setting up Trac?
No, it’s an existing server where I primarily run Wordpress instances. But this is the first python/WSGI site I’m running.
That said, I spent the better part of today setting up a new virtual machine with the same configuration as the one that has missing headers & footers. Everything works fine on the new server.
I did directory comparisons of trac and genshi between the two machines to ensure nothing was messed up. Things match exactly, including ownership and permissions. I tried debugging and single stepping through the code using “import pid; pid.set_trace()”, but that only resulted in a BdbQuit error [ sorry I’ve never done python web debugging before ].
I guess it’s not an issue with Trac / Genshi, so much as it is with that specific server. I’m not sure how to debug this. If you have any pointers, I’d appreciate it.
Thanks.
-Vijay
From: trac-...@googlegroups.com [mailto:trac-...@googlegroups.com] On Behalf Of RjOllos
Sent: Monday, February 15, 2016 1:53 AM
To: Trac Users <trac-...@googlegroups.com>
Subject: [Trac] Re: Missing header and footer when running with WSGI
--
Hey Ryan,
I checked the VirtualHost config using apache2ctl -S as you suggested. Things look normal.
Thanks,
-Vijay
From: trac-...@googlegroups.com [mailto:trac-...@googlegroups.com] On Behalf Of RjOllos
Sent: Monday, February 15, 2016 1:21 AM
To: Trac Users <trac-...@googlegroups.com>
--
Hey Ryan,
Does "fresh install" mean that this is a new virtual machine that is guaranteed to have no other modifications other than the changes you've made in setting up Trac?
No, it’s an existing server where I primarily run Wordpress instances. But this is the first python/WSGI site I’m running.
That said, I spent the better part of today setting up a new virtual machine with the same configuration as the one that has missing headers & footers. Everything works fine on the new server.
I did directory comparisons of trac and genshi between the two machines to ensure nothing was messed up. Things match exactly, including ownership and permissions. I tried debugging and single stepping through the code using “import pid; pid.set_trace()”, but that only resulted in a BdbQuit error [ sorry I’ve never done python web debugging before ].
I guess it’s not an issue with Trac / Genshi, so much as it is with that specific server. I’m not sure how to debug this. If you have any pointers, I’d appreciate it.
Thanks.
-Vijay
Hey Ryan,
Nailed it! :-D
The issue was with the wsgi.conf file in /etc/apache2/mods-enabled – WSGIPythonOptimize 2 was set on the server that rendered pages without headers / footers, but was WSGIPythonOptimize 0 on the 2 servers (including the new built-from-scratch virtual machine) where Genshi was working.
It looks like the Trac / Genshi has an issue with optimizations turned on. The comment for this setting indicates that this might be the case:
#WSGIPythonOptimize: Enables basic Python optimisation features.
#
#Sets the level of Python compiler optimisations. The default is '0'
#which means no optimisations are applied.
#Setting the optimisation level to '1' or above will have the effect
#of enabling basic Python optimisations and changes the filename
#extension for compiled (bytecode) files from .pyc to .pyo.
#When the optimisation level is set to '2', doc strings will not be
#generated and retained. This will result in a smaller memory footprint,
#but may cause some Python packages which interrogate doc strings in some
#way to fail.
I changed the setting to 0 and headers and footers began rendering once again.
Thanks for staying with me through this. Appreciate your patience a ton.
Should I edit the wiki and put in a note to indicate that when running Trac under WSGI, python optimizations should be turned off?
Cheers,
Vijay
From: trac-...@googlegroups.com [mailto:trac-...@googlegroups.com] On Behalf Of Ryan Ollos
Sent: Monday, February 15, 2016 3:16 AM
To: Trac Users <trac-...@googlegroups.com>
--
Hey Ryan,
Nailed it! :-D
The issue was with the wsgi.conf file in /etc/apache2/mods-enabled – WSGIPythonOptimize 2 was set on the server that rendered pages without headers / footers, but was WSGIPythonOptimize 0 on the 2 servers (including the new built-from-scratch virtual machine) where Genshi was working.
It looks like the Trac / Genshi has an issue with optimizations turned on. The comment for this setting indicates that this might be the case:
#WSGIPythonOptimize: Enables basic Python optimisation features.
#
#Sets the level of Python compiler optimisations. The default is '0'
#which means no optimisations are applied.
#Setting the optimisation level to '1' or above will have the effect
#of enabling basic Python optimisations and changes the filename
#extension for compiled (bytecode) files from .pyc to .pyo.
#When the optimisation level is set to '2', doc strings will not be
#generated and retained. This will result in a smaller memory footprint,
#but may cause some Python packages which interrogate doc strings in some
#way to fail.
I changed the setting to 0 and headers and footers began rendering once again.
Thanks for staying with me through this. Appreciate your patience a ton.
Should I edit the wiki and put in a note to indicate that when running Trac under WSGI, python optimizations should be turned off?
Cheers,
Vijay
Hey Ryan,
I'll add the information to the wiki in a bit.And to answer your question about WSGIPythonOptimize 1 - nope, I already tested it and it doesn't work either. The only value that works is 0.I feel I ought to file an issue to track this. That way someone can look into it and determine that it's not a bug and desired behavior - If it is not desired behavior, then it gets fixed, if so, then we have an entry in the system indicating that it's expected behavior. Your thoughts?Thanks,-Vijay
I've added the information to the TracModWSGI wiki page.Once again, thanks for everything.Cheers,Vijay Varadan
It would be interesting to see if we can retrieve the Python optimization level and log a warning. Perhaps it's possible to display the optimization level on the About Trac page. I might investigate further someday.- Ryan