<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mixedpuppy &#187; Uncategorized</title>
	<atom:link href="http://shane.caraveo.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://shane.caraveo.com</link>
	<description></description>
	<lastBuildDate>Thu, 30 Jun 2011 18:06:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<link rel='salmon' href='http://shane.caraveo.com/?salmon=endpoint'/><link rel='http://salmon-protocol.org/ns/salmon-replies' href='http://shane.caraveo.com/?salmon=endpoint'/><link rel='http://salmon-protocol.org/ns/salmon-mention' href='http://shane.caraveo.com/?salmon=endpoint'/>		<item>
		<title>wsgi middlewares for profiling and debugging</title>
		<link>http://shane.caraveo.com/2010/09/24/wsgi-middlewares-for-profiling-and-debugging/</link>
		<comments>http://shane.caraveo.com/2010/09/24/wsgi-middlewares-for-profiling-and-debugging/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 19:08:45 +0000</pubDate>
		<dc:creator>mixedpuppy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://shane.caraveo.com/?p=68</guid>
		<description><![CDATA[A while back I implemented a debugging and profiling middleware, and I&#8217;ve been using those with Pylons recently. I think their pretty useful, so I&#8217;ve wrapped them up into an installable egg that contains Paste interfaces in setup.py. This allows you to easily insert the middleware into any existing Paste project (e.g. a Pylons project). [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://trac.edgewall.org/ticket/8507">while back</a> I implemented a debugging and profiling middleware, and I&#8217;ve been using those with Pylons recently.  I think their pretty useful, so I&#8217;ve wrapped them up into an installable egg that contains Paste interfaces in setup.py.  This allows you to easily insert the middleware into any existing Paste project (e.g. a Pylons project).    I&#8217;m basically going to use this <a href="http://bitbucket.org/mixedpuppy/middlewares">middlewares</a> project as a dumping ground for middleware I find useful.  It currently contains a debug (via <a href="http://www.xdebug.org/docs-dbgp.php">DBGP</a>) middleware, a profiler and a csrf middleware.  There is nothing that says you must use Paste with these, Paste just makes it easier.  The csrf middleware is currently tied to using Beaker.</p>
<p>Here&#8217;s a screenshot of <a href="http://www.activestate.com/komodo-ide">Komodo IDE</a> debugging my Pylons app.  Lots of other debuggers support DBGP, but for many reasons I like Komodo.</p>
<p><a href="http://shane.caraveo.com/wp-content/uploads/2010/09/debugging.png"><img class="alignnone size-medium wp-image-69" title="debugging" src="http://shane.caraveo.com/wp-content/uploads/2010/09/debugging-300x298.png" alt="" width="300" height="298" /></a></p>
<p>Below is a partial output of line profiling the csrf middleware call handler.  The profiler can use line or call profiling.  I find line profiling handy when I want to focus into a specific area.  While debugging and call profiling require no code changes in your code, line profiling does require you to decorate the function(s) you want to line profile.</p>
<p>The profiler currently requires a patch if you want to do line profiling with Pylons.  I&#8217;ve sent the <a href="http://bitbucket.org/mixedpuppy/middlewares/src/tip/line_profiler.patch">patch</a> to the maintainer of <a href="http://packages.python.org/line_profiler/">line_profiler</a>.</p>
<pre>Timer unit: 1e-06 s

File: ...../csrf.py
Function: __call__ at line 40
Total time: 0.004621 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
    40                                               @profile
    41                                               def __call__(self, environ, start_response):
    42         1           29     29.0      0.6          request = Request(environ)
    43         1            3      3.0      0.1          session = environ['beaker.session']
    44         1          476    476.0     10.3          csrf_token = session.get('csrf')
    45         1            4      4.0      0.1          if not csrf_token:
    46                                                       csrf_token = session['csrf'] = str(random.getrandbits(128))
    47                                                       session.save()
    48
    49         1            7      7.0      0.2          if request.method == 'POST':</pre>
]]></content:encoded>
			<wfw:commentRss>http://shane.caraveo.com/2010/09/24/wsgi-middlewares-for-profiling-and-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>database migrations for SQLAlchemy part duex</title>
		<link>http://shane.caraveo.com/2010/09/13/database-migrations-for-sqlalchemy-part-duex/</link>
		<comments>http://shane.caraveo.com/2010/09/13/database-migrations-for-sqlalchemy-part-duex/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 20:00:14 +0000</pubDate>
		<dc:creator>mixedpuppy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://shane.caraveo.com/?p=65</guid>
		<description><![CDATA[Well, as I was looking at making miruku more reliant on sqlalchemy-migrate, I discovered the expirmental command: migrate update_db_from_model! So much for an afternoons work, but at least I&#8217;m much more familiar with the migration tools. So here&#8217;s how I&#8217;ve implemented an auto upgrade for Pylons. First, easy_install sqlalchemy-migrate Now, in your pylons development.ini, add [...]]]></description>
			<content:encoded><![CDATA[<p>Well, as I was looking at making miruku more reliant on sqlalchemy-migrate, I discovered the expirmental command: <em>migrate  update_db_from_model</em>!  So much for an afternoons work, but at least I&#8217;m much more familiar with the migration tools.  So here&#8217;s how I&#8217;ve implemented an auto upgrade for Pylons.</p>
<p>First, <em>easy_install sqlalchemy-migrate</em></p>
<p>Now, in your pylons development.ini, add the following to app:main:</p>
<p><code># SQLAlchemy migration<br />
# if managed, the migration repository is here<br />
migrate.repository = %(here)s/changes<br />
# automatically do database upgrades<br />
migrate.auto = 1</code></p>
<p>Then, in PRJNAME.config.environment, in <strong>load_environment, after the call to init_model</strong> add the following:</p>
<pre>
    # sqlalchemy auto migration
    if asbool(config.get('migrate.auto')):
        try:
            # managed upgrades
            cschema = schema.ControlledSchema.create(engine, config['migrate.repository'])
            cschema.update_db_from_model(meta.Base.metadata)
        except exceptions.InvalidRepositoryError, e:
            # unmanaged upgrades
            diff = schemadiff.getDiffOfModelAgainstDatabase(
                meta.Base.metadata, engine, excludeTables=None)
            genmodel.ModelGenerator(diff).applyModel()
</pre>
<p>Of course, don&#8217;t forget the imports you need:</p>
<p><code>from paste.deploy.converters import asbool<br />
from migrate.versioning.util import load_model<br />
from migrate.versioning import exceptions, genmodel, schemadiff, schema<br />
</code></p>
<p>Run your app: <em>paster serve &#8211;reload development.ini</em></p>
<p>Now with most basic changes in the model, when paste reloads your database will be updated to reflect the new model.  This of course can fail sometimes, such as adding a new column with <em>nullable=False</em>.</p>
<p>I&#8217;m only using the unmanaged upgrades right now, so the managed section may need some tweaking, I&#8217;ll see when I get there.</p>
]]></content:encoded>
			<wfw:commentRss>http://shane.caraveo.com/2010/09/13/database-migrations-for-sqlalchemy-part-duex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get the dirt on your communications!</title>
		<link>http://shane.caraveo.com/2010/04/24/get-the-dirt-on-your-communications/</link>
		<comments>http://shane.caraveo.com/2010/04/24/get-the-dirt-on-your-communications/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 00:36:18 +0000</pubDate>
		<dc:creator>mixedpuppy</dc:creator>
				<category><![CDATA[mozilla]]></category>
		<category><![CDATA[thunderbird]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://shane.caraveo.com/?p=27</guid>
		<description><![CDATA[I&#8217;ve been hacking on a few things lately, one is the Contacts addon for Firefox and getting it to work in Thunderbird.  A quick demo of a little feature I added to Contacts in Thunderbird&#8230; Here I&#8217;ve received an email from some random person, and I need to know who they are and why I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hacking on a few things lately, one is the Contacts addon for Firefox and getting it to work in Thunderbird.  A quick demo of a little feature I added to Contacts in Thunderbird&#8230;</p>
<p>Here I&#8217;ve received an email from some random person, and I need to know who they are and why I should care that they&#8217;ve emailed me&#8230;Give me the dirt!</p>
<p><a href="http://shane.caraveo.com/wp-content/uploads/2010/04/popupmenu.png"><img class="alignnone size-medium wp-image-29" title="popupmenu" src="http://shane.caraveo.com/wp-content/uploads/2010/04/popupmenu-300x116.png" alt="" width="300" height="116" /></a></p>
<p>And here is a Contact tab in thunderbird as the result:</p>
<p><a href="http://shane.caraveo.com/wp-content/uploads/2010/04/contacttab.png"><img class="alignnone size-medium wp-image-28" title="contacttab" src="http://shane.caraveo.com/wp-content/uploads/2010/04/contacttab-244x300.png" alt="" width="244" height="300" /></a></p>
<p>I&#8217;m not sure about this email, that guy looks a little sketchy.</p>
<p>You can find out more about <a href="http://mozillalabs.com/blog/2010/04/contacts-in-the-browser-0-3-released/">Contacts</a> at Mozilla Labs, and follow the Thunderbird patch I&#8217;m working on in <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=560640">bugzilla</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://shane.caraveo.com/2010/04/24/get-the-dirt-on-your-communications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>getting started</title>
		<link>http://shane.caraveo.com/2010/03/29/getting-started/</link>
		<comments>http://shane.caraveo.com/2010/03/29/getting-started/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 20:31:51 +0000</pubDate>
		<dc:creator>mixedpuppy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mixedpuppy.wordpress.com/?p=4</guid>
		<description><![CDATA[Here i am, getting started.  Initially this will primarily be work content, though eventually I&#8217;m sure I&#8217;ll branch out.  I&#8217;ve written a little bit about me for those that want to know.]]></description>
			<content:encoded><![CDATA[<p>Here i am, getting started.  Initially this will primarily be work content, though eventually I&#8217;m sure I&#8217;ll branch out.  I&#8217;ve written a little bit <a href="/about/">about me</a> for those that want to know.</p>
]]></content:encoded>
			<wfw:commentRss>http://shane.caraveo.com/2010/03/29/getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

