The Unfuddle Tutorial

By : Shabda Raaj

Unfuddle is the tool we use for our non open source development. I have found it to be the best tool for Software Project management, in particular I think it is superior to Basecamp and Assembla.

When you start using Unfuddle, the number of things can seem overwhelming. This tutorial should help you Unfuddle the Unfuddle.


The Unfuddle Glossary

Unfuddle has,

  • Projects: Top level Things which need to be done.
  • User: People who are working on a given project.
  • Ticket: What a User works on.
  • Milestone: A timed list of tickets which should be completed before this given time ...

more info..
Topics : tips tutorial
shabda
Comments
Reactions

Experiments in URL design.

By : Shabda Raaj

Keeping url structure sane plays a major role in user experience, by making it easy to go to specific pages and navigate the site. Some real world urls and how they could have been better follow.


The Bad Urls:

  • http://news.ycombinator.com/item?id=1967820
  • http://area51.phpbb.com/phpBB/viewforum.php?f=99
  • http://msdn.microsoft.com/en-us/aa336522.aspx

The Good

  • Easy to develop for. The id referred is the Primary key

The Bad

  • Hard for users to select the correct page from a url bar dropdown
  • Bad for SEO

Neutral:

  • Easy to guess next and previous ...

more info..
Topics : opinion web2.0 apps urls
shabda
Comments
Reactions

Unfuddle Summary Script

By : Shabda Raaj

Unfuddle is our preferred tool for private repos, project management and ticketing. We recently wrote a slick script to summarize our Unfuddle status. So here is it.


import getpass
import simplejson
import sys
import urllib2

from datetime import datetime, date

try:
    from settings import *
except ImportError:
    ACCOUNT_DETAILS = {
        'account': '',
        'username': '', 
        'password': '',
    }
    SEND_MAIL = False

if not ACCOUNT_DETAILS['account']:
    ACCOUNT_DETAILS['account'] = raw_input('Enter unfuddle account name: ')

if not ACCOUNT_DETAILS['username']:
    ACCOUNT_DETAILS['username'] = raw_input('Username: ')

if not ACCOUNT_DETAILS['password']:
    ACCOUNT_DETAILS['password'] = getpass.getpass()

class Unfuddle(object):
    def __init__(self):
        self.base_url = 'https://%s.unfuddle.com' % (ACCOUNT_DETAILS['account'])
        self.api_base_path = '/api/v1/'

def get_data(self ...

more info..

Github in github

By : Shabda Raaj

We have a (semi) new app. This takes your Github account and creates Github pages from it. It displays a summary of your account, and of all your apps. Get it at github


Readme

Takes a github account, creates html pages for it, and puts it on Github pages.

How it proceeds.

  1. Get data for specified account from Github API
  2. Uses Jinja2 to write ReST docs.
  3. Build html from the ReST docs.
  4. Pushes the html to a Git repo from which you build github pages.

tl;dr: Yo dawg, I heard you like github, so I put a github in ...

more info..
shabda
Comments
Reactions

I am so starving: Web app in python frameworks.

By : Shabda Raaj

I have written the same web app in various web frameworks. Get it from Github.

Copied from the Readme.

This is a set of apps which creates the same application in various Python web micro-frameworks.

The app(s) talks to Facebook, and finds out recent people who have posted a public status with the text "so starving".

This idea came from reading Onion.

We have the same app in these frameworks.

Microframeworks:

Full stack frameworks:


If the framework included template engine and caching, that was used directly. Otherwise ...

more info..
Topics : python
shabda
Comments
Reactions

Getting trending Github projects via YQL

By : Shabda Raaj

Github.com/explore allows you to see the trending Github topics. They use repopular.com for this, which use twitter retweets to find out the popular Github repos.

Since neither Repopular, nor Github have a RSS of these trending repos, I wanted to get a list of these. Here is how easy it is with YQL.

How we do it

  • Go to YQL console. Give the SQL query to get the data from the webpage.

  • where url="repopular.com" and css="div.pad a" is the magic which select the webpage, and also what DOM elemenst we are interested in ...

more info..
Topics : django API
shabda
Comments
Reactions

Essential web-apps to run a software business.

By : Shabda Raaj

We work on a variety of products and with people. We work in a highly distributed environment, with all of our clients working remotely from us. And while we work out of the same office, we are frequently working from other places as well. Here are the tools which help us stay productive, sane and working. :)

For our open source projects we use Github.
For our client and non OS projects, we use Unfuddle.

For our client code we need both SVN and Git, and we need tickets which can be assigned to people. Both ...

more info..
Topics : business
shabda
Comments
Reactions

Django is not flexible

By : Shabda Raaj

Django is not flexible at all because you can not do simple things like.

more info..
shabda
Comments
Reactions

Moving home

By : Shabda Raaj

Tl;dr version:

We are moving our site from Uswaretech.com to Agiliq.com. Please update your book marks and the like.

Longer version:

We have moved. Our new, cool, and amazing site is Agiliq.com. Built with Django, pixie dust and pink unicorns, its is sure to amaze you. Please update your bookmarks.

Gory details:

If you are client of ours, the Unfuddle and billing details would be changing soon. (You should also have received an email from ...

more info..
Topics : meta about
shabda
Comments
Reactions

Rails and Django commands : comparison and conversion

By : Shabda Raaj

The most commonly used Rails commands and their Django equivalents

Rails | Django

rails console | manage.py shell
rails server | manage.py runserver
rake | None
rails generate | None
rails dbconsole | manage.py dbshell
rails app_name | django-admin.py startproject/manage.py startapp
rake db:create | manage.py syncdb

The salient points to note are,

  1. Django has all commands via manage.py, Rails has it broken into rails and rake.
  2. Overall there are more Rails+Rake commands available than Django commands
  3. There is no one to one mapping between Rails and Django commands. Eg. There are no equivalent to rake doc:* or rake ...

more info..
shabda
Comments
Reactions

The Rails and Django models layer Rosseta stone

By : Shabda Raaj

Rails Active records and Django models are more similar than they are different. This is a quick guide to converting between Rails 3 and Django 1.2, and is available on github at http://github.com/uswaretech/Acts-as-Django

Defining models

Both Django and Rails keep the canonical database representation in ruby or python.

#Django

class Post(models.Model):
    name = models.CharField(max_length = 100, )
    slug = models.CharField(max_length = 100, )
    body = models.TextField()

class Comments(models.Model):
    post = models.ForeignKey(Post)
    username = models.CharField(max_length = 100, )
    comment = models.TextField()

#Rails

#db/schema.rb
ActiveRecord::Schema.define(:version => 20100319195739) do

  create_table "comments", :force ...

more info..
shabda
Comments
Reactions

Doing things with Django models - aka - Django models tutorial

By : Shabda Raaj

Django abstracts most of the actions you would be doing with the Database. What it doesn't abstracts, and doesn't try to abstract is the Database modelling part. This is a quick tutorial describing to how model your data in Django models.py, and how to access and modify them.

Consider a hypothetical HR department, which wants you to build an application to track and manage their processes. They have employees who work for a department, contractors who work for multiple department. Let's see how you you would do that in Django.

from django.db import models

class ...

more info..
shabda
Comments
Reactions

Wordpress and Django: best buddies

By : Shabda Raaj

Summary: How to integrate a non Django database system in your Django code, using Wordpress as example. The completed code is available at github or you can see some screnshots


Though there are quite a few good Django blog applications, our blog is based on Wordpress. A number of plugin's make moving to a Django based app a bad decision for us, and not in the spirit of "best tools for the job".

We moved the other way, and decided to use Django to admin the Wordpress database. The completed code is available on Github

It is not too ...

more info..
shabda
Comments
Reactions

Doing things with Django forms

By : Shabda Raaj

Forms are one of the best features of Django. (After models, admin, url routing etc :) ). Here is a quick tutorial describing how to do things with Django forms.

  1. Basic form

Prob. You want to show a form, validate it and display it.

Ans. Create a simple form.

class UserForm(forms.Form):
    username = forms.CharField()
    joined_on = forms.DateField()

This wil take care that the form is displayed with two text field, and a value for them are filled in, and the second field has correct formatting for a date.

2.

Prob. Create a form which has values populated depending upon a ...

more info..
shabda
Comments
Reactions

Tools of Pro Django developer - aka What powers dinette and almost every app we write.

By : Shabda Raaj

There are some tools and apps which we use with almost all apps we write, and in particular which, we used for dinette. Here they are broken into useful during development, and (also) useful post development.

During Development

  1. Ipython and ipdb
  2. South
  3. Django test utils
  4. Django extensions
  5. Django debug toolbar
Ipython and ipdb

Ipython is a enhanced shell for python. Ipdb similarly add extra capacity to the builtin pdb debugger. It is extremely convenient to drop into a ipython shell right where a complex piece of code is being hit.

from IPython.Shell import IPShellEmbed
ipython = IPShellEmbed()
ipython()

Of course ...

more info..
Topics : python tips
shabda
Comments
Reactions

django-forum

By : Shabda Raaj

twitter ready version:

We have released a Django forum application, with some cool features not in any other Django based forum. You can get it here or see it in action.

blog version

There are quite a few Django based forum applications, so why another? Its a bit of a rhetorical question, as the answer is "none of them met my needs exactly, so we created my own", as you might expect.

Without further ado here is a list of features. It is available on uswaretech.com/forum/.

  • Based on, inspired by and ripped from PunBB. (Thanks!)
  • PunBB like 3 ...

more info..
Topics : django utilities apps
shabda
Comments
Reactions

Django-buzz

By : Shabda Raaj

We have updated the Django popular stories widget, which powers the widget in the side bar. It is now on Github.

Earlier the code used was hardcoded to only find Django stories, but now you can create arbitary topics from admin.

Get the code and create the widgets on your servers, (or let us know, and we will create it here if it is interesting). We created three we want to track. Databases, Python and Javascript

Databases

Python

Javascript


We build amazing web apps. Talk to us to discuss what we can do for you.

more info..
Topics : Uncategorized
shabda
Comments
Reactions

Django quiz

By : Shabda Raaj

A quick django quiz. Answers available tomorrow. Get it as a text file (django-quiz) or on google docs or read below.

### Easy

1. You have a class defined as

    class Post(models.Model):
        name = models.CharField(max_length=100)
        is_active = models.BooleanField(default=False)

You create multiple objects of this type. If you do
Post.objects.get(is_active=False),

what exceptions is raised?

a. MultipleObjectsReturned
b. ManyObjectsReturned
c. SyntaxError
d. MultipleModelReturned
e. ManyModelReturned

2. Where is the function render_to_response defined?

a. django.views
b. django.shortcuts
c. django.templates
d. django.contrib.templates
e. django.contrib.shortcuts

3. What is the ...

more info..
Topics : django tips meta
shabda
Comments
Reactions

The magic of metaclasses in Python

By : Shabda Raaj

Metaclasses are a way for you to have a class act as the template for another class. They are simlar to a classfactory, in that they create new classes. In words of Tim Peters Metaclasses are deeper magic than 99% of people are going to need.

However, in right hands they can be a potent tool, in particular Django uses metaclasses beautifully to create very beautiful declarative models. Without further ado, here is a very simple (and very wrong) metaclass example.

class Z(type):
    def __new__(cls, name, bases, attrs, ):
        print cls, name, bases, attrs

class A(object):
    __metaclass__ = Z ...

more info..
Topics : Uncategorized

Writing your own template loaders

By : Shabda Raaj

Django has three builtin template loaders which are used to get the templates for rendering.

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

Writing your template loader is a awfuly easy. It is a callable which

  1. Returns a tuple of (openfile, filename) if it can find the template.
  2. Raise TemplateDoesNotExist if the templates cannot be found.

The simplest template loader can be

from django.template import TemplateDoesNotExist
def load_template_source(template_name, template_dirs=None):
        try:
            return open(template_name).read(), template_name
        except IOError:
            raise TemplateDoesNotExist, template_name

if you put this to your template loaders directory ...

more info..
shabda
Comments
Reactions

Django gotchas

By : Shabda Raaj

This is announcement about our new work, Django Gotchas, a teeny tiny ebook about commonly occurring gotchas with Django. Here is the readme copied from the project.


Django-gotchas is a collections of gotchas which happen commonly when you are working with Django. They are some errors which I have made commonly or seen others do, these are not the errors which happen because they are hard to reason about, these are those errors which hapen when you close your eyes for a moment when coding.


This is still very much a work in progress, released in the spirit of release ...

more info..
Topics : django book tutorial
shabda
Comments
Reactions

Django-SocialAuth - Login via twitter, facebook, openid, yahoo, google using a single app.

By : Shabda Raaj

TL;DR version: Here is an app to allow logging in via twitter, facebook, openid, yahoo, google, which should work transparently with Django authentication system. (@login_required, User and other infrastructure work as expected.) Demo and Code.Longer version follow:


We are releasing our new app. Django-Socialauth. This app makes it awfully easy, to allow users to login your site using Yahoo/Google/Twitter/Facebook/Openid. A demo is available here.

This is released under an Attribution Assurance License. A copy of the same is provided included with the code.

After installing this app, you can use @login_required on any view ...

more info..
© Agiliq, 2009-2012