<?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>Brandon&#039;s Blog &#187; Web Applications</title>
	<atom:link href="http://www.brandonturner.net/blog/category/web_apps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonturner.net/blog</link>
	<description>Random thoughts on web applications, software development and Linux</description>
	<lastBuildDate>Mon, 02 Jan 2012 22:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Doctrine 1.1 with Symfony 1.2</title>
		<link>http://www.brandonturner.net/blog/2009/05/doctrine11-with-symfony12/</link>
		<comments>http://www.brandonturner.net/blog/2009/05/doctrine11-with-symfony12/#comments</comments>
		<pubDate>Tue, 05 May 2009 01:05:40 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=270</guid>
		<description><![CDATA[Doctrine 1.1 doesn't come with Symfony 1.2, however it was recently released stable.  This describes how to use Doctrine 1.1 with Symfony 1.2 including patches.]]></description>
			<content:encoded><![CDATA[<p>I recently started a new project using the <a href="http://www.symfony-project.org">Symfony PHP Framework</a>.  I&#8217;ve used Symfony before and love it.  In the past I&#8217;ve used Propel, but as Symfony now fully supports <a href="http://www.doctrine-project.org">Doctrine</a> and Doctrine looks very promising, I decided to give it a shot for my latest project.</p>
<p>Symfony 1.2 currently uses Doctrine 1.0.  Doctrine 1.1 was <a href="http://www.doctrine-project.org/blog/doctrine-1-1-released">released</a> in March.  Symfony 1.3 will support Doctrine 1.1, but won&#8217;t be released until <a href="http://www.symfony-project.org/blog/2009/01/25/about-symfony-1-3">November</a>.</p>
<p>Since I&#8217;m starting a new project, I wanted to try to use the latest version of Doctrine.  I&#8217;ll be honest, I don&#8217;t have a great reason for doing this other then the pain I went through migrating an old project (with lots of custom model stuff) from Propel 1.2 to Propel 1.3.  I understand this is an apples to oranges comparison, however its the only motivation I&#8217;ve got.  Feel free to stop reading now.</p>
<p>Overall the Symfony developers have made it extremely easy to use Doctrine 1.1 with Symfony 1.2.  However, given this is an <strong>unsupported</strong> configuration, they don&#8217;t back-port any patches related to Doctrine 1.1 from the Symfony 1.3 branch to sf 1.2.  In this post I will try to catalog the changes and provide a back-port patch you can use to integrate Doctrine 1.1 into your sf 1.2 projects.</p>
<h4>Related Postings</h4>
<p>Here are some pages/tickets/changesets related to Doctrine 1.1 with Symfony.  If I&#8217;m missing something, please leave me a comment below and I&#8217;ll update this ASAP!</p>
<table>
<tr class="first">
<td><a href="http://www.symfony-project.org/blog/2009/01/12/call-the-expert-using-a-custom-version-of-doctrine">Symfony Blog</a></td>
<td>Call the expert: Using a custom version of Doctrine</td>
</tr>
<tr>
<td><a href="http://trac.symfony-project.org/ticket/5667">Ticket 5667</a></td>
<td>In generated forms, Doctrine 1.1 does not save model after linking relations.</td>
</tr>
<tr>
<td><a href="http://trac.symfony-project.org/ticket/5741">Ticket 5741</a></td>
<td>CLI doesn&#8217;t use the right installation of Doctrine</td>
</tr>
<tr>
<td><a href="http://trac.symfony-project.org/ticket/6285">Ticket 6285</a></td>
<td>Form generator, saving linked objects problem (SF 1.2 + Doctrine 1.1)</td>
</tr>
<tr>
<td><a href="http://trac.symfony-project.org/changeset/16508">Changeset 16508</a></td>
<td>fix for admin gen and Doctrine 1.1 link()/unlink() methods (fixes <a href="http://trac.symfony-project.org/ticket/5667">#5667</a>, <a href="http://trac.symfony-project.org/ticket/6285">#6285</a>)</td>
</tr>
<tr>
<td><a href="http://trac.symfony-project.org/ticket/6373">Ticket 6373</a></td>
<td>sfDoctrineGuardPlugin support Doctrine 1.1</td>
</tr>
</table>
<h4>Installing Doctrine 1.1</h4>
<p>To get started using Doctrine 1.1, you&#8217;ll need to download it.  Jonathan Wage provided instructions <a href="http://www.symfony-project.org/blog/2009/01/12/call-the-expert-using-a-custom-version-of-doctrine">here</a> which I&#8217;ll reproduce below.</p>
<p>From your Symfony project&#8217;s root folder:</p>
<div class="prompt">
$ <span class="cmd">cd lib/vendor</span><br />
$ <span class="cmd">svn co http://svn.doctrine-project.org/branches/1.1/lib doctrine</span>
</div>
<p>Now change the location of the Doctrine lib path by editing your <code>ProjectConfiguration::setup()</code> method to look similar to:</p>
<pre class="brush: php; title: ; notranslate">
public function setup()
{
  sfConfig::set('sfDoctrinePlugin_doctrine_lib_path', sfConfig::get('sf_lib_dir') . '/vendor/doctrine/Doctrine.php');
}
</pre>
<h4>Patch Symfony Library</h4>
<p>Now you need to patch the Symfony library with the back-ported changes related to Doctrine from the Symfony 1.3 branch.  This patch is very simple, and currently only effects one file.</p>
<p>Navigate to your Symfony lib directory.  Depending on how you started your project, this is probably the <code>lib/symfony</code> directory in your project.</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://www.bltweb.net/patches/symfony-1.2.7-doctrine-1.1.patch">http://www.bltweb.net/patches/symfony-1.2.7-doctrine-1.1.patch</a></span><br />
$ <span class="cmd">patch -p0 &lt; symfony-1.2.7-doctrine-1.1.patch</span>
</div>
<p>Now rebuild your model forms.  From your project&#8217;s root directory:</p>
<div class="prompt">
$ <span class="cmd">php symfony doctrine:build-forms</span><br />
$ <span class="cmd">php symfony cc</span>
</div>
<h4>Patch sfDoctrineGuardPlugin</h4>
<p>If you use the <code>sfDoctrineGuardPlugin</code> you will need to apply another patch.</p>
<p>From your project&#8217;s root directory:</p>
<div class="prompt">
$ <span class="cmd">wget <a href="http://www.bltweb.net/patches/sfDoctrineGuardPlugin-doctrine-1.1.patch">http://www.bltweb.net/patches/sfDoctrineGuardPlugin-doctrine-1.1.patch</a></span><br />
$ <span class="cmd">patch -p0 &lt; sfDoctrineGuardPlugin-doctrine-1.1.patch</span>
</div>
<h4>Finished!</h4>
<p>You should now be able to use Doctrine 1.1 with Symfony 1.2.  I haven&#8217;t run into any problems using it, however I&#8217;ve just gotten started with my new project and haven&#8217;t done much of anything yet!  If you have troubles let me know.</p>
<p>For anyone on Gentoo, I have a <a href="http://svn.bltweb.net/repos/public/gentoo_overlay/dev-php5/symfony/symfony-1.2.7-r2.ebuild">symfony ebuild</a> in my <a href="/blog/gentoo-overlay/">Gentoo Overlay</a> that will install Symfony 1.2 with Doctrine 1.1 support for you.</p>
<p>I&#8217;ll try to keep this post updated if I come across anything else that needs to change when using Doctrine 1.1 with Symfony 1.2.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/05/doctrine11-with-symfony12/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Reloading reCAPTCHA with error via Javascript</title>
		<link>http://www.brandonturner.net/blog/2009/02/reload_recaptcha_with_error/</link>
		<comments>http://www.brandonturner.net/blog/2009/02/reload_recaptcha_with_error/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 21:04:36 +0000</pubDate>
		<dc:creator>Brandon</dc:creator>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.brandonturner.net/blog/?p=104</guid>
		<description><![CDATA[Today I needed to add a captcha to a web form used to send emails. Ordinarily this is pretty simple using the reCAPTCHA service. There was only one problem: the form was validated and submitted via AJAX rather than a regular HTTP post. The reCAPTCHA client API provides a reload javascript method that will grab [...]]]></description>
			<content:encoded><![CDATA[<p>Today I needed to add a captcha to a web form used to send emails.  Ordinarily this is pretty simple using the <a href="http://www.recaptcha.net">reCAPTCHA</a> service.  There was only one problem: the form was validated and submitted via AJAX rather than a regular HTTP post.</p>
<p>The reCAPTCHA <a href="http://recaptcha.net/apidocs/captcha/client.html">client API</a> provides a <code>reload</code> javascript method that will grab a new set of words for the user to decode.  It was easy enough to display a small error message above the reCAPTCHA div and call this method when the user responds incorrectly.</p>
<p>In a typical setup, as described in the reCAPTCHA <a href="http://recaptcha.net/apidocs/captcha/client.html">client API</a>, the standard theme can display an error message when the user responds incorrectly.  This is done by appending an <code>error</code> URL parameter to the challenge.  The error message I was adding via javascript was showing up above the reCAPTCHA module rather than just above the text box.  I wanted to display the error message included in the standard reCAPTCHA theme.</p>
<p>Though I&#8217;m sure there are several ways to accomplish my goal, I settled on a very easy, but very unsupported solution (read: HACK):</p>
<p>The message the standard template displays just above the input textbox is controlled by a class set on the <code>recaptcha_widget_div</code> element.  A class of <code style="color: #008000">recaptcha_nothad_incorrect_sol</code> causes &#8220;Type the two words:&#8221; or &#8220;Type what you hear:&#8221; to be displayed while a <code style="color: #008000">recaptcha_had_incorrect_sol</code> class causes &#8220;Incorrect. Try again.&#8221; to be displayed.  So to display the default error message all you need to do is change the class of the <code>recaptcha_widget_div</code> element.</p>
<p>Trying to mix this with the reCAPTCHA <code>reload</code> method doesn&#8217;t work as you might expect.  The <code>reload</code> method causes an AJAX request to be sent to the reCAPTCHA server.  When the response arrives, the reCAPTCHA module is updated.  If you modify the class before the response arrives, your updated class will be overwritten.  To fix this, you can override the default response callback <code>Recaptcha.finish_reload</code>.</p>
<p>So my final solution (hack) looked something like this (please note, the page in question was already loading the prototype library so I used it):</p>
<pre class="brush: jscript; title: ; notranslate">
if(typeof Recaptcha.old_finish_reload === 'undefined') {
   Recaptcha.old_finish_reload = Recaptcha.finish_reload;
   Recaptcha.finish_reload = function(a, b, c, d) {
      Recaptcha.old_finish_reload(a, b, c, d);
      $('recaptcha_widget_div').removeClassName('recaptcha_nothad_incorrect_sol');
      $('recaptcha_widget_div').addClassName('recaptcha_had_incorrect_sol');
   };
}
Recaptcha.reload();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.brandonturner.net/blog/2009/02/reload_recaptcha_with_error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

