<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: TurboGears 2 (TG2) with mod_wsgi and virtual environments</title>
	<atom:link href="http://getmediacore.com/blog/turbogears-2-tg2-with-mod_wsgi-and-virtual-environments/feed/" rel="self" type="application/rss+xml" />
	<link>http://getmediacore.com/blog/turbogears-2-tg2-with-mod_wsgi-and-virtual-environments/</link>
	<description></description>
	<lastBuildDate>Thu, 26 Aug 2010 19:36:34 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Graham Dumpleton</title>
		<link>http://getmediacore.com/blog/turbogears-2-tg2-with-mod_wsgi-and-virtual-environments/comment-page-1/#comment-24</link>
		<dc:creator>Graham Dumpleton</dc:creator>
		<pubDate>Thu, 14 May 2009 02:27:05 +0000</pubDate>
		<guid isPermaLink="false">http://getmediacore.com/blog/?p=103#comment-24</guid>
		<description>One more thing.

Use of site.addsitedir() has ordering issues for directories. So long as using mod_wsgi 2.4 or later, you are better off using &#039;python-path&#039; option for WSGIDaemonProcess and daemon mode, or WSGIPythonPath if using embedded mode. These will correctly reorder to the path to ensure virtual environment stuff comes before same packages installed in system wide Python site-packages directory. The ordering issues are mentioned in:

  http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

Which reminds me I need to update it to say the directive ways of doing it now fixup order as of mod_wsgi 2.4. That document describes some Python code to do reordering if doing it from WSGI script file and the ordering becomes an issue.</description>
		<content:encoded><![CDATA[<p>One more thing.</p>
<p>Use of site.addsitedir() has ordering issues for directories. So long as using mod_wsgi 2.4 or later, you are better off using &#8216;python-path&#8217; option for WSGIDaemonProcess and daemon mode, or WSGIPythonPath if using embedded mode. These will correctly reorder to the path to ensure virtual environment stuff comes before same packages installed in system wide Python site-packages directory. The ordering issues are mentioned in:</p>
<p>  <a href="http://code.google.com/p/modwsgi/wiki/VirtualEnvironments" rel="nofollow">http://code.google.com/p/modwsgi/wiki/VirtualEnvironments</a></p>
<p>Which reminds me I need to update it to say the directive ways of doing it now fixup order as of mod_wsgi 2.4. That document describes some Python code to do reordering if doing it from WSGI script file and the ordering becomes an issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham Dumpleton</title>
		<link>http://getmediacore.com/blog/turbogears-2-tg2-with-mod_wsgi-and-virtual-environments/comment-page-1/#comment-23</link>
		<dc:creator>Graham Dumpleton</dc:creator>
		<pubDate>Thu, 14 May 2009 02:14:42 +0000</pubDate>
		<guid isPermaLink="false">http://getmediacore.com/blog/?p=103#comment-23</guid>
		<description>The error &quot;Invalid command &#039;WSGIDaemonProcess&#039;, perhaps misspelled or defined by a module not included in the server configuration&quot;, would occur for mod_wsgi on Windows or if using Apache 1.3, as daemon mode not supported in those cases. In odd cases where Apache Runtime Library not compiled with thread support, would also not be available either. APR is still sometimes not compiled with thread support on BSD systems for some reason.

In respect of gotcha 1, the libexpat problem is not an issue for Python &gt;= 2.5. This is because pyexpat properly namespace prefixes its own version, so should be in conflict.

In respect of gotcha 3, this can be more than an permissions problem. For mod_wsgi embedded mode the PYTHON_EGG_CACHE may be calculated as a stupid value based on root home directory. In that case may be necessary to use WSGIPythonEggs directive to set alternate location in Apache configuration for embedded mode. One can also use &#039;python-eggs&#039; option to WSGIDaemonProcess to override the location. In both cases, as you do, you can also just set PYTHON_EGG_CACHE in os.environ in the WSGI script file. This only solves the location issue. As you point out, that new location still has to be writable by Apache user if running embedded mode and user that daemon process runs as, default is still Apache user, if running daemon mode.

If you run daemon mode as a specific user, then by default will correctly use location in home directory of that user, if you don&#039;t set it, and if that is yourself will be able to write it properly. Thus, if you have no concerns about it, often easier just to setup daemon process to run as yourself. If doing that, the directories down to the location of the WSGI script file still have to be readable/search to Apache user, but the WSGI script file itself and all your Python code doesn&#039;t need to be and only needs to be accessible to you. This is useful if on a shared system and don&#039;t want to make it any easier for other users to see your code.</description>
		<content:encoded><![CDATA[<p>The error &#8220;Invalid command &#8216;WSGIDaemonProcess&#8217;, perhaps misspelled or defined by a module not included in the server configuration&#8221;, would occur for mod_wsgi on Windows or if using Apache 1.3, as daemon mode not supported in those cases. In odd cases where Apache Runtime Library not compiled with thread support, would also not be available either. APR is still sometimes not compiled with thread support on BSD systems for some reason.</p>
<p>In respect of gotcha 1, the libexpat problem is not an issue for Python &gt;= 2.5. This is because pyexpat properly namespace prefixes its own version, so should be in conflict.</p>
<p>In respect of gotcha 3, this can be more than an permissions problem. For mod_wsgi embedded mode the PYTHON_EGG_CACHE may be calculated as a stupid value based on root home directory. In that case may be necessary to use WSGIPythonEggs directive to set alternate location in Apache configuration for embedded mode. One can also use &#8216;python-eggs&#8217; option to WSGIDaemonProcess to override the location. In both cases, as you do, you can also just set PYTHON_EGG_CACHE in os.environ in the WSGI script file. This only solves the location issue. As you point out, that new location still has to be writable by Apache user if running embedded mode and user that daemon process runs as, default is still Apache user, if running daemon mode.</p>
<p>If you run daemon mode as a specific user, then by default will correctly use location in home directory of that user, if you don&#8217;t set it, and if that is yourself will be able to write it properly. Thus, if you have no concerns about it, often easier just to setup daemon process to run as yourself. If doing that, the directories down to the location of the WSGI script file still have to be readable/search to Apache user, but the WSGI script file itself and all your Python code doesn&#8217;t need to be and only needs to be accessible to you. This is useful if on a shared system and don&#8217;t want to make it any easier for other users to see your code.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
