<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<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/"
	>

<channel>
	<title>eggdrop.ch blog</title>
	<link>http://eggdrop.ch/blog</link>
	<description>Texts and open source software</description>
	<pubDate>Sun, 17 Feb 2008 15:23:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>Compare files in two directories</title>
		<link>http://eggdrop.ch/blog/2008/02/17/compare-directories/</link>
		<comments>http://eggdrop.ch/blog/2008/02/17/compare-directories/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 15:23:11 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Programming</category>
	<category>English</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2008/02/17/compare-directories/</guid>
		<description><![CDATA[Sometimes I have two versions of a directory stored on my computer. When cleaning up, it is handy to be able to see which files are in common and which files differ. To do that, I wrote a small Python script that compares two directories. The script also shows duplicate files in each of the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I have two versions of a directory stored on my computer. When cleaning up, it is handy to be able to see which files are in common and which files differ. To do that, I wrote a small Python script that compares two directories. The script also shows duplicate files in each of the directories. MD5 checksums are used to determine if files are equal – no file name comparison is used. Also, the script goes recursively into subdirectories.</p>
<p><a href="/downloads/compare-directories/compare.py">Download script (compare.py)</a></p>
<p>The usage is simple:</p>
<pre>Usage: compare.py [-d] dir1 dir2
Compares files in two directories, based on their MD5 checksum.
-d: Debug. Prints the MD5 checksum of every file to stderr.
</pre>
<p>Sample usage and output:</p>
<pre>% <b>python compare.py dir1 dir2</b>
Duplicate files
============================================================

dir1/file 2.pdf
dir1/file.pdf

Common files
============================================================

dir1/image.png
dir2/image.png

dir1/test.pdf
dir2/subdir/foobar.pdf

Files only in dir1
============================================================

dir1/hello.jpg

Files only in dir2
============================================================

dir2/something.jpg
dir2/video.mov
</pre>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2008/02/17/compare-directories/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>The new SSL error pages in Firefox 3 suck.</title>
		<link>http://eggdrop.ch/blog/2007/11/20/the-new-ssl-error-pages-in-firefox-3-suck/</link>
		<comments>http://eggdrop.ch/blog/2007/11/20/the-new-ssl-error-pages-in-firefox-3-suck/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 16:30:13 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Web</category>
	<category>English</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2007/11/20/the-new-ssl-error-pages-in-firefox-3-suck/</guid>
		<description><![CDATA[Until now, if you had a private website which required a login or collected private data (for example a small online shop), you could create a self-signed certificate or a certificate signed by http://www.cacert.org/ for free. There would be a somewhat confusing error message in all browsers, but that wasn&#8217;t a big issue.
Now, let&#8217;s see [...]]]></description>
			<content:encoded><![CDATA[<p>Until now, if you had a private website which required a login or collected private data (for example a small online shop), you could create a self-signed certificate or a certificate signed by <a href="http://www.cacert.org/">http://www.cacert.org/</a> for free. There would be a somewhat confusing error message in all browsers, but that wasn&#8217;t a big issue.</p>
<p>Now, let&#8217;s see what they did in Firefox 3 (Beta 1):<br />
<img src="http://eggdrop.ch/blog/wp-content/ssl.png" alt="SSL in Firefox 3" width="80%" /></p>
<p>The website will not be displayed and there&#8217;s only a small link at the bottom (which most people won&#8217;t see). Clicking this unfriendly link requires you to confirm two additional questions and maybe do additional settings. In short, most people won&#8217;t be able to access your site at all.</p>
<p>So what are possible consequences of this change for private websites?</p>
<ul>
<li>They will stop using SSL. That&#8217;s the easiest way. Who cares about encryption? The user won&#8217;t notice anyway.</li>
<li>They will use a certificate from <a href="http://cert.startcom.org/ ">http://cert.startcom.org/</a>, which is the only certificate issuer I know which should not display this nasty error message. Unfortunately, if you want wildcards (i.e. make the certificate valid for all your subdomains), you still need to pay for a &#8220;Class 2&#8243; certificate (<a href="http://www.startssl.com ">http://www.startssl.com/</a>), and most providers don&#8217;t give you enough IP addresses, but that&#8217;s another issue. So there&#8217;s no free solution for wildcard domains.</li>
</ul>
<p>What could be done to avoid this problem?</p>
<ul>
<li>In my opinion, encryption and trust should be separated. It is more secure to visit a website which has encryption enabled than any other website without encryption. Ideally, every website would be transferred encrypted. If someone wants trust, i.e. allow people to see that your server is really your server, then he or she could buy a certificate. In the end, you can&#8217;t really trust <i>any</i> website (what, if the server has been compromised?), but encryption is always a good thing (your provider or your network administrator can&#8217;t read the data).</li>
<li>CAcert should be included in mainstream browsers, which unfortunately <a href="http://wiki.cacert.org/wiki/InclusionStatus">doesn&#8217;t seem to be the case</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=215243">not even in Firefox</a>.</li>
<li>There should be more free certificate issuers. You shouldn&#8217;t have to pay for encryption (or trust).</li>
</ul>
<p>What&#8217;s your opinion about this topic?
</p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2007/11/20/the-new-ssl-error-pages-in-firefox-3-suck/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Another reason why Mac OS X is better than Windows</title>
		<link>http://eggdrop.ch/blog/2007/02/27/why-macosx-is-better/</link>
		<comments>http://eggdrop.ch/blog/2007/02/27/why-macosx-is-better/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 17:51:57 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>English</category>
	<category>Software</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2007/02/27/why-macosx-is-better/</guid>
		<description><![CDATA[Here&#8217;s a comparison of the &#8220;Mouse Precision Error Coefficient&#8221; (from Pfeiffer Consulting, lower is better):

You can really feel the difference when working with both systems.
Found via digg.
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a comparison of the &#8220;Mouse Precision Error Coefficient&#8221; (from <a href="http://www.pfeifferreport.com/trends/Vista_UIF_Rep.pdf">Pfeiffer Consulting</a>, lower is better):</p>
<p><img src="http://eggdrop.ch/blog/wp-content/moue_error.png" alt="Mouse Precision Error Coefficient" /></p>
<p>You can really feel the difference when working with both systems.</p>
<p>Found via <a href="http://digg.com/microsoft/Vista_s_UI_is_a_step_back_analyst_says">digg</a>.</p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2007/02/27/why-macosx-is-better/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Django newforms: How to create dynamic forms</title>
		<link>http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/</link>
		<comments>http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 19:46:37 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Web</category>
	<category>Programming</category>
	<category>English</category>
	<category>Django</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/</guid>
		<description><![CDATA[Django is a great framework for building web applications. Recently they started to create the newforms library that makes it easy to handle forms.
But the newforms library works only for static forms. Forms that have a fixed number of fields. What I wanted to do, is create a page that allows you to edit multiple [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.djangoproject.com/">Django</a> is a great framework for building web applications. Recently they started to create the newforms library that makes it easy to handle forms.</p>
<p>But the newforms library works only for static forms. Forms that have a fixed number of fields. What I wanted to do, is create a page that allows you to edit multiple instances of a model at once. It should be similar to <tt>edit_inline</tt>, but there should be a JavaScript link that allows you to add another instance of the object.</p>
<p>That's why I have written classes that make it possible to handle this type of forms using Django. No AJAX is utilized to make this work.</p>
<p><a id="more-34"></a></p>
<h3>What will it look like?</h3>
<p><img src="/downloads/dynamicforms/dynamicforms.png" alt="dynamicforms" style="width:100%; max-width:665px;" /></p>
<h3>Getting started</h3>
<p><b>Note:</b> This howto won't work on Django 0.95. You need a recent SVN checkout of Django (I was using revision 4389).</p>
<p>I created a Python and JavaScript file that make it pretty easy to create dynamic forms. To be able to use my samples, you will have to download them and put the Python file into your application directory and the JavaScript file into your media directory:</p>
<ul>
<li><a href="/downloads/dynamicforms/dynamicforms.py">dynamicforms.py</a></li>
<li><a href="/downloads/dynamicforms/dynamicforms.js">dynamicforms.js</a></li>
</ul>
<p>Now let me show you have to use dynamicforms. Let's start with a simple model (<b>models.py</b>):</p>
<div class="hilite-container">
<div class="igBar"><span id="lpython-7"><a href="#" onclick="javascript:showCodeTxt('python-7'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="python-7">
<div class="python">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">db</span> <span style="color: #ff7700;font-weight:bold;">import</span> models</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Example model</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">class</span> Page<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; title = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>maxlength=<span style="color: #ff4500;color:#800000;">200</span>, core=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; content = models.<span style="color: black;">TextField</span><span style="color: black;">&#40;</span>null=<span style="color: #008000;">True</span>, blank=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">class</span> Admin:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Now the view (<b>views.py</b>). I'll first import some stuff and create a form:</p>
<div class="hilite-container">
<div class="igBar"><span id="lpython-8"><a href="#" onclick="javascript:showCodeTxt('python-8'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="python-8">
<div class="python">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span> <span style="color: #ff7700;font-weight:bold;">import</span> RequestContext</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">http</span> <span style="color: #ff7700;font-weight:bold;">import</span> HttpResponseRedirect</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">shortcuts</span> <span style="color: #ff7700;font-weight:bold;">import</span> render_to_response</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> newforms as forms</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">import</span> models</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">import</span> dynamicforms</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">class</span> PageForm<span style="color: black;">&#40;</span>dynamicforms.<span style="color: black;">Form</span><span style="color: black;">&#41;</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; TEMPLATE = <span style="color: #483d8b;">'form.html'</span> <span style="color: #808080; font-style: italic;"># Path to the form template</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; CORE = <span style="color: black;">&#40;</span><span style="color: #483d8b;">'title'</span>,<span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; title = forms.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;color:#800000;">200</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; content = forms.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>widget=forms.<span style="color: black;">Textarea</span><span style="color: black;">&#40;</span>attrs=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'rows'</span>: <span style="color: #ff4500;color:#800000;">5</span>, <span style="color: #483d8b;">'cols'</span>: <span style="color: #ff4500;color:#800000;">60</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>, required=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Note that I specified the template that will be used to render the form and the core fields, in this example <tt>title</tt>. Core fields are required to be able to add new elements.</p>
<p>The form template (<b>form.html</b>) itself is simple:</p>
<div class="hilite-container">
<div class="igBar"><span id="lhtml-9"><a href="#" onclick="javascript:showCodeTxt('html-9'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="html-9">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"form-row"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{{ form.title.errors }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label</span> <span style="color: #000066;">for</span>=<span style="color: #ff0000;">"{{ form.title.auto_id }}"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"required"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{{ form.title.label }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label&gt;</span></span>{{ form.title }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"form-row"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{{ form.content.errors }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label</span> <span style="color: #000066;">for</span>=<span style="color: #ff0000;">"{{ form.content.auto_id }}"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>{{ form.content.label }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label&gt;</span></span>{{ form.content }}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Feel free to style your form as you want. There are no restrictions.</p>
<p>Now let me add the actual view (<b>views.py</b>):</p>
<div class="hilite-container">
<div class="igBar"><span id="lpython-10"><a href="#" onclick="javascript:showCodeTxt('python-10'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="python-10">
<div class="python">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Example using a custom form (PageForm) and a form template</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">def</span> dynamicform_using_form<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> request.<span style="color: black;">method</span> == <span style="color: #483d8b;">'POST'</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_forms = PageForm.<span style="color: black;">get_forms</span><span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_data = <span style="color: black;">&#91;</span>page_form.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'from_template'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> page_form <span style="color: #ff7700;font-weight:bold;">in</span> page_forms<span style="color: black;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> page_forms.<span style="color: black;">are_valid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> form <span style="color: #ff7700;font-weight:bold;">in</span> page_forms:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Do something with your data here</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> form.<span style="color: #008000;">id</span>, form.<span style="color: black;">cleaned_data</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> HttpResponseRedirect<span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Get your initial data here</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_data = <span style="color: black;">&#91;</span>PageForm<span style="color: black;">&#40;</span>initial=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'title'</span>:page.<span style="color: black;">title</span>, <span style="color: #483d8b;">'content'</span>:page.<span style="color: black;">content</span><span style="color: black;">&#125;</span>, <span style="color: #008000;">id</span>=page.<span style="color: #008000;">id</span><span style="color: black;">&#41;</span>.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'from_template'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> page <span style="color: #ff7700;font-weight:bold;">in</span> models.<span style="color: black;">Page</span>.<span style="color: black;">objects</span>.<span style="color: black;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">'edit.html'</span>, <span style="color: black;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'page_template'</span>:PageForm<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'from_template'</span><span style="color: black;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'page_data'</span>:page_data,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: black;">&#125;</span>, context_instance=RequestContext<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>If there's no POST data, the form will be initialized with a list of rendered forms that are JavaScript-ready. I am passing the page's ID to make it easy to save the objects later. There's also a dummy-form that will be used for adding new objects (<tt>page_template</tt>). Note that <tt>render_js('from_template')</tt> uses the <tt>from_template</tt> function which I implemented and renders the form using the given template. You can also pass the template name via the constructor of the form. Instead of <tt>form_template</tt>, you can also use e.g. <tt>as_p</tt>.</p>
<p>When posting the form, a list (<tt>FormCollection</tt>) of posted forms is returned via the <tt>get_forms</tt> classmethod. We are again preparing the <tt>page_data</tt> in case the forms don't validate. If the forms are valid, their IDs and their cleaned data will be printed. This example doesn't save anything, but I'll show you later how to use the built-in <tt>form_for_instance</tt> method to save the objects.</p>
<p>Here's the template of the edit page (<b>edit.html</b>):</p>
<div class="hilite-container">
<div class="igBar"><span id="lhtml-11"><a href="#" onclick="javascript:showCodeTxt('html-11'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="html-11">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> xmlns=<span style="color: #ff0000;">"http://www.w3.org/1999/xhtml"</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">"en-us"</span> xml:<span style="color: #000066;">lang</span>=<span style="color: #ff0000;">"en-us"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"/media/mootools.js"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"/media/dynamicforms.js"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/css"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"/media/css/forms.css"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var PageForm = Form.extend({</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; initialize: function(value) {</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.parent({{ page_template }}, value);</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.fieldset = new Element('fieldset');</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.fieldset.setProperty('class', 'module aligned');</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; this.fieldset.innerHTML = this.html;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; $('page-forms').adopt(this.fieldset);</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; }</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">});</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Window.onDomReady(function() {</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; {% for page in page_data %}</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; new PageForm({{ page }});</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; {% endfor %}</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">});</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"content"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;form</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">"."</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"post"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"page-forms"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"#"</span> <span style="color: #000066;">onclick</span>=<span style="color: #ff0000;">"new PageForm();"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Add new page<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"submit"</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>Note that I am using the <a href="http://www.mootools.net/">mootools</a> JavaScript library, because it already implements stuff like class inheritance (you will need to enable <tt>Window.Base</tt> and it's dependencies when downloading mootools). You can rewrite the JavaScript code if you use another JavaScript library.</p>
<p>The <tt>PageForm</tt> JavaScript class uses the <tt>page_template</tt> to add a new form if no values are specified. Forms with existing data will be created in the <tt>Window.onDomReady</tt> function.</p>
<h3>Another example using form_for_model and form_for_instance</h3>
<p>Here's a working view (<b>views.py</b>) that let's you add and edit <tt>Page</tt> objects without using the manually created <tt>PageForm</tt>:</p>
<div class="hilite-container">
<div class="igBar"><span id="lpython-12"><a href="#" onclick="javascript:showCodeTxt('python-12'); return false;">Plain text version (popup)</a></span></div>
<div class="syntax_hilite">
<div id="python-12">
<div class="python">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Example using form_for_model/instance and form.as_p()</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff7700;font-weight:bold;">def</span> dynamicform_using_model<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; page_form = forms.<span style="color: black;">form_for_model</span><span style="color: black;">&#40;</span>models.<span style="color: black;">Page</span>, dynamicforms.<span style="color: black;">BaseForm</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> request.<span style="color: black;">method</span> == <span style="color: #483d8b;">'POST'</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; is_valid = <span style="color: #008000;">True</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_forms = page_form.<span style="color: black;">get_forms</span><span style="color: black;">&#40;</span>request, <span style="color: black;">&#123;</span><span style="color: #483d8b;">'core'</span>:<span style="color: black;">&#40;</span><span style="color: #483d8b;">'title'</span>,<span style="color: black;">&#41;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_data = <span style="color: black;">&#91;</span>page_form.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'as_p'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> page_form <span style="color: #ff7700;font-weight:bold;">in</span> page_forms<span style="color: black;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> page_forms.<span style="color: black;">are_valid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> form <span style="color: #ff7700;font-weight:bold;">in</span> page_forms:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> form.<span style="color: #008000;">id</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instance_form = forms.<span style="color: black;">form_for_instance</span><span style="color: black;">&#40;</span>models.<span style="color: black;">Page</span>.<span style="color: black;">objects</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span>pk=form.<span style="color: #008000;">id</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#40;</span>form.<span style="color: black;">cleaned_data</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">assert</span> instance_form.<span style="color: black;">is_valid</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instance_form.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> HttpResponseRedirect<span style="color: black;">&#40;</span><span style="color: #483d8b;">'.'</span><span style="color: black;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page_data = <span style="color: black;">&#91;</span>forms.<span style="color: black;">form_for_instance</span><span style="color: black;">&#40;</span>page, dynamicforms.<span style="color: black;">BaseForm</span><span style="color: black;">&#41;</span><span style="color: black;">&#40;</span><span style="color: #008000;">id</span>=page.<span style="color: #008000;">id</span><span style="color: black;">&#41;</span>.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'as_p'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> page <span style="color: #ff7700;font-weight:bold;">in</span> models.<span style="color: black;">Page</span>.<span style="color: black;">objects</span>.<span style="color: black;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">'edit.html'</span>, <span style="color: black;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'page_template'</span>:page_form<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">render_js</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'as_p'</span><span style="color: black;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">'page_data'</span>:page_data,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: black;">&#125;</span>, context_instance=RequestContext<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p>You have to specify <tt>dynamicforms.BaseForm</tt> in <tt>form_for_model</tt>, because Django requires a <tt>BaseForm</tt>. Saving objects is as easy as calling <tt>form.save()</tt>. For updating objects I had to create another <tt>form_for_instance</tt> and pass the page's id.</p>
<h3>Comments?</h3>
<p>Have a lot of fun using dynamicforms and please leave a comment on this page if you like (or don't) dynamicforms or if you have suggestions.</p>
<p><b>Update (February 18th):</b> Improved get_forms() in dynamicforms.py to allow deletion of objects (now there are no premature breaks when a form is missing).</p>
<p><b>Update (May 6th):</b> Improved dynamicforms.js to prevent data loss when storing the template in a variable and creating multiple objects at once.</p>
<p><b>Update (August 4th):</b> Changed clean_data to cleaned_data, improved dynamicforms.js (unicode, from_template takes now an optional extra_context argument)</p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Cool the user with PC coolers</title>
		<link>http://eggdrop.ch/blog/2006/07/07/cool-the-user-with-pc-coolers/</link>
		<comments>http://eggdrop.ch/blog/2006/07/07/cool-the-user-with-pc-coolers/#comments</comments>
		<pubDate>Fri, 07 Jul 2006 11:11:48 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Hardware</category>
	<category>English</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/07/07/cool-the-user-with-pc-coolers/</guid>
		<description><![CDATA[After seeing this picture (cool the user with PC coolers, found via MacOrama) I realized that I also had some unused PC coolers lying around.
Here is what I came up with:

The cooler is connected to the PC and is standing on the legs of a Netgear WLAN router. 
]]></description>
			<content:encoded><![CDATA[<p>After seeing <a href="http://www.flickr.com/photos/remkovandokkum/181620397/">this picture</a> (cool the user with PC coolers, found via <a href="http://www.macorama.net/2006/07/nerdventilator.html">MacOrama</a>) I realized that I also had some unused PC coolers lying around.</p>
<p>Here is what I came up with:</p>
<p><a class="imagelink" href="http://eggdrop.ch/blog/wp-content/cooler.jpg" title="cooler"><img id="image33" src="http://eggdrop.ch/blog/wp-content/cooler.thumbnail.jpg" alt="cooler" /></a></p>
<p>The cooler is connected to the PC and is standing on the legs of a Netgear WLAN router. </p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/07/07/cool-the-user-with-pc-coolers/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>RSS-Reader Widget: Universal Binary and new features</title>
		<link>http://eggdrop.ch/blog/2006/06/23/rss-reader/</link>
		<comments>http://eggdrop.ch/blog/2006/06/23/rss-reader/#comments</comments>
		<pubDate>Fri, 23 Jun 2006 16:37:04 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>News</category>
	<category>Programming</category>
	<category>English</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/06/23/rss-reader/</guid>
		<description><![CDATA[
My RSS-Reader Dashboard Widget for Mac&#160;OS&#160;X is now a Universal Binary and should run on Intel Macs. Because I don't own an Intel Mac yet, contact me if it does not work correctly.
It also supports automatic reloading of the feed and scrolling using the mouse scroller and keyboard arrows (Thanks to Nicolas Weber or implementing [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://eggdrop.ch/blog/wp-content/rss-reader.thumbnail.png" alt="RSS-Reader" style="float:left; margin-right:20px; margin-bottom:10px;" /></p>
<p>My <a href="http://eggdrop.ch/projects/rss-reader/">RSS-Reader Dashboard Widget</a> for Mac&nbsp;OS&nbsp;X is now a Universal Binary and should run on Intel Macs. Because I don't own an Intel Mac yet, contact me if it does not work correctly.</p>
<p>It also supports automatic reloading of the feed and scrolling using the mouse scroller and keyboard arrows (Thanks to <a href="http://www.amnoid.de/">Nicolas Weber</a> or implementing scrolling).</p>
<div style="clear:both;"></div>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/06/23/rss-reader/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Automatische Ansage des Anrufenden</title>
		<link>http://eggdrop.ch/blog/2006/06/16/automatische-ansage-des-anrufenden/</link>
		<comments>http://eggdrop.ch/blog/2006/06/16/automatische-ansage-des-anrufenden/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 17:49:49 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Programming</category>
	<category>Hardware</category>
	<category>Deutsch</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/06/16/automatische-ansage-des-anrufenden/</guid>
		<description><![CDATA[Bei einem eingehenden Telefonanruf wird bei mir nun Name, Beruf und Ortschaft des Anrufenden automatisch mit einer synthetischen Stimme angesagt. Bei Bedarf wird dies sogar im Telefonbuch über das Internet nachgeschlagen.
Voraussetzung für das Setup sind ein Telefonanschluss bei GGAdigiPhone und natürlich Programmier- und Bastelkenntnisse...
Die Installation und alle benötigten Scripts finden sich in meinem Telefonie-Text.
Vielleicht kann [...]]]></description>
			<content:encoded><![CDATA[<p>Bei einem eingehenden Telefonanruf wird bei mir nun Name, Beruf und Ortschaft des Anrufenden automatisch mit einer synthetischen Stimme angesagt. Bei Bedarf wird dies sogar im Telefonbuch über das Internet nachgeschlagen.</p>
<p>Voraussetzung für das Setup sind ein Telefonanschluss bei <a href="/blog/2006/04/20/telefonie-bei-ggadigiphone/">GGAdigiPhone</a> und natürlich Programmier- und Bastelkenntnisse...</p>
<p>Die Installation und alle benötigten Scripts finden sich in meinem <a href="/texts/digiphone/">Telefonie-Text</a>.</p>
<p>Vielleicht kann dies ja jemand auf ein Setup mit analogem Telefonanschluss (und Modem im Computer) portieren?
</p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/06/16/automatische-ansage-des-anrufenden/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Elevator/Lift hacking</title>
		<link>http://eggdrop.ch/blog/2006/05/10/elevatorlift-hacking/</link>
		<comments>http://eggdrop.ch/blog/2006/05/10/elevatorlift-hacking/#comments</comments>
		<pubDate>Wed, 10 May 2006 19:43:36 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Deutsch</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/05/10/elevatorlift-hacking/</guid>
		<description><![CDATA[Ich bin auf einen interessanten Blogeintrag über das "Hacken" von Aufzügen gestossen. So soll es beispielsweise Lifte geben, die eine Person ohne Zwischenhalte zu einem bestimmten Stockwerk führen, wenn man den Knopf des Stockwerks und den Tür-Schliess-Knopf gleichzeitig drückt.
Habe diese Tricks noch nicht ausprobiert, vermutlich werden sie in der Schweiz nicht funktionieren.
Hat jemand Erfahrung mit [...]]]></description>
			<content:encoded><![CDATA[<p>Ich bin auf einen <a href="http://kunoichi.info/blog/2006/05/08/elevatorlift-hacking/">interessanten Blogeintrag</a> über das "Hacken" von Aufzügen gestossen. So soll es beispielsweise Lifte geben, die eine Person ohne Zwischenhalte zu einem bestimmten Stockwerk führen, wenn man den Knopf des Stockwerks und den Tür-Schliess-Knopf gleichzeitig drückt.</p>
<p>Habe diese Tricks noch nicht ausprobiert, vermutlich werden sie in der Schweiz nicht funktionieren.</p>
<p>Hat jemand Erfahrung mit dem "Hacken" von Aufzügen in der Schweiz? <img src='http://eggdrop.ch/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/05/10/elevatorlift-hacking/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Telefonie bei GGAdigiPhone</title>
		<link>http://eggdrop.ch/blog/2006/04/20/telefonie-bei-ggadigiphone/</link>
		<comments>http://eggdrop.ch/blog/2006/04/20/telefonie-bei-ggadigiphone/#comments</comments>
		<pubDate>Thu, 20 Apr 2006 21:07:36 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Hardware</category>
	<category>Deutsch</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/04/20/telefonie-bei-ggadigiphone/</guid>
		<description><![CDATA[Mein Internetprovider (GGA Maur) bietet neu auch Telefonie (GGAdigiPhone) über das Kabelnetz an. Wir haben das Angebot bestellt, unter anderem aus dem Grunde, dass ein Telefon geschenkt wird.
Das Paket ist mit einem Mediatrix 1102 IP-Telefonie-Gerät gekommen, den man zwischen Kabelmodem und PC anschliesst. An diese Box schliesst man dann das eigentliche Telefon per RJ11 an.
Ich [...]]]></description>
			<content:encoded><![CDATA[<p>Mein Internetprovider (<a href="http://www.gga-maur.ch">GGA Maur</a>) bietet neu auch Telefonie (GGAdigiPhone) über das Kabelnetz an. Wir haben das Angebot bestellt, unter anderem aus dem Grunde, dass ein Telefon geschenkt wird.</p>
<p>Das Paket ist mit einem Mediatrix 1102 IP-Telefonie-Gerät gekommen, den man zwischen Kabelmodem und PC anschliesst. An diese Box schliesst man dann das eigentliche Telefon per RJ11 an.</p>
<p>Ich habe einen <a href="/texts/digiphone/">Text</a> geschrieben, der erläutert, wie man die Box auch hinter einem Linux-Server mit NAT zum Laufen bringt.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/04/20/telefonie-bei-ggadigiphone/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Disassembling an external LaCie harddrive</title>
		<link>http://eggdrop.ch/blog/2006/04/02/disassembling-an-external-lacie-harddrive/</link>
		<comments>http://eggdrop.ch/blog/2006/04/02/disassembling-an-external-lacie-harddrive/#comments</comments>
		<pubDate>Sun, 02 Apr 2006 18:47:55 +0000</pubDate>
		<dc:creator>tom</dc:creator>
		
	<category>Hardware</category>
	<category>English</category>
		<guid isPermaLink="false">http://eggdrop.ch/blog/2006/04/02/disassembling-an-external-lacie-harddrive/</guid>
		<description><![CDATA[Here are some pictures of disassembling my external "LaCie Porsche Hard Drive" which contained a broken Maxtor disk:
  
]]></description>
			<content:encoded><![CDATA[<p>Here are some pictures of disassembling my external "LaCie Porsche Hard Drive" which contained a <a href="/blog/2006/03/23/problems-with-maxtor-harddisks/">broken Maxtor disk</a>:</p>
<p><a href="/blog/wp-content/lacie_1.jpg"><img src="/blog/wp-content/lacie_1.thumbnail.jpg" alt="Lacie 1" /></a> <a href="/blog/wp-content/lacie_2.jpg"><img src="/blog/wp-content/lacie_2.thumbnail.jpg" alt="Lacie 2" /></a> <a href="/blog/wp-content/lacie_3.jpg"><img src="/blog/wp-content/lacie_3.thumbnail.jpg" alt="Lacie 3" /></a></p>
]]></content:encoded>
			<wfw:commentRSS>http://eggdrop.ch/blog/2006/04/02/disassembling-an-external-lacie-harddrive/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
