Category Archives: Python

Repeating Sections in a Django Template

I have a need to have multiple sections of name/value pairs with a header on some pages. Something like: <div class="row">     <div class="span6">         <div class="row"><div class="span3"><h2>History:</h2></div></div>         <div class="row"><div class="span2">Date added to fleet:</div><div class="span2">{{plane.dateAddedToFleet}}</div></div>         <div class="row"><div class="span2">Total Flight Time:</div><div class="span2">{{plane.totalFlightTime|asTime}}</div></div>         <div … Continue reading

Posted in Django, Python | 8 Comments

Rate limiting with django-ratelimit

I was playing around with James Socol’s django-ratelimit tonight. It provides a decorator to rate-limit view functions. Very nice! I wanted to use it for login blocking, and some minor changes helped this out. My forked version of django-ratelimit is … Continue reading

Posted in Django, Python | Leave a comment

Custom Tag to Render Avatar in Django Userena

Here is a simple custom tag to render a users avatar (‘mugshot’) when using Django Userena. It optionally takes width and or height in pixels. Place the following code in /templatetags/ your_app/     templatetags/ from django import template … Continue reading

Posted in Django, Python | Leave a comment

Django Image Field Overwrite with ImageKit

I’m using django-imagekit on a new site. I was having a problem that when a user uploaded a new image for the object, the system would not overwrite the existing image file, but instead would create a new file with … Continue reading

Posted in Django, Python | Leave a comment

SimpleJson Error with django under google app engine

Since moving over to 64 bit windows 7, I’ve had this error when starting up: "…] zipimporter('C:\\python25\\lib\\site- packages\\simplejson-2.0.9-py2.5-win.egg', 'simplejson\\') … … SetGlobals() … … File "C:\Program Files\Google\google_appengine\google\appengine\dist\", line 268, in _getitem__ info = _zipfile_cache[self._archive].getinfo(filename) File "C:\Python25\lib\", line 462, … Continue reading

Posted in Python | Leave a comment

Sequence from every Nth Item of another Sequence

The phrase ‘every Nth item‘ may be off here, but it is close enough what I want to do (reduce a data set for charting purposes). # data = sequence of data items # nth = you want every nth … Continue reading

Posted in programming, Python | 12 Comments

In-Application Customer Feedback

Matt Wilson asked about ‘awesome web-apps to let customers suggest/vote/comment’ on upcoming features.‘ This gave me the idea to post about ErgMate’s in-application feedback mechanism. In addtion to sending an email to the support mailbox, there are two other ways … Continue reading

Posted in Micro-isv, programming, Python | Leave a comment

Forcing a HTTP Proxy on Local Google App Engine Development Server

I’ve been trying somewhat in vain to debug a REST interface that’s failing when running under GAE. After some searching, I found a way to force the local development server to use an http proxy (such as Charles or Membrane). … Continue reading

Posted in Python | 1 Comment

Restful Interfaces to 3rd-Party Websites in Python

Here are the slides and examples from my Code Mash talk: Restful Interfaces to 3rd-Party Websites with Python (PDF) examples.tar.gz

Posted in programming, Python | Leave a comment

wxPython Font by Pixel Height

I’ve been looking to find a way to resize a font when the window’s size changes. Here is code that will create a font that is close as possible to a given height in pixels without specifying anything about the … Continue reading

Posted in Python, wxPython | Leave a comment