RPI Printer List
Just a simple application I implemented to learn the basics of wxPython and wxGlade. This simply page scrapes a specific page on RPI's helpdesk website (which lists all the printers available in the network) and caches it locally. This local cache is displayed via a front-end interface that supports simple filtering by building, room, printer name, costs, or output. Double-clicking on any entry will connect to it (and add it to the list of printers accessible to your computer).
This makes it relatively simple to add a printer you need to access in campus.
Note: Connecting to the printers assumes that you are using the newer pmanager1.win.rpi.edu to authenticate to the campus network. If you wish to use pmanager.win.rpi.edu, then pass the argument pmanager.win.rpi.edu to the executable. Simply modifying the shortcut to include this parameter will make the application always startup with this setting.
You can download this program here.
Beginning to Code
Okay, now we're ready to start writing code! In normal Django development, you want to plan out what data your database will contain, this is important. This is due to one current flaw in Django: that Django lacks a schema evolution system. Django can only reset or create tables, but not modify existing ones.
Once you've planned out your data structures for your database, you can start creating models. Models describe how your data is stored in the database and any extra metadata your application needs to be aware of but the underlying database system may or may not be storing.
For this tutorial, I've already have a set of models designed (with some consideration for features not implemented in this tutorial series). We're going to have 4 model objects:
- Room: this contains room information, such as name, owner, etc.
- Message: this contains the actually message a user sends.
- Membership: this model associates a Room with a User (aka, we know that user can view this chat room)
- Attachment: this contains file upload information that may be associated to a particular message.
Model definitions are fairly easy to make. Let's make the Room model:
from django.db import models
import datetime
class Room(models.Model):
name = models.CharField(max_length=200)
created_at = models.DateTimeField('created at', default=datetime.datetime.now)
def __unicode__(self):
return u'%s' % self.name
Most of the code is simple. The first two lines imports the Django Model class that Django provides (which makes model definitions extremely simple) and we import the native python datetime module for, you guessed it, time functionality.
In the Room class definition we simply define properties to that tells Django what type of data each property stores. These properties are mapped as fields in the database.
For example, the name property we set stores a string (char or varchar in database terms) with a max length of 200 characters. The other two properties are just as readable. The first parameter for nearly all Field functions is a human-readable name of the field. In the case for the name property, Django will just use the field name. Also, the __unicode__ method provides a display-friendly output of a particular model (which we're outputting the room name). The friendly names are for Django's automatic admin.
Reading up on Django methodologies
DjangoCon 2008: Reusuable Apps
You can click on the lnk above to see the video about how Django apps should be designed. This was really enlightening for me as it further reinforces when and what applications should be in Django. Rather than be monolithic feature set, there should be an application per feature of your application.
The examples given in the video were an application for user registration and a seperate application for user profiles. James also says that a typical "simple" project should have at least a dozen applications instead of just a few applications in the INSTALLED_APPS list.
Unfortunately for me, the series of tutorials I'm making for Django chat does not follow this philosophy. I'll still continue with this route for now, but sometime further in the future, I'll consider rewritting it and rewrite it.