Archive for the ‘Fun’ Category

October 13, 2011 0

Multiprocessing SNMP with Python

By in Fun, SysAdmin

I’ve written a ton of snmp monitoring scripts and they all suck because they are blocking and take “too long” to return results for a large amount of hosts. So how would we make this process faster and make us happier? multiprocessing is a package that supports spawning processes using an API similar to the [...]

August 17, 2011 0

Tweeting from a Django Application

By in Fun, Nothing, SysAdmin

It’s easy to get your application to start setting twitter status updates in django. Create a twitter account twitter.com Create a twitter “application’ and get your keys dev.twitter.com/apps Click on “settings” and set the access to read and write easy_install python-twitter Use this template Whenever you save a “Post” object, the def send_tweet method will [...]

Tags: ,

July 22, 2011 2

Indexing Multi-value fields from django-tagging in Haystack

By in Fun, SysAdmin

Enabling tagging on models is easy when you use django-tagging. However, I also have a search feature which is powered by Haystack and Whoosh. I wanted to be able to search for objects by the tags that are associated with them. You need to use the following in your haystack SearchIndex model: tags = indexes.MultiValueField(indexed=True, [...]

July 20, 2011 0

django-registration Require a unique email address for registration

By in Fun, SysAdmin

Everyone uses django-registration for… registration… however.. you may get this error: TypeError at /accounts/register/ register() takes at least 2 non-keyword arguments (1 given) Here’s what your urls.py should look like for the /accounts/register/ url: urls.py from django.conf.urls.defaults import * from registration.forms import RegistrationFormUniqueEmail urlpatterns = patterns(”, (r’^accounts/register/’, ‘registration.views.register’, {‘form_class’:RegistrationFormUniqueEmail,’backend’:'registration.backends.default.DefaultBackend’ }), )

July 20, 2011 0

Unique Slugs for Django Objects

By in Fun, SysAdmin

I’m working on a new project and decided to use slugs to access object information.  The built-in in “slugify” does not generate unique slugs for objects, but I found a solution. Overriding the save method allows us to check to see if there are any other objects which have the same slug such as “how-to-make-a-table” [...]