<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mFabrik - mobile sites, apps, HTML5 and CMS software development &#187; php</title>
	<atom:link href="http://blog.mfabrik.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mfabrik.com</link>
	<description>Freedom delivered.</description>
	<lastBuildDate>Wed, 03 Aug 2011 09:47:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Making Plone easy again (and Sauna Sprint topics)</title>
		<link>http://blog.mfabrik.com/2011/06/08/making-plone-easy-again-and-sauna-sprint-topics/</link>
		<comments>http://blog.mfabrik.com/2011/06/08/making-plone-easy-again-and-sauna-sprint-topics/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 08:14:28 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sauna sprint]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1274</guid>
		<description><![CDATA[This blog post is about making Plone CMS to accessible for more developers. This is a major topic on which we are working on in Sauna Sprint 2011 (see the previous blog post about Sauna Sprint and motivation to come to Finland). Preface Please do not take this post too seriously if I am ranting [...]]]></description>
			<content:encoded><![CDATA[<p>This blog post is about making <a href="http://plone.org">Plone CMS</a> to accessible for more developers. This is a major topic on which we are working on in Sauna Sprint 2011 (<a href="http://blog.mfabrik.com/2011/06/08/sauna-sprint-2011-motivational-blog-post-%E8%9A%8A%E3%81%8C%E6%A5%BD%E3%81%97%E3%81%84%E3%81%A7%E3%81%99/">see the previous blog post about Sauna Sprint and motivation to come to Finland</a>).</p>
<h2>Preface</h2>
<p>Please do not take this post too seriously if I am ranting tongue-in-cheek. This thinking does not reflect the official opinion of Sauna Sprint team any way, it is just my personal rambling.</p>
<h2>Background</h2>
<p>Plone is having popularity issues. This can be deducted by:</p>
<ul>
<li>PHP CMS are more popular (Google trends and so on)</li>
<li><a href="http://amplicate.com/love/plone">Plone lacks love</a></li>
<li>By discussing with Python programmers outside Plone community: they see Plone as monster</li>
</ul>
<p>Plone is a superior CMS product (feature wise, polish wise, tech wise, and so on). So how did this happen?</p>
<p>My theory, you are free to disagree, is that the community has been driving &#8220;wrong&#8221; ideologies</p>
<ul>
<li>Plone&#8217;s &#8220;buyers&#8221; are not users, but developers</li>
<li>There has been no driving community factor to make Plone accessible for more developers. Plone community has been working to make Plone work for the existing community members, not new members. The consulting companies have been too busy to extract money from their existing big clients. It might even be that it&#8217;s the best interest of these companies to keep the barrier of entry high, as this way they protect the Plone business for themselves. Note that this strategy will fail in the point there is no longer Plone business.</li>
</ul>
<p>The big boys are telling that customers are abandoning Plone, because there are no developers. I know a lot of Plone developers, looking for more Plone work.  I&#8217;ll translate this that there are not enough affordable Plone developers entering the market.</p>
<p>I am also not buying arguments like</p>
<ul>
<li>&#8220;don&#8217;t compare apples to oranges (Django vs. Plone)&#8221;</li>
<li>&#8220;its history and evolved that way&#8221;</li>
<li>&#8220;big tool must be complex&#8221;</li>
</ul>
<h2>The result</h2>
<p>Plone is easy to use, but hard to develop. <strong>If you need to use code generators and boiler-plate in Python code, you are doing it wrong.</strong></p>
<p>Plone is a soup of different, non-mainstream, technologies. To be a Plonista you need master: Python (ok docs), Plone user mode (good docs),  Zope component architecture (some docs), ZCML (no useful docs), GenericSetup  (no docs), TAL (some docs), Archetypes (basically no docs), buildout  (aaaaaarghs) &#8230; You have too much to learn from material which does not exist. Today the material effectively does not exist if it&#8217;s not your first Google hit &#8211; I am against book.</p>
<p>New developers are not getting in. It is easier to duplicate basic Plone functionality in a hacky in-house Django CMS than customize Plone for your use case. Plone does not give any more added value to the new developers. There is no business motivation to adapt Plone as a technology platform in new ventures.</p>
<h2>The quest</h2>
<p>Let&#8217;s fix it, as I see the developer acceptance the most crucial challenge Plone community is facing if the community wants to survive.</p>
<p>What we can do here is</p>
<ul>
<li>Make Plone easier for developers</li>
<li>Make more, better, learning material available</li>
<li>Eliminate and protect against factors in Plone which hinder the goals of two above bullets (do not include new technologies or modules to core if they make developers sad)</li>
</ul>
<p>To accomplish this we can</p>
<ol>
<li>Promote &#8220;easy&#8221; technologies inside and outside Plone community (Dexterity over Archetypes, Grok over ZCML)</li>
<li>Making a standard workflow available for them (Django style tutorial that do 1, 2, 3 and you are a certified Plone developer)</li>
<li>Kill technologies which make the stack unnecessary complex and are not necessarily needed in newbie use cases (buildout, I am looking at you)</li>
<li>Replace old, badly documented and difficult solutions with easier ones  (could we actually replace TAL with something more popular?)</li>
</ol>
<h2>Operational plan</h2>
<p>Here are some concrete tasks what we could tackle in Sauna Sprint.</p>
<p>Make it easy department</p>
<ul>
<li>Plone auto-restart team: provide working and fast auto-restart á la Django or Tornado (hint: plone.reload doesn&#8217;t cut it &#8211; you need real restarts process-wise)</li>
<li>Default custom product team: ship Plone with a file-system based custom product skeleton, so that when you need to include your first custom Python module you don&#8217;t need to learn about buildout and paster first . You actually can copy-paste in Python code and it just works.</li>
<li>Through-the-web is happy again team: Make it possible to code and execute Python through-the-web so that it actually works.: a working replacement for RestrictedPython</li>
</ul>
<p>Fix user-wise broken things department</p>
<ul>
<li>Buildout team: make buildout more user friendly: spit out error messages which are actually useful, have newbie buildout tutorial from the developer perspective. Nothing bad should happen when buildout is run. Make buildout to confirm version updates, etc.</li>
<li>Anti-buildout team: how to install eggs without buildout. Why did we need the buildout in the first place?</li>
</ul>
<p>This is how you do it department</p>
<ul>
<li>Tutorial team: Make &#8220;gapless&#8221; hand-holding tutorial for creating your first view, form and content-type. Make it so that you do not need to look outside the tutorial or learn anything unnecessary (don&#8217;t make me think)</li>
<li>Picture team: draw big pictures of Plone architecture, how different parts are connected, so that new developers get hang on things easily</li>
<li>Document generator team: Integrate collective.developermanual with Sphinx tool that generate the reference  documentation from the source code: views, viewlets, templates, CSS classes, portlets, etc.</li>
</ul>
<p>Hasta la vista babe department</p>
<ul>
<li>Kill it with fire team: Hunt down all bad learning material and make it redirect to new learning material (no ExternalMethods, no Install.py, no plone_skins, etc.)</li>
<li>Nuke it from orbit team: I am not sure what this team could do, but I like the feeling of the name</li>
</ul>
<p>We hope that novice  developers attend the sprint. This way we can use you as guinea pigs and document the pain points on a road to become Plone developer. Don&#8217;t worry &#8211; we&#8217;ll inject you with proper medicine to numb the pain and forget bad memories.
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/06/08/making-plone-easy-again-and-sauna-sprint-topics/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Reducing MySQL memory usage on Ubuntu / Debian Linux</title>
		<link>http://blog.mfabrik.com/2011/03/31/reducing-mysql-memory-usage-on-ubuntu-debian-linux/</link>
		<comments>http://blog.mfabrik.com/2011/03/31/reducing-mysql-memory-usage-on-ubuntu-debian-linux/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 10:56:46 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[mtop]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[res]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[virt]]></category>
		<category><![CDATA[virtual memory]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1149</guid>
		<description><![CDATA[If you are running your services on a low end virtual hosting every byte of memory you can save is important. The memory is often the limiting factor of how many applications you can run on VPS: CPUs are shared, memory not, on the same physical host. Low-end VPS come with 512 MB memory or [...]]]></description>
			<content:encoded><![CDATA[<p>If you are running your services on a low end virtual hosting every byte of memory you can save is important. The memory is often the limiting factor of how many applications you can run on VPS: CPUs are shared, memory not, on the same physical host.</p>
<ul>
<li>Low-end VPS come with 512 MB memory or less</li>
<li>Front front-end server Apache / Nginx / Varnish takes &gt; 100 MB +  min. 20 MB for each child process</li>
<li>Memecached takes its toll</li>
<li>MySQL takes 200 &#8211; 400 MB</li>
<li>Each Python / PHP process takes at least 15 MB and you need parallel processes for paraller HTTP requests (FCGI, pre-fork, others&#8230; )</li>
<li>Operating system processes need some memory (SSH, cron, sendmail)</li>
</ul>
<p>As you can see it gets very crowded in 512 MB.</p>
<p>It&#8217;s especially troublesome since the memory is allocated lazily and the memory usage builds up slowly. In some point caches are no longer caches, but swapped to a disk &#8211; virtual memory usage grows beyond available RAM. To keep the server response, everything time critical should fit to RAM once and if the processes themselves don&#8217;t know how to release memory in this situation you need to tune a memory cap for them.</p>
<h2>MySQL memory consumption</h2>
<p>MySQL can be a greedy bastard what comes to memory consumption. Here on this server MySQL seems to take 417M virtual memory which seems to be little excessive for just running two WordPress instances and one Django / Python application:</p>
<pre>1310 mysql     20   0  417M 21100  2776 S  0.0  1.2  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/v</pre>
<p>After some tuning I was able to bring it down a bit</p>
<pre>3354 mysql     20   0  276m  19m 2848 S    0  1.2   3:41.19 mysqld</pre>
<p>A reduction of 130 MB, or 1/4 of the server total memory. Not bad.</p>
<p><a href="http://ubuntu-snippets.blogspot.com/2009/02/mtop-mysql-monitor.html">Use mtop to monitor running MySQL</a>, its querieries, etc. so you know what&#8217;s going on. As you can see this MySQL has very good cache rate meaning that basically it is keeping everything in memory. If the content of the sites is less than 10 MBytes total, 400 MB contains plenty of space to cache the content:</p>
<pre>load average: 0.05, 0.08, 0.16 mysqld 5.0.51a-3ubuntu5.8-log up 1 day(s), 19:47 hrs                                                             
2 threads: 1 running, 6 cached. Queries/slow: 187.1K/0 Cache Hit: 99.39%</pre>
<h2>What eats memory</h2>
<p>I am not an expert on MySQL, so I hope someone with more insight could post comments regarding how to tune MySQL for low memory situations and how it is expected to behave.</p>
<p>Some ideas I run through my head</p>
<ul>
<li>MySQL default cache settings are not too tight on Ubuntu/Debian, making it suitable for moderate loads, not low loads. If you don&#8217;t have much content, everything is just kept in memory (even if not needed)</li>
<li>MySQL uses round robin for connections and if there is 100 max connections it will allocate a thread stack for each connection (someone please confirm this &#8211; I found contracting infos).</li>
</ul>
<h2>Configuring MySQL</h2>
<p>Here are listed some methods how to reduce the memory usage. This is what I done on this little box</p>
<p>MySQL is mostly configured in <em>/etc/mysql/my.cnf</em> on Ubuntu / Debian.</p>
<ul>
<li>Let&#8217;s halve key_buffer from 16M to 8M. <a href="http://dev.mysql.com/doc/refman/5.0/en/myisam-key-cache.html">It is used by MyISAM table cache</a>.</li>
<li>Halve <a href="http://techgurulive.com/2010/10/20/query_cache_size-tuning-optimizing-my-cnf-file-for-mysql/">query_cache_size</a>. query_cache_size  = 8M. Also, decrease query_cache_limit to 512 K.</li>
<li><a href="http://www.mysqlperformanceblog.com/2006/05/17/mysql-server-memory-usage/">Each connection, even if idle, will have 256 KB buffer</a>. Decrease the number of max. connections. (XXX: not sure about this). Drop max connections from 100 -&gt; 30, as we do not have that many concurrent visitors on the site. Also, set less aggressive thread_stack size.</li>
</ul>
<p>The final adjustments</p>
<pre>key_buffer              = 8M
max_connections         = 30
query_cache_size        = 8M
query_cache_limit       = 512K
thread_stack            = 128K</pre>
<h2>More info</h2>
<ul>
<li><a href="http://www.zimbio.com/Linux/articles/692/Fine+Tuning+MYSQL+Reducing+Memory+Usage">Fine-tuning MySQL</a></li>
<li><a href="http://www.electrictoolbox.com/mysql-table-storage-engine/">Showing what database engine MySQL tables are using</a></li>
<li><a href="http://www.mysqlperformanceblog.com/2006/05/17/mysql-server-memory-usage/">MySQL server memory usage</a></li>
<li><a href="http://www.lowendbox.com/blog/reducing-mysql-memory-usage-for-low-end-boxes/">Reducing MySQL memory usage for low end boxes</a></li>
</ul>
<p>Send in more tips please! Is 32-bit better than 64-bit for low end VPS, how much this affects MySQL?
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/31/reducing-mysql-memory-usage-on-ubuntu-debian-linux/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Copy/move phpBB3 forum from a server to another computer (Ubuntu/Linux)</title>
		<link>http://blog.mfabrik.com/2011/03/30/copymove-phpbb3-forum-from-a-server-to-another-computer-ubuntulinux/</link>
		<comments>http://blog.mfabrik.com/2011/03/30/copymove-phpbb3-forum-from-a-server-to-another-computer-ubuntulinux/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 13:40:11 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2ctl]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[move]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[phpbb]]></category>
		<category><![CDATA[phpbb3]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1179</guid>
		<description><![CDATA[Here are short instructions what you need to do in order to move / copy phpBB3 forum. Prerequisites What you need in order to benefit from these instructions Basic UNIX command-line knowledge SSH access to the server MySQL access to the database LAMP stack ready on the new server These instructions have been tested on [...]]]></description>
			<content:encoded><![CDATA[<p>Here are short instructions what you need to do in order to move / copy phpBB3 forum.</p>
<h2>Prerequisites</h2>
<p>What you need in order to benefit from these instructions</p>
<ul>
<li>Basic UNIX command-line knowledge</li>
<li>SSH access to the server</li>
<li>MySQL access to the database</li>
<li>LAMP stack ready on the new server</li>
</ul>
<p>These instructions have been tested on Ubuntu/Debian/Linux but they should work in other environments too.</p>
<h2>Write down database access information</h2>
<p>Get password from config.php file on the old server:</p>
<pre>cd /var/www/phpBB3
cat config.php</pre>
<p>Write down database name, username and password.</p>
<h2>Copy files</h2>
<p>Use rsync to remotely copy forum files to a new computer. On new computer, in /var/www folder</p>
<pre>rsync -av --compress-level=9 user@oldserver.com:/var/www/phpBB3 .</pre>
<h2>Dump and copy database</h2>
<p>Execute the following command on the new server. It takes SSH connection to the old server and dumps phpBB3 database to the new server over the SSH connection.</p>
<pre>ssh user@oldserver.com -C -o CompressionLevel=9 mysqldump -u databaseuser --password=databasepassword --skip-lock-tables --add-drop-table databasename &gt; phpbb3.sql</pre>
<h2>Create a new database</h2>
<p>Use the old access information from config.php to create a database with identical access information on the new server. You need a MySQL root access to create new databases.</p>
<pre>mysql -uroot -p</pre>
<p>Create database and grant access to phpBB3 user for it.</p>
<pre>mysql&gt; create database databasename;</pre>
<pre>mysql&gt; GRANT ALL ON databasename.* TO 'databaseuser'@'localhost' identified by 'databasepassword';</pre>
<p>Load the database on the new server from the dump file:</p>
<pre>mysql&gt; connect databasename;</pre>
<pre>mysql&gt; source phpbb3.sql</pre>
<h2>Configure Apache virtualhost for the new server</h2>
<p>The last step is to set-up Apache virtual host on the new server, so you can access the phpBB3 using a domain name. Note that this doesn&#8217;t need to be a real domain name, but you can spoof the domain name using /etc/hosts file on your local workstation.</p>
<p>Add file <em>/etc/apache2/sites-enabled/phpbb3.conf</em> (or pick a filename based on forum name if you host multiple forums)</p>
<pre>&lt;VirtualHost *&gt;
 ServerName yourdomainname.com

 DocumentRoot /var/www/phpBB3
 &lt;Directory /&gt;
   Options FollowSymLinks
   AllowOverride None
 &lt;/Directory&gt;

&lt;/VirtualHost&gt;</pre>
<p>Note that &lt;virtualhost *&gt; may change depending on how Apache has been set up to listen IP addresses and ports. Also if you are using a shared hosting package or VPS you might need to use the server control panel (cPanel) to do this step.</p>
<p>Then check if your new config file is ok and restart Apache:</p>
<pre>apache2ctl configtest
apache2ctl graceful</pre>
<h2>Hosts spoofing trick</h2>
<p>If you are not having a DNS server of your own which you can use for the copy you can always use <a href="http://webandmobile.mfabrik.com/docs/web-and-mobile/user-manual/installation#modifying-your-local-hosts-file">/etc/hosts file trick </a>to spoof domain names. This way you can make Apache to serve the forum from the server even if the forum is not connected to any real domain name yet.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/30/copymove-phpbb3-forum-from-a-server-to-another-computer-ubuntulinux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Python sucks: how you call a function and document it</title>
		<link>http://blog.mfabrik.com/2011/03/29/when-python-sucks-how-you-call-a-function-and-document-it/</link>
		<comments>http://blog.mfabrik.com/2011/03/29/when-python-sucks-how-you-call-a-function-and-document-it/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 09:11:38 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[epytext]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zope]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1175</guid>
		<description><![CDATA[Though maybe written tongue-in-cheek, this Python Makes Me Nervous article has some excellent points. Because of duck-typing, you should rigorously document how methods should be called (try epytext and its fields). Most open source Python projects do the exact opposite Even Python standard library is poorly documented and sets a very bad example (missing manual [...]]]></description>
			<content:encoded><![CDATA[<p>Though maybe written tongue-in-cheek, this <a href="http://teddziuba.com/2008/12/python-makes-me-nervous.html">Python Makes Me Nervous article</a> has some excellent points.</p>
<ul>
<li>Because of duck-typing, you should rigorously document how methods should be called (try <a href="http://epydoc.sourceforge.net/epytext.html">epytext</a> and its fields).</li>
<li>Most open source Python projects do the exact opposite</li>
<li>Even Python standard library is poorly documented and sets a very bad example (<a href="http://www.voidspace.org.uk/python/articles/urllib2.shtml">missing manual</a> ???)</li>
<li>Thus, programming in Python becomes nightmare of grepping through source code (the implementation) or stepping into it in pdb just to figure out how APIs should work (<a href="http://collective-docs.plone.org/security/permission_lists.html#listing-different-available-permissions">Plone/Zope,</a> anyone?)</li>
</ul>
<p>Should Python community stop in some point to focus on delivering better documentation instead of focusing on new features and goodies (like the syntax moratorium which was recently lifted)?</p>
<p>﻿﻿From my personal experience</p>
<ul>
<li>The best, and the only, person to document the code adequately is the person how originally wrote it</li>
<li>Because the author already knows how to use the code he doesn&#8217;t need to care about the fact how to enable the code for other users.  Many libraries and projects are driven by &#8220;scratching your own need&#8221; mentality, not by &#8220;let&#8217;s make this a happy community&#8221; mentality. The exception is something like Facebook or Google whose sole purpose is to attract new users their platform bringing in new €€€.</li>
<li>If you are developing a framework or community project make the documentation a requirement for deliverable and stick with it. If you let one person to skip one hour of writing documentation you are making 10 persons spending one hour figuring out how to use the damn thing.</li>
<li>Doctests are not documentation. They are tests. They are extremely unreadable way to say &#8220;how I should use this thing&#8221;, because doctests are often executed in the context of test stubs which do not reflect connections to the other parts of the framework or real contexts.</li>
<li>&#8220;Buy a book &#8211; it tells you everything&#8221; business model is not feasible in long run. Books get old. Books are not searchable. People don&#8217;t buy books.</li>
</ul>
<p>The good documentation is a way to differentiate, and win, in the situation where there are competing frameworks. I believe the success of Django was mostly driven by its good documentation.</p>
<p>This points could be applied to other duck-typed, open source driven programming languages (PHP anyone?). With good documentation we can reduce the need of Valium recipes for everyone of us.</p>
<p>&nbsp;
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/29/when-python-sucks-how-you-call-a-function-and-document-it/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Enable PHP log output (error_log) on XAMPP on OSX</title>
		<link>http://blog.mfabrik.com/2011/03/16/enable-php-log-output-error_log-on-xampp-on-osx/</link>
		<comments>http://blog.mfabrik.com/2011/03/16/enable-php-log-output-error_log-on-xampp-on-osx/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 21:29:18 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[error_log]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[tail]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1124</guid>
		<description><![CDATA[If you are using XAMPP to develop PHP software (WordPress, Joomla!) on OSX you might want to get some advanced logging output from your code. PHP provides nice error_log() function, but it is silent by default. Here are short instructions how to enable it and follow the log. Use your favorite editor to edit php.ini [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> to develop PHP software (WordPress, Joomla!) on OSX you might want to get some advanced logging output from your code. PHP provides nice <a href="http://php.net/manual/en/function.error-log.php">error_log</a>() function, but it is silent by default. Here are short instructions how to enable it and follow the log.</p>
<p>Use your favorite editor to edit php.ini file in <em>/Applications/XAMPP/etc/php.ini</em> &#8211; sudo priviledges needed, <a href="http://www.peterborgapps.com/smultron/">Smultron</a> does it out of the box.</p>
<p>Change lines:</p>
<pre>log_errors = Off</pre>
<pre>;error_log = filename</pre>
<p>To:</p>
<pre>log_errors = on</pre>
<pre>error_log = /tmp/php.log</pre>
<p>Restart Apache using <em>XAMPP controller</em> in <em>Finder -&gt; Applications</em>.</p>
<p>Now use the following UNIX command to see continuous log flow in your terminal:</p>
<pre>tail -f /tmp/php.log
</pre>
<p>See also the earlier article about <a href="http://blog.mfabrik.com/2010/12/22/local-xampp-development-and-unix-file-permissions/">XAMPP and file permissions</a>.
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/16/enable-php-log-output-error_log-on-xampp-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google App Engine: issues with dynamic instances and DeadlineExceededErrors</title>
		<link>http://blog.mfabrik.com/2011/03/11/google-app-engine-issues-with-dynamic-instances-and-deadlineexceedederrors/</link>
		<comments>http://blog.mfabrik.com/2011/03/11/google-app-engine-issues-with-dynamic-instances-and-deadlineexceedederrors/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 10:24:07 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[appengine]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[always on]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[DeadlineExceededError]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[gaeutilities]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[http requiest]]></category>
		<category><![CDATA[instance]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[new process]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[response time]]></category>
		<category><![CDATA[zabbix]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1092</guid>
		<description><![CDATA[Dynamic instances and processing time This Google App Engine feature came me as a surprise, though it makes perfect sense. Your site is slow if it has low traffic. Google App Engine runs Python code on instances. By default, instances are dynamic. Instances are shutdown if they do not have enough traffic (requests per minute). [...]]]></description>
			<content:encoded><![CDATA[<h2>Dynamic instances and processing time</h2>
<p>This Google App Engine feature came me as a surprise, though it makes perfect sense. Your site is slow if it has low traffic.</p>
<p>Google App Engine runs Python code on instances. By default, instances are dynamic. Instances are shutdown if they do not have enough traffic (requests per minute). Thus, when you get the individual hits to App Engine now and then, App Engine must restart your instance every time for each hit.</p>
<p>When this happens, you see the following in App Engine console logs for every request on low volume traffic:</p>
<pre>This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.</pre>
<p>It is not always ok to add 500 &#8211; 2000 milliseconds processing delay on the top of the normal processing time. Google&#8217;s own recommendation was that each page should be served within 200 milliseconds.</p>
<p>There are three ways to optimize this issue</p>
<ul>
<li>Use App Engine premium feature &#8220;Always on&#8221; 0,30 $ / day which keeps your instance always running</li>
<li>Use cron job or such to keep your instance alive (polling once in a minute seems to do the job)</li>
<li>Optimize your imports and split your code to several modules with light amount of imports, so that start up is fast (modules are imported only once)</li>
</ul>
<p>We are using <a href="http://www.zabbix.com/">Zabbix</a> software to monitor our sites (sidenote: I don&#8217;t recommend Zabbix as the first monitoring software choice as it is very difficult to use and has bad user experience, alienating both sysadmins and developers away from it). This is what we had before optimizations &#8211; App Engine was starting a new process for every request:</p>
<p><a href="http://blog.mfabrik.com/wp-content/uploads/2011/03/zabbix31.png"><img class="alignnone size-full wp-image-1095" title="zabbix3" src="http://blog.mfabrik.com/wp-content/uploads/2011/03/zabbix31.png" alt="" width="791" height="490" /></a></p>
<p>&#8230; and this is output we got after optimizations:</p>
<p><a href="http://blog.mfabrik.com/wp-content/uploads/2011/03/zabbix4.png"><img class="alignnone size-full wp-image-1096" title="zabbix4" src="http://blog.mfabrik.com/wp-content/uploads/2011/03/zabbix4.png" alt="" width="786" height="392" /></a></p>
<p>Here is the corresponding diagram after optimizations from App Engine dashboard itself. These processing times are without network latency. As far as I know Google does not expose the endpoints of App Engine hosting, so you don&#8217;t know from which site of the world your responses come from. By comparing this diagram to the diagram above, you can see how Internet traffic is affecting to your App Engine application.</p>
<p><a href="http://blog.mfabrik.com/wp-content/uploads/2011/03/appengine.png"><img class="alignnone size-full wp-image-1097" title="appengine" src="http://blog.mfabrik.com/wp-content/uploads/2011/03/appengine.png" alt="" width="824" height="280" /></a></p>
<h2>The PITA of dying instances</h2>
<p>For some reason, App Engine instances misbehave sometimes. This causes the HTTP requests die ungracefully.</p>
<p>Normally it is not a problem as you lost few page loads now and then. People are used to &#8220;Internet grade&#8221; service and can hit the refresh button if they have problems opening a page.</p>
<p>However if you are monitoring your site and the site gives an unnecessary alarm in the middle of the night, waking up your bastard operator from Hell, he will be very angry next morning and tell you to migrate the crappy software from unreliable Python / App Engine to more reliable PHP servers <img src='http://blog.mfabrik.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>This is what you see in App Engine logs:</p>
<pre>A serious problem was encountered with the process that handled this request, causing it to exit.
This is likely to cause a new process to be used for the next request to your application.
If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)</pre>
<p>After digging in deeper, you see that it is a problem of instating a new object in the database, exceeding 30 seconds hard limit for processing a HTTP request:</p>
<pre>2011-03-09 05:06:20.794 / 500 30094ms 86cpu_ms 40api_cpu_ms
0kb Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
.NET CLR 2.0.50727),gzip(gfe),gzip(gfe),gzip(gfe)

&lt;class 'google.appengine.runtime.DeadlineExceededError'&gt;:
Traceback (most recent call last):
  File "/base/data/home/apps/mfabrikkampagne/1.347249742610459821/main.py", line 494, in main
    run_wsgi_app(application)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 97, in run_wsgi_app
    run_bare_wsgi_app(add_wsgi_middleware(application))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 115, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 515, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/mfabrikkampagne/1.347249742610459821/main.py", line 296, in get
    try: self.session = Session()</pre>
<p>So it looks like there is a temporary hick-up in Google App Engine&#8217;s Data Store (Big Table?). In the example above the error comes from <a href="http://gaeutilities.appspot.com/">gaeutilities</a>&#8216;s Session model, but it could be any other model.</p>
<p><a href="http://code.google.com/intl/fi-FI/appengine/docs/python/runtime.html#The_Request_Timer">It is possible to catch DeadlineExceededError and temporarily work-around it, as shown in App Engine documentation</a>.</p>
<p>The best way to handle this situation is to adjust your monitoring software &#8211; Zabbix in our case. Zabbix allows you to configure triggers so that they don&#8217;t alarm on every bad item state change. Instead, you can use <em>min()</em> function and trigger the alarm after the trigger condition has failed every time during a monitoring period. Just make sure that the trigger period is at least twice long as the update interval of your web scenario: this way Zabbix can logs at least two item state changes and allows one of them to be failed one.</p>
<p>For example if</p>
<ul>
<li>Update interval of web scenario is 60 seconds</li>
<li>Trigger function must check minimal failures of 1 during 2*60 seconds + some buffer = 150 seconds.</li>
</ul>
<pre>{xxx.fi:web.test.fail[de.mfabrik.com].min(150)}=1</pre>
<p>This will allow one failed response before triggering the alarm.
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/11/google-app-engine-issues-with-dynamic-instances-and-deadlineexceedederrors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ghetto logging for PHP</title>
		<link>http://blog.mfabrik.com/2011/03/03/ghetto-logging-for-php/</link>
		<comments>http://blog.mfabrik.com/2011/03/03/ghetto-logging-for-php/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 12:49:55 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[file_put_contents]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=1051</guid>
		<description><![CDATA[In the case you need to quickly see if certain code path is executed on a production server for which config cannot be changed. file_put_contents("/tmp/log.txt", "this is a test entry\n"); The proper method would be Configure error log in php.ini Use error_log() &#8230;. or use logging facility of your PHP framework Get developers  Subscribe mFabrik [...]]]></description>
			<content:encoded><![CDATA[<p>In the case you need to quickly see if certain code path is executed on a production server for which config cannot be changed.</p>
<pre>file_put_contents("/tmp/log.txt", "this is a test entry\n");</pre>
<p>The proper method would be</p>
<ul>
<li>Configure error log in php.ini</li>
<li>Use error_log()</li>
<li>&#8230;. or use logging facility of your PHP framework</li>
</ul>
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/03/03/ghetto-logging-for-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python surpassed PHP in popularity</title>
		<link>http://blog.mfabrik.com/2011/02/15/python-surpassed-php-in-popularity/</link>
		<comments>http://blog.mfabrik.com/2011/02/15/python-surpassed-php-in-popularity/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 08:36:38 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tiobe]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=981</guid>
		<description><![CDATA[TIOBE confirms it. Next: Plone overtakes WordPress in popularity. Get developers  Subscribe mFabrik blog in a reader Follow me on Twitter]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">TIOBE confirms it</a>.</p>
<p>Next: Plone overtakes WordPress in popularity.
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2011/02/15/python-surpassed-php-in-popularity/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Updating and backing up Joomla! site on Ubuntu Linux</title>
		<link>http://blog.mfabrik.com/2010/10/05/updating-and-backing-up-joomla-site-on-ubuntu-linux/</link>
		<comments>http://blog.mfabrik.com/2010/10/05/updating-and-backing-up-joomla-site-on-ubuntu-linux/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 09:29:46 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[joomla]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=823</guid>
		<description><![CDATA[Here are short instructions for advanced Linux users to update Joomla! sites on Ubuntu Linux servers. Little Joomla! experience is required, the instructions are written from the Linux sys-admin reader perspective. The instructions assume full control over the server, though the instructions might also work on the shared hosting. These instructions also consider minor security [...]]]></description>
			<content:encoded><![CDATA[<p>Here are short instructions for advanced Linux users to update Joomla! sites on Ubuntu Linux servers. Little Joomla! experience is required, the instructions are written from the Linux sys-admin reader perspective. The instructions assume full control over the server, though the instructions might also work on the shared hosting. These instructions also consider minor security updates only, not major updates like Joomla! 1.5 -&gt; 1.6.  For further instructions, <a href="http://docs.joomla.org/Upgrading_1.5_from_an_existing_1.5x_version">please refer to Joomla! update manual</a>. See also <a href="http://forum.joomla.org/viewforum.php?f=430">Joomla! update and migration forum</a>.  It is useful to subscribe to <a href="http://developer.joomla.org/security.html">Joomla! security announcements RSS </a>as Joomla!, being unsafe PHP software by its nature, requires security updates very often. Script kiddies can take down your site very fast unless you can keep up with the updates.</p>
<h2>Work as the site user</h2>
<p>The site can be installed locally (under /home) or globally (under /var/www). If the site is installed globally you might need to set your effective user.  You should perform the command as the same user who owns the site PHP files. You should not be using root use as the owner of the site files. If you run Joomla! site through Apache, the effective user is www-data. Use sudo command to switch to this user. Use ls -l command to figure out which user you are.</p>
<pre>sudo -i -u www-data</pre>
<h2>Back up code files</h2>
<p>Use tar command to pack the existing folder structure in the case the update will destroy critical files.</p>
<pre>cd /var/www/yoursite
tar -cjf yoursite.tar.bz2 *</pre>
<h2>Back up database</h2>
<div>Note that you can see the database password in <em>configuration.php</em> file if you do not remember it.</div>
<div>
<pre>mysqldump -umysql_user_name-p mysql_database_name &gt; mysql_database_name.sql</pre>
</div>
<h2>Check Joomla! version</h2>
<div>Login as administrator. The login URL is the site URL + /administrator</div>
<div>Choose Help -&gt; System info from the menu.</div>
<div>You’ll see Joomla! version line.</div>
<h2>Download version specific Joomla! update pack</h2>
<div>
<p>Each minor version requires its own update. You can have update packages between each version like 1.5.18 -&gt; 1.5.19, or update packs which leap versions like 1.5.18 -&gt; 1.5.20.  <a href="http://joomlacode.org/gf/project/joomla/frs/?action=FrsReleaseBrowse&amp;frs_package_id=5325">Go to Joomla! package listing</a>.  Pick-up the package which will update your current Joomla! version to the latest version.  Download the patch file to the server.</p>
<pre>wget http://joomlacode.org/gf/download/frsrelease/12611/53380/Joomla_1.5.18_to_1.5.20-Stable-Patch_Package.tar.gz</pre>
</div>
<div>
<p>Extract it</p>
<pre>tar -xvzf Joomla_1.5.18_to_1.5.20-Stable-Patch_Package.tar.gz</pre>
<p>This will replace the changed Joomla! files with newer versions.</p>
<h2>Check the update has been correctly applied</h2>
<div>Visit Help -&gt; System info again. See that the version number has been updated.</div>
<div>Check that all pages on your site are working.</div>
<div></div>
<div></div>
<div></div>
</div>
<p class="signature">
<a href="http://mfabrik.com/@@zoho-contact-form"><img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/mfabrik-24.png"></a> <a href="http://mfabrik.com/@@zoho-contact-form">Get developers</a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml"><img valign="middle" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" style="vertical-align:middle;border:0"/></a> <a href="http://feeds.feedburner.com/mFabrikWebAndMobileDevelopment" rel="alternate" type="application/rss+xml">Subscribe mFabrik blog in a reader</a> <a href="http://twitter.com/mfabrik"> <img valign="middle"  src="http://blog.mfabrik.com/wp-content/uploads/twitter-24.png"></a> <a href="http://twitter.com/moo9000">Follow me on Twitter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2010/10/05/updating-and-backing-up-joomla-site-on-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating and theming WordPress with your CMS site using XDV</title>
		<link>http://blog.mfabrik.com/2010/03/28/integrating-and-theming-wordpress-with-your-cms-site-using-xdv/</link>
		<comments>http://blog.mfabrik.com/2010/03/28/integrating-and-theming-wordpress-with-your-cms-site-using-xdv/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 12:48:17 +0000</pubDate>
		<dc:creator>Mikko Ohtamaa</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[xdv]]></category>
		<category><![CDATA[zope]]></category>
		<category><![CDATA[deliverance]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[locationmatch]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[theming]]></category>
		<category><![CDATA[virtualhost]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://blog.mfabrik.com/?p=421</guid>
		<description><![CDATA[Introduction XDV is an external HTML theming engine, a.k.a. theming proxy, which allows you to mix and match HTML and CSS from internal and external sites by using simple XML rules. It separates the theme development from the site development, so that people with little HTML and CSS knowledge can create themes without need to [...]]]></description>
			<content:encoded><![CDATA[<div id="xdv-theming">
<div>
<h1><a id="introduction" name="introduction" href="http://www.tele3.cz/jbar/rest/render.py#id1">Introduction</a></h1>
<p>XDV is an external HTML theming engine, a.k.a. theming proxy, which allows you to mix and match HTML and CSS from internal and external sites by using simple XML rules. It separates the theme development from the site development, so that people with little HTML and CSS knowledge can create themes without need to know underlying Python, PHP or whatever. It also enables integration of different services and sites to one, unified, user experience. For example, XDV is used by <cite>plone.org &lt;http://plone.org&gt;</cite> to integrate Plone CMS and Trac issue tracker.  XDV compiles theming rules to XSL templates, which has been a standard XML based templates language since 1999. XSL has good support in every programming language and web server out there. Example backends to perform XSL transformation include</p>
<ul>
<li>Python and lxml library</li>
<li>Apache&#8217;s mod_transform</li>
<li>nginx web server</li>
<li>All XSL capable Java and .NET software out there</li>
</ul>
<p>XDV theming can be used together with Plone where enhanced support is provided by <a href="http://pypi.python.org/pypi/collective.xdv">collective.xdv package</a> package. Technically, collective.xdv adds Plone settings panel and does XSL transformation in Zope&#8217;s post-publication hook using lxml library.  XDV can be used standalone with <a href="http://pypi.python.org/pypi/xdv/0.3a2">XDV package</a> to theme any web site, let it be WordPress, Joomla, Drupal or custom in-house PHP solution from year 2000.  XDV is based on <a href="http://deliverance.openplans.org/">Deliverance specification</a> The difference between XDV and Deliverance reference implementation is that XDV internally compiles themes to XSL templates, when Deliverance relies on processing HTML in Python. Currently XDV approach seems to be working better, as we had many problems trying to apply Deliverance for WordPress site (redirects didn&#8217;t work, HTTP posts didn&#8217;t work, etc.).</p>
</div>
<div>
<h1><a id="tutorials" name="tutorials" href="http://www.tele3.cz/jbar/rest/render.py#id3">Tutorials</a></h1>
<ul>
<li><a href="http://plone.org/products/collective.xdv/documentation/reference-manual/theming">http://plone.org/products/collective.xdv/documentation/reference-manual/theming</a></li>
<li><a href="http://pypi.python.org/pypi/collective.xdv">http://pypi.python.org/pypi/collective.xdv</a></li>
<li><a href="http://pypi.python.org/pypi/xdv">http://pypi.python.org/pypi/xdv</a></li>
<li><a href="http://pypi.python.org/pypi/dv.xdvserver">http://pypi.python.org/pypi/dv.xdvserver</a> (with WSGI)</li>
</ul>
</div>
<div>
<h1><a id="setting-up-xdv-development-tools" name="setting-up-xdv-development-tools" href="http://www.tele3.cz/jbar/rest/render.py#id4">Setting up XDV development tools</a></h1>
<p>XDV tools are deployed as Python eggs. You can use tools like <cite>buildout &lt;http://www.buildout.org/&gt;</cite> configuration and assembly tool or easy_install to get XDV on your development computer and the server.  If you are working with Plone you can integrate XDV to your site existing buildout. If you are not working with Plone, <a href="http://pypi.python.org/pypi/xdv#installation">XDV home page</a> has instructions how to deploy XDV command standalone.</p>
</div>
<div>
<h1><a id="xdv-rules" name="xdv-rules" href="http://www.tele3.cz/jbar/rest/render.py#id5">XDV Rules</a></h1>
<p>Rules (rules.xml) will tell how to fit content from external source to your theme HTML.  It provides straightforward XML based syntax to manipulate HTML easily</p>
<ul>
<li>Append, replace and drop HTML pieces</li>
<li>Insert HTML snippets</li>
<li>CSS or XPath selectors can be used to identify HTML parts</li>
<li>It is possible to mix and match content from more than two sites</li>
<li>etc.</li>
</ul>
<p>Rules XML syntax is documented at <a href="http://pypi.python.org/pypi/xdv">XDV homepage</a>.  Rules will be compiled to XSL template (theme.xsl) by <em>xdvcompiler</em> command. The actual theming is done by one of the XSL backends listed above, by taking HTML as input and applying XSL transformations on it.  Note that currently rules without matching selectors are silently ignored and there is no bullet-proof way to debug what happens inside XSL transformation, except by looking into compiled theme.xsl.</p>
</div>
<div>
<h1><a id="using-xdv-to-theme-and-integrate-a-wordpress-site" name="using-xdv-to-theme-and-integrate-a-wordpress-site" href="http://www.tele3.cz/jbar/rest/render.py#id6">Using XDV to theme and integrate a WordPress site</a></h1>
<p>Below are instructions how to integrate a WordPress site to your CMS. In this example CMS is Plone, but it could be any other system.  We will create XDV theme which will theme WordPress site to match our CMS site in the fly.</p>
<p style="text-align: center;"><a href="http://blog.mfabrik.com/wp-content/uploads/2010/03/xdv_wordpress.png"><img class="size-full wp-image-424 aligncenter" title="xdv_wordpress" src="http://blog.mfabrik.com/wp-content/uploads/2010/03/xdv_wordpress.png" alt="" width="658" height="720" /></a></p>
<p>WordPress theme using built with XDV and using a live Plone web page as a theme template.  This way WordPress theme inherits &#8220;live data&#8221; from Plone site, like top tabs (portal sections), footer, CSS and other stuff which can be changed in-the-fly and reflecting changes to two separaet theming products would be cumbersome.  Benefits using WordPress for blogging instead of main CMS</p>
<ul>
<li>WordPress post and comment management is easy</li>
<li>WordPress does not need to be touched: the old public WordPress instance can keep happily running wherever it is during the whole process</li>
<li>You do not need to migrate legacy WordPress installations to your CMS&#8217;s internal blogging tool</li>
<li>WordPress comes with extensive blog spam filtering tools. We get 11000 spam comments a month.</li>
<li>WordPress is designed for blogging and the user interface is good for that</li>
<li>WordPress integrates well with blog pingback support services</li>
<li>WordPress supports Gravatars and other blogging plug-ins</li>
<li>..and so on&#8230;</li>
</ul>
<p>Benefits of using XDV theming instead of creating native WordPress theme are</p>
<ul>
<li>You need to maintain only one theming add-on product e.g. one for your main CMS and WordPress receives updates to this site and theme automatically</li>
<li>WordPress does not need to be touched</li>
<li>You can host your WordPress on a different server, even wordpress.com, and still integrate it to your main CMS</li>
<li>The theme can be recycled not only for WordPress, but also other external services: Bugzilla, Trac, Webmail, phpBB, you-name-it</li>
<li>Even though WordPress has slick UI, it is a well known fact that it is a can of worms internally. My developers do not like the idea of PHP development and would spit on my face if I ask them to go a develop a WordPress theme for us</li>
</ul>
<div>
<h2><a id="theme-elements" name="theme-elements" href="http://www.tele3.cz/jbar/rest/render.py#id7">Theme elements</a></h2>
<p>The theme will consist of following pieces</p>
<ul>
<li>Deliverance rules XML file which defines how to combine Plone and WordPress HTML (rules.xml)</li>
<li>Additional CSS definitions active only for WordPress (wordpress.css). Dependency to this CSS in injected to the &lt;head&gt; by rules XML</li>
<li>Special Plone page template which will provide slots where WordPress can drop in the content (wordpress_listing.pt)</li>
<li>A helper script which makes it easy for repeatable perform theming actions, like recompiling the theme (xdv.py)</li>
</ul>
<div>
<h3><a id="cms-page-template" name="cms-page-template" href="http://www.tele3.cz/jbar/rest/render.py#id8">CMS page template</a></h3>
<p>This explains how to create a Plone page template where WordPress content will be dropped in. This step is not necessary, as we could do this without touching the Plone. However, it makes things more straightforward and explicit when we known that WordPress theme uses a certain template and we explicitly define slots for WordPress content there.  Example:</p>
<pre>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="here/main_template/macros/master"
      i18n:domain="plone"&gt;

&lt;body&gt;

    &lt;div metal:fill-slot="content"&gt;

        &lt;div id="wordpress-content"&gt;
                &lt;!-- Your WordPress "left column" will go there --&gt;
        &lt;/div&gt;

    &lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<div>
<h3><a id="theming-rules" name="theming-rules" href="http://www.tele3.cz/jbar/rest/render.py#id9">Theming rules</a></h3>
<p>Following are XDV rules (rules.xml) how we will fit WordPress site to Plone frame.  It will integrate</p>
<ul>
<li>Content from WordPress</li>
<li>Metadata from WordPress</li>
<li>CSS from Plone</li>
<li>Page basic structrure from Plone</li>
</ul>
<p>rules.xml:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;rules xmlns="http://namespaces.plone.org/xdv"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:css="http://namespaces.plone.org/xdv+css"&gt;

    &lt;!-- Remove WordPress CSS by filtering out &lt;style&gt; tags--&gt;
    &lt;drop css:content="style" /&gt;

    &lt;!-- Make sure that WordPress metadata is present in &lt;head&gt; section --&gt;
    &lt;append css:content="head link" css:theme="head" /&gt;

    &lt;!-- note: replace does not seem to handle multiple meta tags very well --&gt;
    &lt;drop css:theme="meta" /&gt;
    &lt;append css:content="head meta" css:theme="head" /&gt;

    &lt;!-- Use blog title instead of Plone page title --&gt;
    &lt;replace css:content="title" css:theme="title" /&gt;

    &lt;!-- Put WordPress sidebar to Plone's portlets section --&gt;
    &lt;append css:content="#r_sidebar" css:theme="#portal-column-one .visualPadding" /&gt;

    &lt;!-- Place wordpress content into our theme content area --&gt;
    &lt;copy css:content="#contentleft" css:theme="#wordpress-content" /&gt;

    &lt;!-- This mixes in WordPress specific CSS sheet which is applied for pages
         served from WordPress only and does not concern Plone CMS.
         This stylesheet will theme WordPress specific tags,
         like blog posts and comment fields.
         We keep this file in Plone, but this could be served from elsewhere. --&gt;
    &lt;append css:theme="head"&gt;
        &lt;style type="text/css"&gt;
           @import url(http://mfabrik.com/++resource++plonetheme.mfabrik/wordpress.css);
        &lt;/style&gt;
    &lt;/append&gt;

    &lt;!-- This stylesheet is used by special spam protection plug-in NoSpamNX --&gt;
    &lt;append css:theme="head"&gt;
        &lt;link rel="stylesheet" href="http://blog.mfabrik.com/wp-content/plugins/nospamnx/nospamnx.css" type="text/css" /&gt;
    &lt;/append&gt;

    &lt;!-- Remove Google Analytics script used for CMS site --&gt;
    &lt;drop css:theme="#page-bottom script" /&gt;

    &lt;!-- Rebuild our Google Analytics code, using a different tracker id this time
         which is a specific to our blog.
      --&gt;
    &lt;append css:theme="#page-bottom"&gt;

        &lt;script type="text/javascript"&gt;
                var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
                document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        &lt;/script&gt;

        &lt;script type="text/javascript"&gt;
                try {
                       var pageTracker = _gat._getTracker("UA-8819100-2");
                       pageTracker._trackPageview();
                } catch(err) {
                }
        &lt;/script&gt;
    &lt;/append&gt;

&lt;/rules&gt;
</pre>
</div>
<div>
<h3><a id="wordpress-specific-css" name="wordpress-specific-css" href="http://www.tele3.cz/jbar/rest/render.py#id10">WordPress specific CSS</a></h3>
<p>This CSS has styles which are applied only to WordPress pages. They are mainly corner case fixes where WordPress and CMS styles must match.  The CSS file is loaded when rules.xml injects it to &lt;head&gt; section.  wordpress.css:</p>
<pre>/* Font and block style fixes */

#wordpress-content h1 {
        border: 0;
}

#wordpress-content .post-end {
        margin-bottom: 60px;
}

#wordpress-content pre {
        width: 600px;
        overflow: auto;
        background: white;
        border: 1px solid #888;
}

#wordpress-content ul {
        margin-left: 20px;
}

#wordpress-content .post-info-date,
#wordpress-content .post-info-categories,
#wordpress-content .post-info-tags {
        font-size: 80%;
        color: #888;
}

/* Make sure that posts and comments look sane in our theme */

#wordpress-content .post {
        margin-top: 15px;
}

#wordpress-content .commentlist li {
        margin: 20px;
        background: white;
        padding: 10px;
}

#wordpress-content .commentlist li img {
        float: left;
        margin-right: 20px;
        margin-bottom: 20px;
}

#wordpress-content #commentform {
        margin: 20px;
}

#wordpress-content {
        margin-left: 20px;
        margin-right: 20px;
}

/* Make WordPress "sidebaar" look like Plone "portlets */

.template-wordpress_listing #portal-column-one ul {
        list-style: none;
        margin-bottom: 40px;
}

.template-wordpress_listing #portal-column-one ul#Recent li {
        margin-bottom: 8px;
}

.template-wordpress_listing #portal-column-one ul#Categories a {
        line-height: 120%;
}

.template-wordpress_listing #portal-column-one h2 {
        background: transparent;
        border: 0;
        font-weight:normal;
        line-height:1.6em;
        padding:0;
        text-transform:none;
        font-size: 16px;
        color: #9b9b9b;
        border-bottom:4px solid #CDCDCD;
}
</pre>
</div>
<div>
<h3><a id="helper-script" name="helper-script" href="http://www.tele3.cz/jbar/rest/render.py#id11">Helper script</a></h3>
<p>The following Python script (xdv.py) makes it easy for us</p>
<ul>
<li>Recompile the theme</li>
<li>Test the theme applied on the site</li>
<li>Preview the theme in our browser</li>
</ul>
<dl>
<dt>It is basically wrapped with default file locations around</dt>
<dd><em>bin/xdvcompiler</em> and <em>bin/xdvrun</em> commands with some webbrowser opening magic.</dd>
</dl>
<p>xdv.py:</p>
<pre>"""

 This command line Python script compiles your rules.xml to XDV XSL

 Modify it for your own needs.

 It assumes your buildout.cfg has xdv section and generated XDV
 commands under bin/

 To compile, execute in the buildout folder::

     python src/plonetheme.mfabrik/xdv.py

 To build test HTML::

     python src/plonetheme.mfabrik/xdv.py --test

 To build test HTML and preview it in browser, execute in buildout folder::

     python src/plonetheme.mfabrik/xdv.py --preview

"""

import getopt, sys
import os
import webbrowser

# rules XML for theming
RULES_XML = "src/plonetheme.mfabrik/deliverance/etc/rules.xml"

# Which XSL file to generate for compiled XDV
OUTPUT_FILE = "theme.xsl"

# Which file to generate applied theme test runs
TEST_HTML_FILE = "test.html"

# Our "theme.html" is a remote template served for each request.
# Because we are doing live integrattion, this is a HTTP resource,
# not a local file.
THEME="http://mfabrik.com/news/wordpress_listing/"

#
# External site you are theming.
# Note: must have ending slash (lxm cannot handle redirects)
#
SITE="http://blog.twinapex.fi/"

try:
    opts, args = getopt.getopt(sys.argv[1:], "pt", ["preview", "test"])
except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) # will print something like "option -a not recognized"

# Convert options to simple list
opts = [ opt for opt, value in opts ]

print "Compiling transformation"
value = os.system("bin/xdvcompiler -o " + OUTPUT_FILE + " " + RULES_XML +" " + THEME)
if value != 0:
    print "Compilation failed"
    sys.exit(1)

if "-p" in opts or "--preview" in opts or "-t" in opts or "--test" in opts:
      print "Generating test HTML page"
      value = os.system("bin/xdvrun -o " + TEST_HTML_FILE + " " + OUTPUT_FILE + " " + SITE)
      if value != 0:
          print "Page transformation failed"
          sys.exit(1)

if "-p" in opts or "--preview" in opts:
    # Preview the result in a browser
    # NOTE: OSX needs Python &gt;= 2.5 to make this work

    # Make sure test run succeeded
    url = "file://" + os.path.abspath(TEST_HTML_FILE)
    print "Opening:" + url

    # We prefer Firefox for preview for its superious
    # Firebug HTML debugger and XPath rule generator
    try:
        browser = webbrowser.get("firefox")
    except webbrowser.Error:
        # No FF on the system, or OSX which can't find its browsers
        browser = webbrowser.get()

    browser.open_new_tab(url)
</pre>
</div>
</div>
<div>
<h2><a id="compiling-the-theme" name="compiling-the-theme" href="http://www.tele3.cz/jbar/rest/render.py#id12">Compiling the theme</a></h2>
<p>This will generate XSL templates to do theming transform. It will compile rules XML with some boilerplate XSL.  Running our compile script:</p>
<pre>python src/plonetheme.mfabrik/xdv.py
</pre>
<p>Since Plone usually does not use any relative paths or relative resources in HTML, we do not give the parameter &#8220;Absolute prefix&#8221; to the compilation stage. In Plone, everything is mapped through a virtual hosting aware resource locator: portal_url and VirtualHostMonster.  For more information see</p>
<ul>
<li><a href="http://pypi.python.org/pypi/xdv/0.3a2#compilation">http://pypi.python.org/pypi/xdv/0.3a2#compilation</a></li>
</ul>
</div>
<div>
<h2><a id="testing-the-theme" name="testing-the-theme" href="http://www.tele3.cz/jbar/rest/render.py#id13">Testing the theme</a></h2>
<p>The following command will apply theme for an example external page:</p>
<pre>bin/xdvrun -o theme.html theme.xsl http://blog.twinapex.fi
firefox theme.xhtml
</pre>
<p>&#8230; or we can use shortcut provided by our script &#8230;</p>
<pre>python src/plonetheme.mfabrik/xdv.py --preview
</pre>
</div>
<div>
<h2><a id="applying-the-theme-in-apache-production-environment" name="applying-the-theme-in-apache-production-environment" href="http://www.tele3.cz/jbar/rest/render.py#id14">Applying the theme in Apache production environment</a></h2>
<p>These steps tell how to apply the integration theme for WordPress when WordPress is running under Apache virtualhost.</p>
<div>
<h3><a id="installing-dependencies" name="installing-dependencies" href="http://www.tele3.cz/jbar/rest/render.py#id15">Installing dependencies</a></h3>
<p>We use Apache and mod_transform. <a href="http://pypi.python.org/pypi/xdv#apache">Instructions how to set up modules for Apache</a> are available on XDV homepage. Some hand-build modules must be used, but instructions to set them up for Ubuntu / Debian are available.  Apache 2 supports <a href="http://httpd.apache.org/docs/2.2/mod/mod_filter.html">filter chains</a> which allow you to perform magic on HTTP response before sending it out. This corresponds Python&#8217;s WSGI middleware.  We&#8217;ll use special built of mod_transform and mod_depends which are known to working. These modules were forked from their orignal creations to make them XDV compatible, as the orignal has not been updated since 2004 (here you can nicely see how open source guarantees &#8220;won&#8217;t run out of support&#8221; freedom).</p>
<ul>
<li><a href="http://code.google.com/p/html-xslt/">XDV mod_transform and mod_depends homepage</a></li>
<li><a href="http://www.outoforder.cc/projects/apache/mod_transform/">Orignal mod_transform and mod_depends homepage</a></li>
</ul>
<p>Example:</p>
<pre>sudo -i
apt-get install libxslt1-dev libapache2-mod-apreq2 libapreq2-dev apache2-threaded-dev
wget http://html-xslt.googlecode.com/files/mod-transform-html-xslt.tgz
wget http://html-xslt.googlecode.com/files/mod-depends-html-xslt.tgz
tar -xzf mod-transform-html-xslt.tgz
tar -xzf mod-depends-html-xslt.tgz
cd mod-depends-html-xslt ; ./configure ; make ; make install ; cd ..
cd mod-transform-html-xslt ; ./configure ; make ; make install ; cd ..
</pre>
<p>Enable built-in Apache modules:</p>
<pre>a2enmod filter
a2enmod ext_filter
</pre>
<p>For modules <em>depends</em> and <em>transform</em> you need to manually add them to the end of Apache configuration, as they do not provide a2enmod stubs for Debian. Edit /etc/apache2/apache.conf:</p>
<pre>LoadModule depends_module /usr/lib/apache2/modules/mod_depends.so
LoadModule transform_module /usr/lib/apache2/modules/mod_transform.so
</pre>
<p>You need to hard reset Apache to make the new modules effective:</p>
<pre>/etc/init.d/apache2 force-reload
</pre>
</div>
<div>
<h3><a id="virtual-host-configuration" name="virtual-host-configuration" href="http://www.tele3.cz/jbar/rest/render.py#id16">Virtual host configuration</a></h3>
<p>Below is our virtualhost configuration which runs WordPress and PHP. Transformation filter chain has been added in.  /etc/apache/sites-enabled/blog.mfabrik.com:</p>
<pre>&lt;VirtualHost *&gt;

    ServerName blog.mfabrik.com
    ServerAdmin info@mfabrik.com

    LogFormat       combined
    TransferLog     /var/log/apache2/blog.mfabrik.com.log

    # Basic WordPress setup

    Options +Indexes FollowSymLinks +ExecCGI

    DocumentRoot /srv/www/wordpress

    &lt;Directory /srv/www/wordpress&gt;
        Options FollowSymlinks
        AllowOverride All
    &lt;/Directory&gt;

    AddType application/x-httpd-php .php .php3 .php4 .php5
    AddType application/x-httpd-php-source .phps

    # Theming set-up

    # This chain is used for public web pages
    FilterDeclare THEME
    FilterProvider THEME XSLT resp=Content-Type $text/html

    TransformOptions +ApacheFS +HTML
    # This is the location of compiled XSL theme transform
    TransformSet /theme.xsl

    # This will make Apache not to reload transformation every time
    # it is performed. Instead, a compiled version is hold in the
    # virtual URL declared above.
    TransformCache /theme.xsl /srv/plone/twinapex.fi/theme.xsl

    # We want to apply theme only for
    # 1. public pages (otherwise WordPress administrative interface stops working)
    &lt;Location "/"&gt;
        FilterChain THEME
    &lt;/Location&gt;

    # 2. Admin interface and feeds should not receive any kind of theming
    &lt;LocationMatch "(wp-login|wp-admin|wp-includes)"&gt;
        # The following resets the filter chain
        # http://httpd.apache.org/docs/2.2/mod/mod_filter.html#filterchain
        FilterChain !
    &lt;/LocationMatch&gt;

&lt;/VirtualHost&gt;
</pre>
</div>
<div>
<h3><a id="running-it" name="running-it" href="http://www.tele3.cz/jbar/rest/render.py#id17">Running it</a></h3>
<p>After Apache has all modules enabled and your virtualhost configuration is ok, you should see WordPress through your new theme by visiting at the site served through Apache:</p>
<ul>
<li><a href="../">http://blog.mfabrik.com</a></li>
</ul>
</div>
<div>
<h3><a id="automatically-reflecting-cms-changes-back-to-xdv-theme" name="automatically-reflecting-cms-changes-back-to-xdv-theme" href="http://www.tele3.cz/jbar/rest/render.py#id18">Automatically reflecting CMS changes back to XDV theme</a></h3>
<p>The theme should be recompiled every time</p>
<ul>
<li>Plone is restarted: CSS references change in &lt;head&gt; as CSS cache is rebuilt</li>
<li>CSS is modified: CSS references change in &lt;head&gt; as CSS cache is rebuilt</li>
<li>Plone content is changed and changes reflect back to WordPress theme (e.g. a new top level site section is being added)</li>
</ul>
<p>This is because the compilation will hard-link resources and template snippets to resulting the theme.xsl file. If hard-linked resources change on the Plone site, the transformation XSL file does not automatically reflect back the changes.  It could be possible to use Plone events automatically to rerun theme compilation when concerned resources change. However, the would be quite complex.  For now, we are satisfied with a scheduled task which will recompile the theme now and then.  Alternatively, mod_transforms could be run in non-cached mode with some performance implications.  Here is a shell script, update-wordpress-theme.sh, which will perform the recompilation and make Apache&#8217;s transformation cache aware of changes:</p>
<pre>#!/bin/sh
#
# Periodically update WordPress theme to reflect changes on CMS site
#

# Recompile theme
sudo -H -u twinapex /bin/sh -c cd /srv/plone/twinapex.fi ; python src/plonetheme.mfabrik/xdv.py

# Make Apache aware of theme changes
sudo apache2ctl graceful
</pre>
<p>Then we call it periodically in cron job, every 15 minutes in /etc/cron.d/update-wordpress:</p>
<pre># Make WordPress XDV theme to reflect changes on CMS
0,15,30,45 * * * * /srv/plone/twinapex.fi/update-wordpress-theme.sh
</pre>
</div>
</div>
<div>
<h2><a id="updating-wordpress-settings" name="updating-wordpress-settings" href="http://www.tele3.cz/jbar/rest/render.py#id19">Updating WordPress settings</a></h2>
<p>No changes on WordPress needed if the domain name is not changed in the theme transformation process.</p>
<div>
<h3><a id="site-url" name="site-url" href="http://www.tele3.cz/jbar/rest/render.py#id20">Site URL</a></h3>
<p>Unlike Plone, WordPress does not have decent virtual hosting machinery. It knowns only one URL which is uses to refer to the site in the external context (e.g. RSS feeds).  This setting can be overridden in</p>
<ul>
<li>WordPress administrative interface</li>
<li>wp-config.php</li>
</ul>
<p>Here is an example how we override this in our wp-config.php:</p>
<pre>// http://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29
define('WP_HOME','http://blog.mfabrik.com');
define('WP_SITEURL','http://blog.mfabrik.com');
</pre>
</div>
</div>
<div>
<h2><a href="http://www.tele3.cz/jbar/rest/render.py#id21">HTTP 404 Not Found special case</a></h2>
<p>Http 404 Not Found responses are not themed by Apache filter chain. This is not possible due to order of pipeline in Apache.  As a workaround you can set up a custom HTTP 404 page in WordPress which does not expose the old theme.</p>
<ul>
<li>Go to WordPress admin interface, Theme editor</li>
<li>Edit 404.php and modify it so that it does not pull in the WordPress theme:
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Not found&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

        &lt;h1&gt;Not Found, Error 404&lt;/h1&gt;
        &lt;p&gt;Aaaaw, snap! The page you are looking for no longer exists. It must be our hamster who ate it.&lt;/p&gt;

        &lt;a href="&lt;?php bloginfo('url'); ?&gt;"&gt;Go to blog homepage&lt;/a&gt;

        &lt;a href="http://mfabrik.com"&gt;mFabrik business site&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</li>
</ul>
<p>For more information see</p>
<ul>
<li><a href="http://codex.wordpress.org/Creating_an_Error_404_Page">http://codex.wordpress.org/Creating_an_Error_404_Page</a></li>
</ul>
</div>
<div>
<h2><a id="roll-out-checklist" name="roll-out-checklist" href="http://www.tele3.cz/jbar/rest/render.py#id22">Roll-out checklist</a></h2>
<p>Below is a checklist you need to go to through to confirm that the theme integration works on your production site</p>
<ul>
<li>WordPress public pages are loaded with the new theme</li>
<li>WordPress login works</li>
<li>WordPress administrative interface works</li>
<li>RSS feed from WordPress works and contain correct URLs</li>
<li>HTTP 404 not found is handled correctly</li>
<li>HTTP 302 redirect is handled correctly (i.e. missing / at the end of blog post URL)</li>
<li>Changes on CMS site are reflected to WordPress theme within the update delay</li>
<li>Old blog site is redirected to new site using HTTP 301 (if applies)</li>
</ul>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.mfabrik.com/2010/03/28/integrating-and-theming-wordpress-with-your-cms-site-using-xdv/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

