<?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>Dan's Blog</title>
	<atom:link href="http://danosipov.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://danosipov.com/blog</link>
	<description>I will be posting my latest photos, as well as code snippets, useful tricks &#38; techniques, and whatever else is on my mind on a particular day.</description>
	<lastBuildDate>Tue, 26 Jul 2011 00:10:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Doctrine 2.0 Entity Serialization</title>
		<link>http://danosipov.com/blog/?p=377</link>
		<comments>http://danosipov.com/blog/?p=377#comments</comments>
		<pubDate>Tue, 26 Jul 2011 00:10:24 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=377</guid>
		<description><![CDATA[Doctrine 2.0 documentation recommends against serializing entities. If you ignore the documentation, you will be faced with PHP notices, such as
Notice: Unknown: "id" returned as member variable from __sleep() but does not exist in Unknown on line 0
as well as broken object relations on unserialized objects. But its very tempting to use the entities in [...]]]></description>
			<content:encoded><![CDATA[<p>Doctrine 2.0 documentation recommends against <a href="http://www.doctrine-project.org/docs/orm/2.0/en/reference/architecture.html#serializing-entities">serializing entities</a>. If you ignore the documentation, you will be faced with PHP notices, such as</p>
<p><code>Notice: Unknown: "id" returned as member variable from __sleep() but does not exist in Unknown on line 0</code></p>
<p>as well as broken object relations on unserialized objects. But its very tempting to use the entities in situations that implicitly require serialization &#8211; for example in Zend_Auth. A &#8220;User&#8221; entity used in Zend_Auth would be written to session, and thus serialized implicitly, creating the already mentioned problems.</p>
<p>However, its relatively easy to create a proxy to the entity. For example:</p>
<p><code><br />
class UserProxy {<br />
&nbsp;&nbsp;&nbsp; protected $entity;<br />
&nbsp;&nbsp;&nbsp; protected $identity;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; public function __construct($entity)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;entity = $entity;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Get the identifier from the entity<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;identity = $this-&gt;entity-&gt;getId();<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; public function __call($name, $arguments)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return call_user_func_array(<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; array($this-&gt;entity, $name),<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $arguments);<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; public function __sleep()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return array('identity');<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; public function __wakeup()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;restore();<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; protected function restore()<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!empty($this-&gt;identity)) {<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Replace with however you get<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // the entity manager<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $entityManager = Zend_Registry::get('em');<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;entity = $entityManager<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -&gt;find('User', $this-&gt;identity);<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
</code></p>
<p>Now you just use the proxy in place of the entity in situations requiring serialization.</p>
<p><code><br />
$toSerialize = new UserProxy($userEntity);<br />
</code></p>
<p>Any method calls made to the Proxy will be forwarded to the entity by the magic method. If the Proxy object is serialized, upon waking up, it will use the identifier to restore the entity.</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=377</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bisna lib and Doctrine 2.1</title>
		<link>http://danosipov.com/blog/?p=372</link>
		<comments>http://danosipov.com/blog/?p=372#comments</comments>
		<pubDate>Wed, 06 Jul 2011 15:00:52 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=372</guid>
		<description><![CDATA[Those of you using Bisna library to easily hook Doctrine 2 ORM into Zend Framework, may find that it is incompatible with Doctrine 2.1. The reason is the rewritten annotation reader in Doctrine 2.1, which Bisna doesn&#8217;t support. However, its easy to update it.
In Bisna/Application/Container/DoctrineContainer.php, find the method startORMMetadata (should be the last method in [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you using<a href="https://github.com/prolic/ZendFramework1-Doctrine2" target="_blank"> Bisna library</a> to easily hook Doctrine 2 ORM into Zend Framework, may find that it is incompatible with <a href="http://www.doctrine-project.org/blog/doctrine-2-1" target="_blank">Doctrine 2.1</a>. The reason is the rewritten annotation reader in Doctrine 2.1, which Bisna doesn&#8217;t support. However, its easy to update it.</p>
<p>In Bisna/Application/Container/DoctrineContainer.php, find the method startORMMetadata (should be the last method in the file), and replace it with the following (apologies for messed up indentation <img src='http://danosipov.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ):</p>
<p><code><br />
private function startORMMetadata(array $config = array())<br />
{<br />
$metadataDriver = new \Doctrine\ORM\Mapping\Driver\DriverChain();</p>
<p>// Default metadata driver configuration<br />
$defaultMetadataDriver = array(<br />
'adapterClass'               =&gt; 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',<br />
'mappingNamespace'           =&gt; '',<br />
'mappingDirs'                =&gt; array(),<br />
'annotationReaderClass'      =&gt; 'Doctrine\Common\Annotations\AnnotationReader',<br />
'annotationReaderCache'      =&gt; $this-&gt;defaultCacheInstance,<br />
'annotationReaderNamespaces' =&gt; array()<br />
);</p>
<p>foreach ($config as $driver) {<br />
$driver = array_replace_recursive($defaultMetadataDriver, $driver);</p>
<p>// Register the ORM Annotations in the AnnotationRegistry<br />
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(<br />
APPLICATION_PATH . '/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');</p>
<p>$reflClass = new \ReflectionClass($driver['adapterClass']);<br />
$nestedDriver = null;</p>
<p>if (<br />
$reflClass-&gt;getName() == 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' ||<br />
$reflClass-&gt;isSubclassOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver')<br />
) {<br />
$annotationReaderClass = $driver['annotationReaderClass'];<br />
$reader = new $annotationReaderClass();<br />
$reader-&gt;setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');<br />
$reader-&gt;setIgnoreNotImportedAnnotations(true);<br />
$reader-&gt;setEnableParsePhpImports(false);</p>
<p>foreach ($driver['annotationReaderNamespaces'] as $alias =&gt; $namespace) {<br />
$reader-&gt;setAnnotationNamespaceAlias($namespace, $alias);<br />
}</p>
<p>$annotationReader = new \Doctrine\Common\Annotations\CachedReader(<br />
new \Doctrine\Common\Annotations\IndexedReader($reader),<br />
new \Doctrine\Common\Cache\ArrayCache()<br />
);<br />
$nestedDriver = $reflClass-&gt;newInstance($annotationReader, $driver['mappingDirs']);<br />
} else {<br />
$nestedDriver = $reflClass-&gt;newInstance($driver['mappingDirs']);<br />
}</p>
<p>$metadataDriver-&gt;addDriver($nestedDriver, $driver['mappingNamespace']);<br />
}</p>
<p></code></p>
<p><code>if (($drivers = $metadataDriver-&gt;getDrivers()) &amp;&amp; count($drivers) == 1) {<br />
reset($drivers);<br />
$metadataDriver = $drivers[key($drivers)];<br />
}<br />
</code></p>
<p><code> return $metadataDriver;<br />
}</code></p>
<p>You should be good to go. Hopefully this saved you some time in research. I&#8217;ll try to push this update to github as well.</p>
<p>Any comments about missed configuration options are always welcomed!</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=372</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Overwintering Monarchs</title>
		<link>http://danosipov.com/blog/?p=364</link>
		<comments>http://danosipov.com/blog/?p=364#comments</comments>
		<pubDate>Fri, 11 Mar 2011 16:13:44 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Travelog]]></category>
		<category><![CDATA[butterfly]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=364</guid>
		<description><![CDATA[
Every year millions of monarch butterflies fly more than three thousand miles from Canada to Mexico, to the same mountains where a year earlier their grandparents spent the winter. This phenomenon is the migration of the Eastern Monarch. Last month I took the trip, organized by Expedition Travel, to the Transvolcanic mountain range in Mexico [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/danospv/5517743906/" title="Illuminated by the Sun by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5014/5517743906_5178338ba2.jpg" width="500" height="322" alt="Illuminated by the Sun" /></a></p>
<p>Every year millions of monarch butterflies fly more than three thousand miles from Canada to Mexico, to the same mountains where a year earlier their grandparents spent the winter. This phenomenon is the migration of the Eastern Monarch. Last month I took the trip, organized by <a href="http://www.ExpeditionTravelOnline.com" target="_blank">Expedition Travel</a>, to the Transvolcanic mountain range in Mexico to witness the colonies of overwintering monarchs.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517743882/" title="Gathering by a Water Source by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5018/5517743882_c98c72a209.jpg" width="500" height="333" alt="Gathering by a Water Source" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743758/" title="Gathering by a Water Source by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5020/5517743758_fecf0972e3.jpg" width="500" height="333" alt="Gathering by a Water Source" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743246/" title="Mating Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5096/5517743246_5c33f609be.jpg" width="500" height="333" alt="Mating Monarchs" /></a></p>
<p>The monarchs in the colony were quite active, thanks to plenty of sunlight. Their generation took the trip in the fall of previous year from Canada down to Mexico, where they spent the winter clinging to trunks and branches of the Oyamel trees. Now they were mating and flying north to Texas. They would reach Texas in early spring, and females will lay eggs on young milkweed plants before dying. The generation born from the eggs will live for a month, and make the trip further north, reaching Alabama, Carolinas, etc. The generation after them will continue the path north, reaching Pennsylvania, Ohio, New York. They also live for a month. The following generation is called Methuselah generation, since they end up living nine times longer than the previous generations, fly up to Canada, and then make their way back to Mexico, flying close to 50 miles per day during the migration, and then spend five months at the overwintering site.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517152583/" title="Monarch Butterfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5054/5517152583_cf66a858aa.jpg" width="500" height="333" alt="Monarch Butterfly" /></a></p>
<p>What motivates the monarch to take this dangerous trip? Their host plant &#8211; the milkweed is more abundant in North America, than it is in Central. Mexico has 6 species of milkweeds, while US has over a hundred. Yet, they can&#8217;t just stay in North America, since they can&#8217;t withstand temperatures below freezing being a tropical butterfly. Milkweed is poisonous, but Monarchs are able to digest it, and use it for protection against the predators. A bird that eats a monarch experiences a heart attack, and will not eat another monarch, or anything that looks like it (ex: Viceroy).</p>
<p><a href="http://www.flickr.com/photos/danospv/5517743170/" title="Overwintering Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5014/5517743170_bab06720b8.jpg" width="333" height="500" alt="Overwintering Monarchs" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743156/" title="Overwintering Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5257/5517743156_ea9af253af.jpg" width="333" height="500" alt="Overwintering Monarchs" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743134/" title="By a Water Stream by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5172/5517743134_7ce5624a63.jpg" width="500" height="333" alt="By a Water Stream" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743116/" title="Monarch Tag by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5051/5517743116_467b503c00.jpg" width="500" height="333" alt="Monarch Tag" /></a></p>
<p>Monarchs take various paths in getting to Mexico. Some follow the coast down to Texas, feasting on flowers blooming thanks to the fall storms, then fly across the land to Mexico. Others fly down to Florida, to Cuba, then to Yucatan, then follow the land back North to the Transvolcanic range. Monarch&#8217;s wings are covered with scales that repel water, so they&#8217;re able to rest on the water, assuming the waves are not high, and then take off from the water. Not much more is known about the paths that monarchs take, but what is known has been discovered thanks to the <a href="http://www.monarchwatch.org/" target="_blank">Monarch Watch</a> tagging program.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517743098/" title="Overwintering Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5298/5517743098_ec1dfc53cf.jpg" width="333" height="500" alt="Overwintering Monarchs" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517743072/" title="Overwintering Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5133/5517743072_85567b4509.jpg" width="333" height="500" alt="Overwintering Monarchs" /></a></p>
<p>The monarch is a butterfly ruled by the sun. When the autumn sun reaches fifty two degrees above the horizon, monarch reproduction cycle shuts down, and migration is kicked off. The generation that flies to Mexico has never been there, yet they&#8217;re able to find the exact spot year after year where their grand-parents spent the winter. It is believed they use a combination of senses to reach their destination. They&#8217;re able to orient themselves to the sun by using polarized light. Then they&#8217;re able to sense the magnetic field of the earth thanks to small magnetic sensors in the base of their wings. This is also extremely helpful, since the mountains where they end up for the winter are of volcanic origin, and are thus rich in iron. Finally, the millions of monarchs every winter leave behind billions of microscopic scales, and its possible that the monarchs are able to detect these using chemical scents.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517152415/" title="Overwintering Monarch Cluster by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5172/5517152415_16f6781541.jpg" width="333" height="500" alt="Overwintering Monarch Cluster" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517742968/" title="Overwintering Monarch Cluster by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5093/5517742968_5781567b58.jpg" width="338" height="500" alt="Overwintering Monarch Cluster" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517152295/" title="Overwintering Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5255/5517152295_d5b73e3050.jpg" width="500" height="331" alt="Overwintering Monarchs" /></a></p>
<p>Once the monarchs reach their destination, they start accumulating in clusters, with the base butterfly holding on to the pine needle, and others holding on to its wings. These clusters can get several butterflies deep, with the temperature in the center of the cluster slightly higher than on the outside. But there is a danger, where a strong enough wind will cause the base monarch to lose grip and fall to the ground. Several mice in the region count on this, and are ready to eat the fallen butterflies. They even line their nests with monarch wings for decoration. Who can blame them?</p>
<p><a href="http://www.flickr.com/photos/danospv/5517152211/" title="Fleeting Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5259/5517152211_8542b4fc8f.jpg" width="333" height="500" alt="Fleeting Monarchs" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517742750/" title="Overwintering Monarchs on a Trunk by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5258/5517742750_b9a5ebe384.jpg" width="333" height="500" alt="Overwintering Monarchs on a Trunk" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5517151997/" title="Overwintering Monarchs on a Trunk by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5176/5517151997_32f8e8b1c8.jpg" width="333" height="500" alt="Overwintering Monarchs on a Trunk" /></a></p>
<p>There are several factors threatening the monarch migration. The biggest threat to them is illegal logging. A biosphere reserve protects the locations of largest colonies, but local villagers frequently cut wood in the forests. The hundred year old pines they cut are critical to Monarchs survival of the winter, because their trunk holds heat, and monarchs layer the tree trunk relying on this heat source.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517151947/" title="Fleeting Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5220/5517151947_95ddabcc93.jpg" width="333" height="500" alt="Fleeting Monarchs" /></a></p>
<p>Another major threat is climate change. The migration relies on the timing of key events, for instance flowers blooming in Texas as they key food source for monarchs, or milkweed plants hatching. Any shifting in the timing of these events could threaten the entire phenomenon. Other threats are due to overpopulation, where wild fields are plowed over and used for agriculture, pesticides that are used poison the land, etc. No one wants to kill the monarchs, but unfortunately, they end up being collateral damage. Hopefully, we can preserve this amazing sight for our future generations.</p>
<p><a href="http://www.flickr.com/photos/danospv/5517151897/" title="Flight of the Monarchs by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5135/5517151897_8c3e8ddbf3.jpg" width="500" height="333" alt="Flight of the Monarchs" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=364</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Emergence of a dragonfly</title>
		<link>http://danosipov.com/blog/?p=358</link>
		<comments>http://danosipov.com/blog/?p=358#comments</comments>
		<pubDate>Tue, 08 Mar 2011 13:01:58 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[dragonfly]]></category>
		<category><![CDATA[emergence]]></category>
		<category><![CDATA[metamorphosis]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=358</guid>
		<description><![CDATA[It&#8217;s been a few months since I&#8217;ve posted anything on the blog. It&#8217;s not because I&#8217;m slacking off &#8211; quite the opposite, I&#8217;ve been extremely busy. But there is a lot to write about, and the post activity will increase. Starting now.
It&#8217;s always mesmerizing to watch the process of metamorphosis. Last summer I had that [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a few months since I&#8217;ve posted anything on the blog. It&#8217;s not because I&#8217;m slacking off &#8211; quite the opposite, I&#8217;ve been extremely busy. But there is a lot to write about, and the post activity will increase. Starting now.</p>
<p>It&#8217;s always mesmerizing to watch the process of metamorphosis. Last summer I had that opportunity. We found a dragonfly larva on the trail near Lost Pond in White Mountains, New Hampshire. The larva was ready to hatch, so I took my spot with the camera, and got ready to film the emergence.</p>
<p><a href="http://www.flickr.com/photos/danospv/sets/72157626097405145/show/"><b>View the slideshow of the emergence</b></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5509237948/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5294/5509237948_5e073aa48f.jpg" width="336" height="500" alt="Emergence of a dragonfly" /></a></p>
<p>To my surprise, after drying off, the larva continued its journey inland, away from the water. I thought it was unusual, as most hatch just above the water, or right near it. This one was very determined, and all my attempts to place it on a photogenic plant failed.</p>
<p>After crawling three or four yards from the edge of the water, the larva reached a tree. Only then did I notice three other exuvia (empty shells left after the dragonfly emerges) on the trunk. This one crawled up to the side of one about 6 feet off the ground, and finally stopped.</p>
<p><a href="http://www.flickr.com/photos/danospv/5508639263/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5139/5508639263_4634e0a948_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5509237560/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5213/5509237560_56e6c860cc_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638747/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5298/5508638747_b818f9d49a_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638673/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5012/5508638673_507f8c738c_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638635/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5217/5508638635_c11eefc889_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638611/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5253/5508638611_77e31acd4f_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638533/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5252/5508638533_1b045f6acd_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638259/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5058/5508638259_8d1d67ace9_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638357/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5095/5508638357_4615cef771_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5509236892/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5180/5509236892_1a1f66c1fa_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638173/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5012/5508638173_db72c51625_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5508638149/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5132/5508638149_69cb92af4b_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/5509236740/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5094/5509236740_b4d24ebf02_t.jpg" width="67" height="100" alt="Emergence of a dragonfly" /></a></p>
<p>One other interesting thing to notice, is that the larva was missing the middle leg on the right side &#8211; lost to a predator earlier in its life. The emerged dragonfly was also missing a leg in the same spot.</p>
<p><a href="http://www.flickr.com/photos/danospv/5509236658/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5298/5509236658_e288cc578d.jpg" width="500" height="333" alt="Emergence of a dragonfly" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5508637935/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5135/5508637935_21dfc361c1.jpg" width="500" height="333" alt="Emergence of a dragonfly" /></a></p>
<p><a href="http://www.flickr.com/photos/danospv/5508639317/" title="Emergence of a dragonfly by danospv, on Flickr"><img src="http://farm6.static.flickr.com/5138/5508639317_a9fda3ff03.jpg" width="333" height="500" alt="Emergence of a dragonfly" /></a></p>
<p>Metamorphosis like this fascinates humans. We are amazed by this transformation for several reasons. Mostly because even in the twenty first century we still don&#8217;t understand it fully. But also because we see deep symbolism in the change that the individuals undergo through. Indeed, occasionally it takes a radical transformation, but what emerges is much grander than what was before.</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=358</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TYPO3 4.2 E-Commerce book review</title>
		<link>http://danosipov.com/blog/?p=351</link>
		<comments>http://danosipov.com/blog/?p=351#comments</comments>
		<pubDate>Sun, 11 Jul 2010 17:36:47 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[TYPO3]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[packt]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=351</guid>
		<description><![CDATA[ I was recently asked to review a new book from Packt Publishing, TYPO3 4.2 E-Commerce, written by Inese Liberte and Edgars Karlsons. TYPO3 is an excellent content management system designed for all types of websites, but there is very little information about building e-commerce shops &#8211; until now that is. While my TYPO3 experience [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/design-build-feature-rich-online-store-using-typo3-4-2-e-commerce/book?utm_source=danosipov.com&#038;utm_medium=bookrev&#038;utm_content=blog&#038;utm_campaign=mdb_003869"><img class="alignleft size-medium wp-image-350" style="margin: 5px;" title="TYPO3 4.2 E-Commerce book" src="http://danosipov.com/blog/wp-content/uploads/2010/07/TYPO3BookImage1-243x300.jpg" alt="TYPO3 4.2 E-Commerce book cover image" /></a> I was recently asked to review a new book from Packt Publishing,<em> <a href="http://www.packtpub.com/design-build-feature-rich-online-store-using-typo3-4-2-e-commerce/book?utm_source=danosipov.com&#038;utm_medium=bookrev&#038;utm_content=blog&#038;utm_campaign=mdb_003869" target="_blank">TYPO3 4.2 E-Commerce</a></em>, written by Inese Liberte and Edgars Karlsons. TYPO3 is an excellent content management system designed for all types of websites, but there is very little information about building e-commerce shops &#8211; until now that is. While my TYPO3 experience is very recent, my e-commerce background dates back to late 90&#8217;s &#8211; so I was very excited to read this book.</p>
<p>First, let me state that although the book title implies the book is written for TYPO3 version 4.2 (which is deprecated now), the content applies equally well for the most recent version of TYPO3 4.4 (same is the case for <a href="http://www.packtpub.com/typo3-4-3-multimedia-cookbook/book" target="_blank">my book</a>). Second, I expected this book to be targeted at TYPO3 integrators &#8211; programmers who need to set up shops. Instead, this book is aimed at small, DIY business owners, trying their foot in e-commerce. The preface promises to walk the reader through setting up the site from scratch to build a profitable web presence. This is somewhat conflicting, as I found that some knowledge about TYPO3 is already required to begin reading this book.</p>
<p>One major issue I stumbled across is the lack of coherent flow in the book. This causes the reader to jump back and forth, as some sections don&#8217;t make sense until after subsequent chapters are read. This also leads to a lot of repeated content, and in general makes the book tough to follow. Let me walk through the chapters of the book and provide a better path to follow.</p>
<p>Chapters 1 &amp; 2 cover basic TYPO3 installation, upgrades, templates, typoscript, and extension installation. Enough typoscript is given to confuse a newbie, so these chapters should only be read after some experience with TYPO3 basics. Likewise, if you&#8217;ve built a TYPO3 powered site before, you can safely skip this section.</p>
<p>Chapter 3 delves into the core of the book and describes the available commerce extensions. The description is very light, but the reader is instructed to consult the extension manuals for more information. The main extension chosen for the rest of the book is <a href="http://typo3.org/extensions/repository/view/tt_products/current/" target="_blank">tt_products</a>. Setting up a test paypal account is covered in detail, however most of the details of integrating it with TYPO3 and tt_products are left missing.</p>
<p>Chapter 4 starts by covering content import from CSV files, which is a bit premature at this point. It then explains adding new product using standard TYPO3 record editing features, and explains how to add a tt_products content element to a page. This is a chapter I would recommend rereading after experimenting with the shop setup.</p>
<p>Chapter 5 jumps into user registration, and covers frontend users and user groups. For commerce specific information, the book explains how to setup discounts for returning users.</p>
<p>The next chapter, chapter 6, diverges into menus, sitemap, navigation, and search. A lot of typoscript code is presented, but very little is explained, so the reader is expected to have a good foundation of typoscript at this point.</p>
<p>Chapter 7 provides a very light coverage of order management &#8211; something I would have liked to see more of, as it is arguably the most important step in the e-commerce flow after making a sale. No workflows, supply chains, or customer notifications are mentioned. The chapter also covers the basics of SSL and its integration into TYPO3. It also describes payment addins &#8211; something that was promised in chapter 3.</p>
<p>Chapter 8 gives an overview of the backend administration. Very little commerce specific information is given, and ideally this chapter should follow the installation chapter. Experienced TYPO3 users can safely skip this chapter.</p>
<p>Chapter 9 gives a top level of SEO optimization techniques. This is a topic that whole books could be, and have been, written on. Some TYPO3 specific information is given, but I would have preferred to see more.</p>
<p>Chapter 10 closes out the book by providing general tips for e-commerce, starting with basic business principles and ideas, and ending with site layout. This information is great for shop owners, but not for technical implementers. No TYPO3 specific information is given.</p>
<p>I was disappointed in not finding any information about TYPO3 and Magento integration, as that is a very popular topic. Unfortunately, its not covered at all in the book.</p>
<p>As a summary, if you were just starting out your TYPO3 e-commerce journey, I would recommend that you get some other introductory TYPO3 books (<a href="https://www.packtpub.com/beginning-typo3/book" target="_blank">Building websites with TYPO3 by Michael Peacock</a> and <a href="https://www.packtpub.com/typo3/book" target="_blank">TYPO3: Enterprise Content Management</a> at the minimum). Only then will you have a good foundation for this book, but then some of the chapters would become irrelevant.</p>
<p>If you want to see the language and type of information covered in the book, you can <a href="https://www.packtpub.com/sites/default/files/8525_Typo3%20eCommerce_SampleChapter_0.pdf" target="_blank">download a sample chapter</a>.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 456px; width: 1px; height: 1px; overflow: hidden;">
<h1 class="title">TYPO3: Enterprise Content Management</h1>
</div>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=351</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arachnophilia</title>
		<link>http://danosipov.com/blog/?p=344</link>
		<comments>http://danosipov.com/blog/?p=344#comments</comments>
		<pubDate>Sun, 27 Jun 2010 03:03:24 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[spiders]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=344</guid>
		<description><![CDATA[
Shooting spider webs can sometimes be tricky. Exposition is probably the toughest to get right. Camera meters are frequently fooled by the background, and the thin spider web ends up overexposed or blends into the background. What I found to work best is to position a bright web against a dark background, set the exposure [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/danospv/4599364029/" title="Weaving the web by danospv, on Flickr"><img src="http://farm4.static.flickr.com/3360/4599364029_9028ba8f30.jpg" width="357" height="500" alt="Weaving the web"></a></p>
<p>Shooting spider webs can sometimes be tricky. Exposition is probably the toughest to get right. Camera meters are frequently fooled by the background, and the thin spider web ends up overexposed or blends into the background. What I found to work best is to position a bright web against a dark background, set the exposure to -1.5, and then play by ear (or rather by eye), checking to see if the image is exposed correctly.</p>
<p><a href="http://www.flickr.com/photos/danospv/4242521709/" title="Enlightened Web by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4056/4242521709_256eda70b6_t.jpg" width="100" height="68" alt="Enlightened Web"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4242521815/" title="Hiding in the Spotlight by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4054/4242521815_f50a9b1137_t.jpg" width="100" height="65" alt="Hiding in the Spotlight"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/3825292232/" title="Captured by danospv, on Flickr"><img src="http://farm3.static.flickr.com/2638/3825292232_9c72981ecf_t.jpg" width="67" height="100" alt="Captured"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/2611023585/" title="Spider with a Mosquito by danospv, on Flickr"><img src="http://farm4.static.flickr.com/3237/2611023585_053f8625c8_t.jpg" width="100" height="67" alt="Spider with a Mosquito"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4237532621/" title="Morning Stretch by danospv, on Flickr"><img src="http://farm3.static.flickr.com/2686/4237532621_ce5027ed01_t.jpg" width="76" height="100" alt="Morning Stretch"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4576497597/" title="Jumping spider by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4050/4576497597_2437e5770b_t.jpg" width="78" height="100" alt="Jumping spider"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4579632503/" title="Spider in the air by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4031/4579632503_6658738637_t.jpg" width="100" height="66" alt="Spider in the air"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/3605409989/" title="Spider reaching for the sun by danospv, on Flickr"><img src="http://farm4.static.flickr.com/3562/3605409989_a4cbf31692_t.jpg" width="100" height="75" alt="Spider reaching for the sun"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4672189943/" title="Jumping Spider by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4055/4672189943_1bee99f977_t.jpg" width="100" height="65" alt="Jumping Spider"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/3625983947/" title="Jumping Spider by danospv, on Flickr"><img src="http://farm4.static.flickr.com/3372/3625983947_02aedb52d3_t.jpg" width="100" height="75" alt="Jumping Spider"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4672816256/" title="Spider with prey by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4033/4672816256_23b8847ea3_t.jpg" width="100" height="65" alt="Spider with prey"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4675310951/" title="Set for the night by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4046/4675310951_08888e7641_t.jpg" width="100" height="67" alt="Set for the night"></a>&nbsp;<a href="http://www.flickr.com/photos/danospv/4672816436/" title="Jumping Spider by danospv, on Flickr"><img src="http://farm2.static.flickr.com/1274/4672816436_585e68b602_t.jpg" width="70" height="100" alt="Jumping Spider"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=344</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The future according to Facebook</title>
		<link>http://danosipov.com/blog/?p=340</link>
		<comments>http://danosipov.com/blog/?p=340#comments</comments>
		<pubDate>Thu, 22 Apr 2010 04:36:20 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[f8]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[open graph]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=340</guid>
		<description><![CDATA[I’m back from the f8 conference in San Francisco, and here are some of my thoughts and observations.
Facebook introduced some new ideas, and expanded the existing products. The big announcements were centered around the Open Graph. It essentially allows you to treat any content on the web (identifiable by a unique URL) as an object [...]]]></description>
			<content:encoded><![CDATA[<p>I’m back from the f8 conference in San Francisco, and here are some of my thoughts and observations.</p>
<p>Facebook introduced some new ideas, and expanded the existing products. The big announcements were centered around the Open Graph. It essentially allows you to treat any content on the web (identifiable by a unique URL) as an object in the graph. Users can interact with objects, “liking” them and thereby adding them to their profile and subscribing to status updates. This essentially takes Facebook interaction into the open web. It will be interesting to see how this concept evolves, as Facebook definitely hasn’t thought it through completely – specifically issues with duplicated objects from different sources.</p>
<p>Implementation of Open Graph objects is very simple, done through meta tags identifying the object and linking them to the administrator profile or application. Facebook also provides simple social widgets, specifically the like button, activity stream, and recommendations list. These widgets can be included as a simple iframe on any page, and show user’s friends interaction with the site, without requiring the user to login through Facebook Connect, as was previously the case. You can see examples of social widgets on <a href ="http://cnn.com">CNN.com</a></p>
<p>Another big announcement was the Graph API. This is essentially a rewrite of the old API methods available on the Facebook in a simple, REST based fashion. The API centers on the concepts of objects and connections, and is self described through introspection, which allows the developer to see the connections available for the object. The object can be anything within the facebook system – and by extension on the open web through Open Graph. Furthermore, real time API updates ping your system when there are updates to the user data, so that you can take appropriate action. Authentication is based on oAuth 2.0 standard, and is much simpler than current implementation. Permissions are now simplified in one dialog box presented to the end user asking for very granular permission level the application needs.</p>
<p>Smaller, but still crucial updates came in areas of search, Facebook credits, analytics &amp; insights, policy, and more. It’s too much to discuss here, but Open Graph has been the theme of the conference, and all updates center around the idea. Facebook is clearly moving in this direction, and is using its highly active user base to change the way we interact with the web.</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=340</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>And the Snow Keeps Falling</title>
		<link>http://danosipov.com/blog/?p=336</link>
		<comments>http://danosipov.com/blog/?p=336#comments</comments>
		<pubDate>Thu, 11 Feb 2010 01:30:07 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[snow]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=336</guid>
		<description><![CDATA[
Snowpocalypse, 2010

&#160;&#160;&#160;
]]></description>
			<content:encoded><![CDATA[<div align="center"><a href="http://www.flickr.com/photos/7542705@N08/4347716528/" title="Stop by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4053/4347716528_becf1c8a4e.jpg" width="333" height="500" alt="Stop" /></a></div>
<p>Snowpocalypse, 2010</p>
<p>
<a href="http://www.flickr.com/photos/7542705@N08/4346970083/" title="Twenty Five by danospv, on Flickr"><img src="http://farm3.static.flickr.com/2783/4346970083_85cd4546ec_t.jpg" width="100" height="67" alt="Twenty Five" /></a>&nbsp;<a href="http://www.flickr.com/photos/7542705@N08/4347716656/" title="One Lane Bridge by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4034/4347716656_1a06bd8a38_t.jpg" width="100" height="67" alt="One Lane Bridge" /></a>&nbsp;<a href="http://www.flickr.com/photos/7542705@N08/4346970431/" title="River by danospv, on Flickr"><img src="http://farm5.static.flickr.com/4026/4346970431_28ed3bd320_t.jpg" width="100" height="67" alt="River" /></a>&nbsp;<a href="http://www.flickr.com/photos/7542705@N08/4347716856/" title="Bridge column by danospv, on Flickr"><img src="http://farm3.static.flickr.com/2726/4347716856_f9c450a05b_t.jpg" width="67" height="100" alt="Bridge column" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=336</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multimedia cookbook</title>
		<link>http://danosipov.com/blog/?p=334</link>
		<comments>http://danosipov.com/blog/?p=334#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:39:37 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[TYPO3]]></category>
		<category><![CDATA[book]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=334</guid>
		<description><![CDATA[My book is about to be released, and some promotional materials have been released into the open to help readers evaluate the type of material covered, and writing style. Here are the tutorials that have been released:

TYPO3 for Connecting External APIs: Flickr and Youtube
Rendering Images in TYPO3 4.3: Part 1
Rendering Images in TYPO3 4.3: Part [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/typo3-4-3-multimedia-cookbook/book/?utm_source=js_typo3_cookbook_abr2_0110&amp;utm_medium=content&amp;utm_campaign=janice#indetail">My book</a> is about to be released, and some promotional materials have been released into the open to help readers evaluate the type of material covered, and writing style. Here are the tutorials that have been released:</p>
<ul>
<li><a href="http://www.packtpub.com/article/typo3-connecting-external-apis-flicker-and-youtube">TYPO3 for Connecting External APIs: Flickr and Youtube</a></li>
<li><a href="http://www.packtpub.com/article/rendering-images-in-typo3-4.3-part1">Rendering Images in TYPO3 4.3: Part 1</a></li>
<li><a href="http://www.packtpub.com/article/rendering-images-in-typo3-4.3-part2">Rendering Images in TYPO3 4.3: Part 2</a></li>
</ul>
<p>I&#8217;m curious as to how well this material represents the book. Let me know your thoughts!</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=334</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Caching in extensions</title>
		<link>http://danosipov.com/blog/?p=322</link>
		<comments>http://danosipov.com/blog/?p=322#comments</comments>
		<pubDate>Sun, 10 Jan 2010 03:57:31 +0000</pubDate>
		<dc:creator>Dan Osipov</dc:creator>
				<category><![CDATA[TYPO3]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[New in 4.3]]></category>

		<guid isPermaLink="false">http://danosipov.com/blog/?p=322</guid>
		<description><![CDATA[TYPO3 4.3 features a new caching framework, which has been backported from FLOW3. The framework (should one choose to use it &#8211; more on that later) allows placement of default TYPO3 caches in DB tables, files, memcached, APC, or any other backend that can be created by implementing a PHP interface.
But even more &#8211; TYPO3 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://typo3.org/download/release-notes/typo3-43/">TYPO3 4.3</a> features a new caching framework, which has been backported from <a href="http://flow3.typo3.org/">FLOW3</a>. The framework (should one choose to use it &#8211; more on that later) allows placement of default TYPO3 caches in DB tables, files, memcached, APC, or any other backend that can be created by implementing a PHP interface.</p>
<p>But even more &#8211; TYPO3 extensions can easily leverage this framework to cache their output, configuration, or anything else they need to cache. Furthermore, the choice of backend is left up to the individual installations. Some may decide to use DB tables, others files, yet some others will go with an in-memory caching system, like memcached, or APC. Choice of storage would be completely transparent to the extension, which will simply use the framework regardless of the backend.</p>
<p>Given all the caches TYPO3 offers, why would you want your own cache? Reasons vary. If your extension is a USER_INT object (which is not cached), but it queries the database, or external resources, you should use caching in your extension. Should the extension be used on a high traffic page, you don&#8217;t want it to become the point of contention.</p>
<p>In this simple guide, I&#8217;ll cover some basics of enabling caching in your extensions. I&#8217;ll assume you&#8217;re running TYPO3 of at least version 4.3.0, and your extension lists this as a dependency. If it doesn&#8217;t, make sure to surround all code using the caching framework with checks for TYPO3 version (use t3lib_div::compat_version() function), and test on all supported TYPO3 versions.</p>
<p>First you need to define the cache. Add this to the ext_localconf.php:</p>
<p><code>// If cache is not already defined, define it<br />
if (!is_array($TYPO3_CONF_VARS['SYS']['caching']<br />
&nbsp;&nbsp;&nbsp;['cacheConfigurations']['my_extension'])) {<br />
&nbsp;&nbsp;&nbsp;$TYPO3_CONF_VARS['SYS']['caching']<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;['cacheConfigurations']['my_extension'] = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'backend' =&gt; 't3lib_cache_backend_DbBackend',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'options' =&gt; array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cacheTable' =&gt; 'tx_myextension_cache',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'tagsTable' =&gt; 'tx_myextension_cache_tags',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br />
&nbsp;&nbsp;&nbsp;);<br />
}</code></p>
<p>We use the database cache as the default. So we need to define the cache tables:</p>
<p><code>CREATE TABLE tx_myextension_cache (<br />
&nbsp;&nbsp;&nbsp;id int(11) NOT NULL auto_increment,<br />
&nbsp;&nbsp;&nbsp;identifier varchar(128) NOT NULL DEFAULT '',<br />
&nbsp;&nbsp;&nbsp;crdate int(11) unsigned NOT NULL DEFAULT '0',<br />
&nbsp;&nbsp;&nbsp;content mediumtext,<br />
&nbsp;&nbsp;&nbsp;lifetime int(11) unsigned NOT NULL DEFAULT '0',<br />
&nbsp;&nbsp;&nbsp;PRIMARY KEY (id),<br />
&nbsp;&nbsp;&nbsp;KEY cache_id (`identifier`)<br />
);<br />
CREATE TABLE tx_myextension_cache_tags (<br />
&nbsp;&nbsp;&nbsp;id int(11) NOT NULL auto_increment,<br />
&nbsp;&nbsp;&nbsp;identifier varchar(128) NOT NULL DEFAULT '',<br />
&nbsp;&nbsp;&nbsp;tag varchar(128) NOT NULL DEFAULT '',<br />
&nbsp;&nbsp;&nbsp;PRIMARY KEY (id),<br />
&nbsp;&nbsp;&nbsp;KEY cache_id (`identifier`),<br />
&nbsp;&nbsp;&nbsp;KEY cache_tag (`tag`)<br />
);</code></p>
<p>Of course, any installation can overwrite the default definition by writing the definition in localconf.php:</p>
<p><code>$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']<br />
&nbsp;&nbsp;&nbsp;['my_extension'] = array(<br />
&nbsp;&nbsp;&nbsp;'backend' =&gt; 't3lib_cache_backend_MemcachedBackend',<br />
&nbsp;&nbsp;&nbsp;'options' =&gt; array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'servers' =&gt; array('127.0.0.1:11211'),<br />
&nbsp;&nbsp;&nbsp;)<br />
);</code></p>
<p>Since the ext_localconf.php in our extension is included after localconf.php, the extension needs to check that the caching definition is not already defined.<br />
Now in your extension you need to create and initialize the cache object:</p>
<p><code>if (TYPO3_UseCachingFramework) {<br />
&nbsp;&nbsp;&nbsp;// Create the cache<br />
&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$GLOBALS['typo3CacheFactory']-&gt;create(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'my_extension',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'t3lib_cache_frontend_VariableFrontend',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['my_extension']['backend'],<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['my_extension']['options']<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
&nbsp;&nbsp;&nbsp;} catch(t3lib_cache_exception_DuplicateIdentifier $e) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// do nothing, the cache already exists<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;// Initialize the cache<br />
&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;cache = $GLOBALS['typo3CacheManager']-&gt;getCache(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'my_extension'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />
&nbsp;&nbsp;&nbsp;} catch(t3lib_cache_exception_NoSuchCache $e) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Unable to load<br />
&nbsp;&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p><i>$this->cache</i> will now hold the cache for your extension. You can now check if the cache has a certain ID:<br />
<i>$this-&gt;cache-&gt;has($id);</i><br />
If it does, retrieve it:<br />
<i>$this-&gt;cache-&gt;get($id);</i><br />
If not, then generate the content and store it:<br />
<i>$this-&gt;cache-&gt;set($id, $content, $tags, $lifetime);</i></p>
<p>See the interface for more operations you can perform on the cache. The greatest thing about the caching framework is the fact that the specific caching backend is completely transparent to you &#8211; and each installation can use whatever method they deem appropriate, without any changes to your extension.</p>
]]></content:encoded>
			<wfw:commentRss>http://danosipov.com/blog/?feed=rss2&amp;p=322</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

