Posts

Thoughts on Django

What follows are some thoughts on django written by Isaac Alston, a friend of mine from university. He originally wrote it as a facebook note, but after reading it I asked if I could re-post it here. I think he gives an enlightening point of view on the experience of a python newcomer beginning to use django . Here it is: This is a short review of my experience with Django ( http://www.djangoproject.c om ). Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. In November, I was informed that the company I am working for would be leaving PHP behind. We had been looking for a faster, and cleaner development tool for a while and were deciding between Ruby on Rails ( http://www.rubyonrails.org/ ) and Django. I had a preference for Django immediately, since I could already program in Python, whereas Rails required Ruby skills. After much debate and discussion, my company eventually chose to use Rails. My co-worker, flatmate and (dare...

django newforms for models

The way django does forms is in a state of transition. There's the old (or, depending on your point of view, current) way, manipulators , and the new way, newforms . newforms is only available in the svn version of django at present, and is still incomplete. Despite this, newforms is usable and provides several compelling advantages over the old way. The docs at present are a little thin (although improving quickly), but the unit tests are full of useful examples (the stuff towards the end is the most interesting, and shows off some of the flexibility of newforms). One thing that would be nice, though, is a way of easily creating a form class that uses a model class's fields. If we have this, we can avoid needless and tedious repetition. Django recently got a function that can be used for this, newforms.form_for_model. It's a start, but there are a few things I'd like it to do that it currently can't. I'd like to use the model's specified defaults, if any, ...

What is wrong with Berlios?

Berlios hosting was once a great replacement for Sourceforge and others. But these days it seems we have more downtime than uptime. I don't blame them (I am sure they have their reasons why nothing is ever available) but I do understand that I need something better to host my open source projects with. While we do bug tracking, and source-code hosting with Malone and Launchpad already, there is no provision on the Launchpad for hosting distribution files, and so we have had to painfully search for alternatives. For now we are going to go with Google code. This is not perfect for our needs, but it will replace everything we need Berlios for except for hosting the PIDA website, which can be easily arranged elsewhere. The main pain will be updating all the links around the web that point to the Berlios website. But that will come in time, and I am sure that PIDA users are bright enough to click a redirect link! For now the new project page is: http://code.google.com/p/pida/ And we als...

PIDA 0.4.0 Released

After a slightly quiet spell (also known as an extended beta period) we have released PIDA 0.4.0. What kind of open source author would I be if I didn't push my own software on my blog! My favourite feature on this release is built in pyflakes. When you save a Python file it runs Pyflakes on it for you and prettifies the output into a GUI list for you to browse through, click on, and jump to the line number. All in Vim, as usual. Please try it, at http://pida.berlios.de/

More on Python Dates, adding time with a datetime.timedelta

I needed a date 2 weeks in the future. I needed it quickly. After blogging about Python dates, I thought I had a clue how to do it. To my relief the first attempted path of least resistance just worked! Here it is: >>> from datetime import date, timedelta >>> today = date.today() >>> two_weeks = timedelta(days=14) >>> two_weeks_time = today + two_weeks >>> today datetime.date(2006, 12, 6) >>> two_weeks_time datetime.date(2006, 12, 20) >>> This was used to automatically populate a column in an an old database: which wanted to be an expected_date = order_date + two_weeks.

Oracle from Python in Linux

Well, pretending to know everything can have its downsides. Like when the boss says "Could you hack up a script to enter custom data into our 3rd party invoicing software?". One choice is to admit that you would not know where to start. The other would be to attempt to muddle through. "Of course, let's have a look". So an hour later we have discovered that the software in question uses an Oracle back-end: Excellent, this is going to be easy, Oracle is an relational database (I read once somewhere) and we learned SQL at university, so it can't be that hard. So, step one: boot into windows, and use the command line client to do some stuff. Great! The SQL is coming back to me already. But this is no good. I can't use windows! The single desktop is beginning to upset me, and well we need it running on Linux so I can feel leeter than my coworkers. So what will we be needing? 1. SQLPLUS for Linux (this the the command line client for Oracle). Should be easy en...

Python Dates

At first glance the datetime module in the python standard library (full documentation available at http://docs.python.org/lib/module-datetime.html appears as an insane mish-mash of things. The types it makes available are date, time, datetime and timedelta. My initial confusion stemmed from the fact that the module name is the same as one of the type names (datetime and datetime.datetime) and this is one of the only times when I have thought that naming types in camel case is a good idea: datetime.DateTime might have been a saner approach. Nevertheless, we continue: A datetime.time is a time, a datetime.date is a date, and a datetime.datetime is a date with a time. A datetime.timedelta is a difference between any of these times. Simple enough. Usage of these types can be made easier by using their "alternative constructors" which are a set of class methods, and can in some cases be more useful than the actual constructor. For example: >>> from datetime import date...