<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pandemonium Illusion</title>
	<atom:link href="http://pandemoniumillusion.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pandemoniumillusion.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 24 Dec 2011 03:26:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pandemoniumillusion.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Pandemonium Illusion</title>
		<link>http://pandemoniumillusion.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pandemoniumillusion.wordpress.com/osd.xml" title="Pandemonium Illusion" />
	<atom:link rel='hub' href='http://pandemoniumillusion.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Homebrew and MySQL server</title>
		<link>http://pandemoniumillusion.wordpress.com/2011/05/03/homebrew-and-mysql-server/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2011/05/03/homebrew-and-mysql-server/#comments</comments>
		<pubDate>Tue, 03 May 2011 18:12:22 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=41</guid>
		<description><![CDATA[So, I got a fresh new macbook last week and decided to use homebrew for my MySQL server installation. I&#8217;ve used homebrew for a while and love it, but I had installed MySQL from a package before I knew about &#8230; <a href="http://pandemoniumillusion.wordpress.com/2011/05/03/homebrew-and-mysql-server/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=41&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I got a fresh new macbook last week and decided to use homebrew for my MySQL server installation. I&#8217;ve used homebrew for a while and love it, but I had installed MySQL from a package before I knew about homebrew (and maybe before it existed). Anyway, here&#8217;s the problem I ran into:</p>
<p>Everything installed just splendidly using <code>brew install mysql</code>, but I have a particularly heavy query on a dev site and the server was responding with &#8220;MySQL server has gone away.&#8221; No errors were showing up in the .err file (/usr/local/var/mysql) until I used <code>mysql.server start --log-warnings=2</code>. It turned out this was because the <code>max_allowed_packet</code> was too small, so I started the server with <code>mysql.server start --max-allowed-packet=16M</code> and I was golden.</p>
<p>So, I went to put this in my my.cnf file&#8230; but there wasn&#8217;t one!! I couldn&#8217;t find any configurations anywhere! Seemed really weird until I realized that <code>mysql.server</code> was actually running <code>msqld</code> with all the options passed in. So, I tried creating an /etc/my.cnf file and then ~/.my.cnf, but they didn&#8217;t work. I kept getting errors like:</p>
<p>ERROR! MySQL server PID file could not be found!<br />
or<br />
ERROR! The server quit without updating PID file<br />
or<br />
ERROR! The server quit without updating PID file (/usr/local/var/mysql/cambiodos.local.pid)</p>
<p>I think this may have had something to do with my setting the mysql user to myself. Shit, it seemed to make sense at the time. So, with &#8220;ERROR&#8221; ringing in my head and my blood pressure rising, I read on the MySQL site somewhere that ~/.my.ini was an alternative to ~/.my.cnf. For some reason it made sense to me to try it and it worked.</p>
<p>I&#8217;m guessing this has something to do with the fact that my.cnf is a configuration file and my.ini is just settings? So by using the .ini file I was able to simply override settings, not the absolute configuration, but that&#8217;s just a guess. Anyway, I&#8217;m happily running mysql with the following ~/.my.ini file:</p>
<p><code> [mysqld]<br />
max_allowed_packet = 16M<br />
log_warnings = 2<br />
default-character-set = utf8</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=41&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2011/05/03/homebrew-and-mysql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Better way to use Django&#8217;s SelectMultiple in Google App Engine for a ListProperty</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/08/20/better-way-to-use-djangos-selectmultiple-in-google-app-engine-for-a-listproperty/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/08/20/better-way-to-use-djangos-selectmultiple-in-google-app-engine-for-a-listproperty/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 02:02:01 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[App Engine]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[listproperty]]></category>
		<category><![CDATA[newforms]]></category>
		<category><![CDATA[SelectMultiple]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=26</guid>
		<description><![CDATA[So my last post was a quick hack attempt at this, but I have come up with a much cleaner method of getting a GAE ListProperty field to work with Django Forms (newforms). You simply have to create a new &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/08/20/better-way-to-use-djangos-selectmultiple-in-google-app-engine-for-a-listproperty/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=26&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So my <a href="http://pandemoniumillusion.wordpress.com/2008/07/15/selectmultiple-for-a-google-app-engine-listproperty-using-django-forms/" target="_self">last post</a> was a quick hack attempt at this, but I have come up with a much cleaner method of getting a <acronym title='Google App Engine'>GAE</acronym> <code>ListProperty</code> field to work with Django Forms (newforms). You simply have to create a new form field called <code>ListPropertyChoice</code>:</p>
<pre>
from django.newforms.fields import MultipleChoiceField
from appengine_django.models import BaseModel

class ListPropertyChoice(MultipleChoiceField):

    def clean(self, value):
        """ extending the clean method to work with GAE keys """
        new_value = super(ListPropertyChoice, self).clean(value)
        key_list = []
        for k in new_value:
            key_list.append(BaseModel.get(k).key())
        return key_list
</pre>
<p>You can then use this in your forms:</p>
<pre>
...
from fields import ListPropertyChoice

class Form(djangoforms.ModelForm):
    my_model = ListPropertyChoice(
                        widget=forms.CheckboxSelectMultiple(),
                        choices=[(m.key(), m.name) for m in db.Query(MyModel)]
                    )
    class Meta:
        model = ParentModel
</pre>
<p>Obviously you can use both the <code>SelectMultiple</code> widget and the <code>CheckboxSelectMultiple</code> widget and this same process could be easily duplicated for <code>ChoiceField</code>:</p>
<pre>
class GAEChoiceField(ChoiceField):
    def clean(self, value):
        """ extending the clean method to work with GAE keys """
        value = super(GAEChoiceField, self).clean(value)
        return BaseModel.get(value).key()
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=26&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/08/20/better-way-to-use-djangos-selectmultiple-in-google-app-engine-for-a-listproperty/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Django ImageField and FileField dynamic upload path in Newforms Admin</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/08/06/django-imagefield-and-filefield-dynamic-upload-path-in-newforms-admin/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/08/06/django-imagefield-and-filefield-dynamic-upload-path-in-newforms-admin/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 03:59:16 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=18</guid>
		<description><![CDATA[I&#8217;ve been using Scott&#8217;s CustomImageField for quite some time, but recently it stopped working when I moved to Newforms Admin. I wasn&#8217;t really sure why this was, but decided to build a quick workaround for now so I can continue &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/08/06/django-imagefield-and-filefield-dynamic-upload-path-in-newforms-admin/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=18&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/">Scott&#8217;s CustomImageField</a> for quite some time, but recently it stopped working when I moved to <a href="http://www.djangoproject.com/documentation/forms/">Newforms Admin</a>. I wasn&#8217;t really sure why this was, but decided to build a quick workaround <a href="http://code.djangoproject.com/ticket/5361">for now</a> so I can continue to use the newforms-admin.</p>
<p>Scott&#8217;s Field used the <code>post_init</code> and <code>pre_save</code> signals, which is probably the right way&#8230; Since this wasn&#8217;t working anymore, I decided to use the <code>post_save</code> signal. This way the image or file would be saved to a temporary directory initially and then moved to the appropriate directory afterwards.</p>
<p>Here is how the field would be defined in the model:</p>
<pre>
    class Image(models.Model):
	file = CustomImageField(use_key=True, upload_to='tmp')
</pre>
<p><code>use_key</code> and <code>upload_to</code> are optional. <code>use_key</code> defaults to <code>False</code>. If it is <code>True</code> then the id of the instance will be used as a prefix for the new file as there is the potential for overwriting now that we are moving the file. <code>upload_to</code> will simply define the temporary directory to upload the files to initially.</p>
<p>Below is the code that defines the <code>CustomImageField</code>. I have this in a file called &#8220;custom_fields.py.&#8221;</p>
<pre>
from django.db.models import ImageField, FileField, signals
from django.dispatch import dispatcher
from django.conf import settings
import shutil, os, glob, re
from distutils.dir_util import mkpath

class CustomImageField(ImageField):
    """Allows model instance to specify upload_to dynamically.

    Model class should have a method like:

        def get_upload_to(self, attname):
            return 'path/to/%d' % self.id

    Based closely on: http://scottbarnham.com/blog/2007/07/31/uploading-images-to-a-dynamic-path-with-django/
    """
    def __init__(self, *args, **kwargs):
        if not 'upload_to' in kwargs:
            kwargs['upload_to'] = 'tmp'
        self.use_key = kwargs.get('use_key', False)
        if 'use_key' in kwargs:
            del(kwargs['use_key'])
        super(CustomImageField, self).__init__(*args, **kwargs)

    def contribute_to_class(self, cls, name):
        """Hook up events so we can access the instance."""
        super(CustomImageField, self).contribute_to_class(cls, name)
        dispatcher.connect(self._move_image, signal=signals.post_save, sender=cls)

    def _move_image(self, instance=None):
        """
            Function to move the temporarily uploaded image to a more suitable directory
            using the model's get_upload_to() method.
        """
        if hasattr(instance, 'get_upload_to'):
            src = getattr(instance, self.attname)
            if src:
                m = re.match(r"%s/(.*)" % self.upload_to, src)
                if m:
                    if self.use_key:
                        dst = "%s/%d_%s" % (instance.get_upload_to(self.attname), instance.id, m.groups()[0])
                    else:
                        dst = "%s/%s" % (instance.get_upload_to(self.attname), m.groups()[0])
                    basedir = "%s%s/" % (settings.MEDIA_ROOT, os.path.dirname(dst))
                    mkpath(basedir)
                    shutil.move("%s%s" % (settings.MEDIA_ROOT, src),"%s%s" % (settings.MEDIA_ROOT, dst))
                    setattr(instance, self.attname, dst)
                    instance.save()

    def db_type(self):
        """Required by Django for ORM."""
        return 'varchar(100)'
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=18&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/08/06/django-imagefield-and-filefield-dynamic-upload-path-in-newforms-admin/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>SelectMultiple for a Google App Engine ListProperty using Django Forms</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/07/15/selectmultiple-for-a-google-app-engine-listproperty-using-django-forms/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/07/15/selectmultiple-for-a-google-app-engine-listproperty-using-django-forms/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 03:10:51 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[App Engine]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[listproperty]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=17</guid>
		<description><![CDATA[***EDIT: I recently posted a better way to do this. I just started with Google App Engine the other day. Man, who could resist a free server environment? Being a long time Django developer (one year), I was really excited &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/07/15/selectmultiple-for-a-google-app-engine-listproperty-using-django-forms/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=17&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>***EDIT:</strong> I recently posted a <a href="http://pandemoniumillusion.wordpress.com/2008/08/20/better-way-to-use-djangos-selectmultiple-in-google-app-engine-for-a-listproperty/">better way</a> to do this.</p>
<p>I just started with <a href="http://code.google.com/appengine/">Google App Engine</a> the other day. Man, who could resist a free server environment?</p>
<p>Being a long time Django developer (one year), I was really excited about it because it &#8220;runs django&#8221;. Now this isn&#8217;t really the case because of <a href="http://en.wikipedia.org/wiki/BigTable">BigTable</a>, which isn&#8217;t a real relational database. However, if you forgo the Django <acronym title="Object Relational Mapping">ORM</acronym> and use <acronym title="Google App Engine">GAE</acronym> models, you can still work with the other things that make Django so awesome: templates and forms. AND, the google models are so similar to Django that you&#8217;ll barely even notice the difference.</p>
<p>Ok, this isn&#8217;t a full on review <acronym title="Google App Engine">GAE</acronym> with Django, so I&#8217;ll cut right to the chase. I&#8217;m sure you found this page when you were trying to use django forms to handle the ListProperty model field in your HTML forms. The problem is that things like ModelChoiceField and ModelMultipleChoiceField won&#8217;t work because they rely on the Django <acronym title="Object Relational Mapping">ORM</acronym>. For that matter, ChoiceField and MultipleChoiceField won&#8217;t work because they return a list of strings, that although they can be the string for a db.key(), they won&#8217;t be the Key <em>objects</em> that your new models expect for ListProperty.</p>
<p>So, to get around this I just adjusted the MultipleChoiceField a bit so that it returns the list chosen fields as Key objects:</p>
<pre>
#MODELS
class Toping(BaseModel):
    name = db.StringProperty(required=True)

class Pizza(BaseModel):
    name = db.StringProperty(required=True)
    toppings = db.ListProperty(db.Key)

    def get_topings(self):
        # This returns the models themselves, not just the keys that are stored in toppings
        return Topping.get(self.toppings)

#FORMS
class PizzaForm(djangoforms.ModelForm):
    toppings = ListPropertyChoice(
                        widget=forms.CheckboxSelectMultiple(),
                        choices=[(rt.key(), rt.name) for rt in db.Query(Topping)]
                    )
    class Meta:
        model = Pizza

#CUSTOM FIELD
from django.newforms.util import ErrorList, ValidationError
from django.newforms.fields import ChoiceField
from django.newforms.widgets import MultipleHiddenInput, SelectMultiple
from appengine_django.models import BaseModel

from appengine_django.serializer.python import smart_unicode
from django.utils.translation import gettext

class ListPropertyChoice(ChoiceField):
    hidden_widget = MultipleHiddenInput

    def __init__(self, choices=(), required=True, widget=SelectMultiple, label=None, initial=None, help_text=None):
        super(ListPropertyChoice, self).__init__(choices, required, widget, label, initial, help_text)

    def clean(self, value):
        """
        Validates that the input is a list or tuple.
        """
        if self.required and not value:
            raise ValidationError(gettext(u'This field is required.'))
        elif not self.required and not value:
            return []
        if not isinstance(value, (list, tuple)):
            raise ValidationError(gettext(u'Enter a list of values.'))
        new_value = []
        for val in value:
            val = smart_unicode(val)
            new_value.append(val)
        # Validate that each value in the value list is in self.choices.
        valid_values = set([smart_unicode(k) for k, v in self.choices])
        for val in new_value:
            if val not in valid_values:
                raise ValidationError(gettext(u'Select a valid choice. %s is not one of the available choices.') % val)
        # These are the only changes to the django MultipleChoice Field
        # we just convert the list of strings to a list of keys
        key_list = []
        for k in new_value:
            key_list.append(BaseModel.get(k).key())
        return key_list
</pre>
<p>Now for a quick expaination&#8230; The ListPropertyChoice class itself is really just the MultipleChoiceField from Django V0.96. I had to use this because I couldn&#8217;t get the latest svn version to work w/ App Engine due to some SafeUnicode issues I haven&#8217;t looked into yet. The only real changes to that class are the last four lines which return the list of keys instead of key-strings from the form.</p>
<p>The only other thing that might need explanation is the get_toppings() method that I added to the Pizza model. This is just a shortcut to access the models instead of the keys, as they&#8217;re stored in the ListProperty.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=17&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/07/15/selectmultiple-for-a-google-app-engine-listproperty-using-django-forms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Bulk Add/Replace from Command Line</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/31/bulk-addreplace-from-command-line/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/31/bulk-addreplace-from-command-line/#comments</comments>
		<pubDate>Sat, 31 May 2008 02:21:41 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[sed find replace]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=16</guid>
		<description><![CDATA[I had to do this like 5 times today, so I thought I&#8217;d put it out there (so I can reference it). Note: you might want to backup your stuff, just in case you screw up your regular expression. Basically, &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/31/bulk-addreplace-from-command-line/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=16&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had to do this like 5 times today, so I thought I&#8217;d put it out there (so I can reference it).</p>
<p><em>Note: you might want to backup your stuff, just in case you screw up your regular expression.</em></p>
<p>Basically, I have a bunch of files that need to have changes, such as email address, or include paths.</p>
<p>So, for example, in one I had to change a bunch of email addresses so I used `sed`. To do this on one file you would simply run the sed command directly:<br />
<code>sed -e s/info@olddomain.com/info@newdomain.com/g -i file.html</code><br />
<strong>-e</strong> tags the regular expression you&#8217;re using<br />
<strong>-i</strong> means we&#8217;re editing the files inline (not outputting the results to standard out)<br />
Don&#8217;t forget <strong>g</strong>, because this will ensure that the expression is greedy and will find all the instances of this expression.</p>
<p>Of course, you probably want to run this on a bunch of files, so you would use `find`, because it&#8217;s awesome:<br />
<code>find -name "*.html" -exec sed -e s/info@olddomain.com/info@newdomain.com/g -i {} \;</code></p>
<p><strong>EDIT: </strong>I have found that Macs have an issue with the inline command (-i). You need to use `-i &#8221;` to give the inline an empty extension. So, the command above would be:</p>
<p>find -name &#8220;*.html&#8221; -exec sed -e s/info@olddomain.com/info@newdomain.com/g -i &#8221; {} \;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=16&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/31/bulk-addreplace-from-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Starting a new Django Project with Versioning</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/12/starting-a-new-django-project-with-versioning/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/12/starting-a-new-django-project-with-versioning/#comments</comments>
		<pubDate>Mon, 12 May 2008 20:51:00 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[getting started]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[svn import]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=13</guid>
		<description><![CDATA[Having an efficient working environment can be essential to the success of any project and can save hours, if not days of extra work in the long run. So, I&#8217;ve put together a little &#8220;getting started guide&#8221; to putting the &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/12/starting-a-new-django-project-with-versioning/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=13&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having an efficient working environment can be essential to the success of any project and can save hours, if not days of extra work in the long run. So, I&#8217;ve put together a little &#8220;getting started guide&#8221; to putting the full package in place with <a href="http://www.djangoproject.com">Django</a>, <a href="http://svnbook.red-bean.com/">SVN</a>, and <a href="http://trac.edgewall.org/">Trac</a>.</p>
<p><strong>Create your django project anywhere</strong><br />
<code><br />
~/django/projects$ ../src/trunk/django/bin/django-admin.py startproject myProject<br />
</code></p>
<p><strong>Set up your SVN</strong><br />
This can be done either on your local machine or on another server. I like /var/svn/repos/myProject/.<br />
<code><br />
$ svnadmin create /var/svn/repos/myProject<br />
</code><br />
I use svnserve to serve my svn so I update the permissions in /var/svn/repos/myProject/conf/svnserve.conf:<br />
<code><br />
[general]<br />
anon-access = none<br />
auth-access = write<br />
password-db = passwd<br />
</code><br />
/var/svn/repos/myProject/conf/passwd<br />
<code><br />
[users]<br />
user = passwd<br />
</code><br />
(re)Start the svnserve daemon<br />
<code><br />
svnserve -d -r /var/svn/repos<br />
</code><br />
Finally, we&#8217;re ready to check in the project tree<br />
<code><br />
$ svn import myProject file:///var/svn/repos/myProject/trunk/myProject -m "Initial import"<br />
</code><br />
Now just import it into Eclipse and your good to go! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Oh, and you might want to read about <a href="http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/">excluding .pyc files in svn</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=13&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/12/starting-a-new-django-project-with-versioning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Compress a PDF with pdftk</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/07/compress-a-pdf-with-pdftk/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/07/compress-a-pdf-with-pdftk/#comments</comments>
		<pubDate>Wed, 07 May 2008 21:02:08 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=15</guid>
		<description><![CDATA[UPDATED (9/7/11): The package is not pdftk, but Ghostscript, and it&#8217;s easily installable through homebrew on a mac. Ok, so I don&#8217;t know why this works, but it does and I haven&#8217;t seen any decrease in quality. I suspect converting &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/07/compress-a-pdf-with-pdftk/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=15&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATED (9/7/11):</strong> The package is not pdftk, but <a title="pdf2ps" href="http://en.wikipedia.org/wiki/Ghostscript">Ghostscript</a>, and it&#8217;s easily installable through <a title="Homebrew Mac OS Package Manager" href="https://github.com/mxcl/homebrew">homebrew</a> on a mac.</p>
<p>Ok, so I don&#8217;t know why this works, but it does and I haven&#8217;t seen any decrease in quality. I suspect converting from PDF to PS and back just optimizes the PDF.<br />
<strong>Requirements</strong></p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Pdftk">pdftk</a> for linux</li>
</ul>
<p><strong>The Process</strong></p>
<ol>
<li>Convert your PDF to PS (this creates a large file</li>
<li>Convert the new PS back to a PDF</li>
</ol>
<p><code><br />
pdf2ps large.pdf very_large.ps<br />
ps2pdf very_large.ps small.pdf<br />
</code></p>
<p><strong>Results</strong><br />
large.pdf : 6.3MB<br />
very_large.ps : 53.4MB<br />
small.pdf : 2.4MB<br />
<em>Looks like pretty good compression to me.</em></p>
<p>If anyone knows why this works so well, please let me know.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=15&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/07/compress-a-pdf-with-pdftk/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Ignore .pyc files in Subversion</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/#comments</comments>
		<pubDate>Wed, 07 May 2008 20:12:34 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=14</guid>
		<description><![CDATA[Subversion allows you to exclude certain files using regular expressions. This needs to be applied to each directory individually. So, if you add a new directory I think you will need to run the command again. To apply the svn:ignore &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=14&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Subversion allows you to exclude certain files using regular expressions. This needs to be applied to each directory individually. So, if you add a new directory I think you will need to run the command again. To apply the svn:ignore property to your project you just need to do two things:</p>
<p><strong>Create a file (.svnignore) with the regular expressions</strong><br />
<code><br />
*.pyc<br />
*~<br />
</code></p>
<p><strong>Run <em>svn propset</em> on the project</strong><br />
<code><br />
svn -R propset svn:ignore -F .svnignore .<br />
</code><br />
<strong>-R</strong> indicates that you are doing this recursively so all the directories ignore these.<br />
<strong>-F</strong> indicates the file we just created with the regular expressions.</p>
<p>EDIT 5/27/08:<br />
If you&#8217;ve already got yourself into the mess of versioning your compiled files, then you might want to do a few things.<br />
1) Revert all the .pyc files (you can always recompile them). You don&#8217;t want there to be any local changes when you try to delete them:<br />
<code>find -name "*.pyc" -exec svn revert {} \;</code><br />
2) Delete all the .pyc files using `svn delete`:<br />
<code>find -name "*.pyc" -exec svn delete {} \;</code><br />
3) Finally recompile and re-run the svn ignore code above</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=14&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Backing up with BackupPC</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/05/backing-up-with-backuppc/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/05/backing-up-with-backuppc/#comments</comments>
		<pubDate>Mon, 05 May 2008 18:05:25 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=12</guid>
		<description><![CDATA[BackupPC is an awesome tool for backing up a number of different machines. BackupPC has a web application that manages your backups and a separate backup application that runs periodically based on the settings you have in the web admin. &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/05/backing-up-with-backuppc/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=12&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://backuppc.sourceforge.net/">BackupPC</a> is an awesome tool for backing up a number of different machines. BackupPC has a web application that manages your backups and a separate backup application that runs periodically based on the settings you have in the web admin.</p>
<p>The design is ingenious because it can back up a variety of machines with unique settings. For windows machines I use a protected share that can only be accessed by a user called &#8216;backup&#8217;. The backup application then connects periodically to the share and runs incremental backups. For the linux machines I run an rsync demon on the pc. This is one of the few cases where it&#8217;s as easy on windows as linux. (In case there&#8217;s any doubt&#8230; everything is easier on linux 99% of the time.)</p>
<p>Given that I use linux exclusively, here&#8217;s the documentation on setting up an rsyncd connection with Backuppc.</p>
<p>1) Install rsyncd: $ sudo apt-get install rsync (ubuntu)<br />
2) Configure rsyncd with a backup option (/etc/rsyncd.conf)<br />
<code><br />
[backup]<br />
    path = /home/jamstooks<br />
    exclude = "/home/jamstooks/.mozilla/firefox/***"<br />
    comment = Backup<br />
    uid = jamstooks<br />
    gid = jamstooks<br />
    read only = true<br />
    auth users = backup<br />
    secrets file = /etc/rsyncd.secrets<br />
</code><br />
<em>I excluded the firefox directory, because I was getting issues with the cache being accessed during backup. It would probably be best to include the bookmarks though.</em><br />
/etc/rsyncd.secrets stores the passwords in plain-text, so make sure you adjust your permissions appropriately:<br />
<code><br />
backup:passwd<br />
</code><br />
3) Ubuntu sets up an init.d setup file, but you want to make sure the daemon is running&#8230;<br />
4) Finally, you are ready to set up BackupPC. In the BackupPC admin, simply select rsync for this machine and fill in the password you selected.</p>
<p>More details can be found in the <a href="http://backuppc.sourceforge.net/faq/BackupPC.html">official BackupPC documentation</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=12&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/05/backing-up-with-backuppc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick image resizing with python</title>
		<link>http://pandemoniumillusion.wordpress.com/2008/05/04/quick-image-resizing-with-python/</link>
		<comments>http://pandemoniumillusion.wordpress.com/2008/05/04/quick-image-resizing-with-python/#comments</comments>
		<pubDate>Sun, 04 May 2008 01:53:11 +0000</pubDate>
		<dc:creator>jamstooks</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[imaging]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pandemoniumillusion.wordpress.com/?p=11</guid>
		<description><![CDATA[I typically build automatic resizing into any django models that use ImageField by overriding the save function like so: def save(self): super(GalleryImage, self).save() # Call the "real" save() method if self.image: # now change the size of the image path &#8230; <a href="http://pandemoniumillusion.wordpress.com/2008/05/04/quick-image-resizing-with-python/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=11&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I typically build automatic resizing into any django models that use ImageField by overriding the save function like so:<br />
<code><br />
	def save(self):<br />
		super(GalleryImage, self).save() # Call the "real" save() method<br />
		if self.image:<br />
			# now change the size of the image<br />
			path = settings.MEDIA_ROOT + self.image<br />
			img1 = PIL.open(path)<br />
			img2 = PIL.open(path)<br />
			img2.save(self.get_thumbnail_path())</p>
<p>			size = 600,600<br />
			img1.thumbnail(size, PIL.ANTIALIAS)<br />
			img1.save(path)</p>
<p>			# create the thumbnail<br />
			size = 150, 150<br />
			img2.thumbnail(size, PIL.ANTIALIAS)<br />
			img2.save(self.get_thumbnail_path())</p>
<p>	def get_thumbnail_path(self):<br />
		path = settings.MEDIA_ROOT + self.image<br />
		return self.convert_path_to_thumbnail(path)</p>
<p>	def get_thumbnail_url(self):<br />
		path = self.get_image_url()<br />
		return self.convert_path_to_thumbnail(path)</p>
<p>	def convert_path_to_thumbnail(self, path):</p>
<p>		basedir = os.path.dirname(path) + '/'<br />
		base, ext = os.path.splitext(os.path.basename(path))</p>
<p>		# make thumbnail filename<br />
		th_name = base + "_tn"<br />
		th_name += ext<br />
		return urlparse.urljoin(basedir, th_name)<br />
</code></p>
<p>This ensures that all my images conform to the sizes I need. However, even if the server is automatically resizing the images for me, I don&#8217;t want to spend hours uploading huge images only to have them resized. It&#8217;s just a waste of bandwidth and time. So, I&#8217;ve written a quick python script that resizes all the images in a given directory and places the copies in a new directory called resized:</p>
<p><code><br />
#! /usr/bin/env python</p>
<p>"""<br />
What:<br />
    Resize all the jpg images in a directory<br />
    All images will be placed inside a directory called "resized"<br />
    This directory must exist<br />
Usage: ./resize.py<br />
"""</p>
<p>import PIL.Image as PIL<br />
import re, os, sys, urlparse</p>
<p>SIZE = 600,600<br />
JPG = re.compile(".*\.(jpg|jpeg)", re.IGNORECASE)</p>
<p>def get_new_path(path):<br />
    basedir = os.path.dirname(path) + '/resized/'<br />
    base, ext = os.path.splitext(os.path.basename(path))<br />
    file = base + ext</p>
<p>    return urlparse.urljoin(basedir, file) </p>
<p>try:<br />
    image_dir = sys.argv[1]<br />
except:<br />
    print "You must specify a directory"<br />
    exit(0)</p>
<p>files = os.listdir(image_dir)<br />
for file in files:<br />
    if JPG.match(file):<br />
        f = image_dir.rstrip("/") + "/" + file<br />
        print f<br />
        img = PIL.open(f)<br />
        img.thumbnail(SIZE, PIL.ANTIALIAS)<br />
        img.save(get_new_path(f))<br />
</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pandemoniumillusion.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pandemoniumillusion.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pandemoniumillusion.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pandemoniumillusion.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pandemoniumillusion.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pandemoniumillusion.wordpress.com&amp;blog=3335422&amp;post=11&amp;subd=pandemoniumillusion&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pandemoniumillusion.wordpress.com/2008/05/04/quick-image-resizing-with-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c88dd3712b9e7fd252047ec467277778?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jamstooks</media:title>
		</media:content>
	</item>
	</channel>
</rss>
