Slippery Snippets
Thursday, July 26, 2007
  Wherefore art thou not working under Windows Hello all.

Still stuck in the Midlands, so posting and development have pretty much ground to a halt. I did manage to do a bit of hacking the other day, but I can't get bzr-svn working under Windows, so you'll have to wait until I'm next in Linux for the next push to trunk.

Anyway, since my last post I've been playing around with wxPython and Django; in particular trying to use one to display the models from the other. During this I ran into another Django bug (second one to stop me in my tracks) and some random behaviour which I didn't quite agree with.

In a huff I decided to try out Pylons - mainly because because it plays well with SqlAlchemy.

It's hard work getting going with Pylons - documentation is nowhere near as complete as Django's but if you're prepared to hunt through the source most things become apparent. The IRC channel is very friendly as well, though you sometimes have to wait for America to wake up.

Here's my handy Pylons tip for the day:

def screenshot(self, id):
i = model.Screenshot.get(id)
if i:
im =
pylons.response.headers['Content-Type'] = "image/%s" % (im.format and im.format.lower() or 'bmp')
pylons.response.headers['Content-length'] = "%s" % len(i.image)
if request.params.has_key('thumb') and request.params['thumb'] == "True":
im.thumbnail(THUMB_SIZE, Image.ANTIALIAS)
w = StringIO(), im.format)
return str(w.getvalue())

The above action pulls an image out of the database and serves it up. If the GET has thumb=True set then you'll get a thumbnail instead.

I know that you're not supposed to serve images from the DB but, trust me, I have good reason for doing so.

It also looks as though there are some issues when returning large images; it's been suggested that FileApp.DataApp is the way forward. 
Glad to hear new version is under way.
Hi Felix,

SnippetsEmu is one of the best plugins I have found for Vim :) Keep up the excellent work. I was wondering if there was a way of having snippets called within snippets. I assume there is currently not since I haven't been able to find anything to suggest so. The reason I ask is because I would like to generate an entire file (a template of sorts) at once rather than bit by bit. I'd rather not make one big snippet, although this might not be a bad idea since the template size is relatively small anyway. Plus, they are called "snippets" for a reason. Anyway, it's somewhat cumbersome to have to define what would be more natural as a standalone file in a single string I'm sure you already know. Just something to think about for the next version maybe?
Post a Comment

Subscribe to Post Comments [Atom]

<< Home

July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / March 2007 / April 2007 / May 2007 / July 2007 / September 2007 / February 2008 / June 2009 / December 2010 /

Powered by Blogger

Subscribe to
Posts [Atom]