1. Skip to navigation
  2. Skip to content

Entries in the Category “Python”

Django 1.1 Testing and Debugging

written by Michael Trier, on Jul 6, 2010 9:39:00 PM.

I’ve been wanting to write this post for about four weeks now, and finally I have a chance to follow through on it. A little over a month ago I picked up Karen M. Tracey’s new book, Django 1.1 Testing and Debugging by Packt Publishing. It’s been surprising to me that I’ve heard little in Django circles about this book because it fills a very nice space that has been a huge void in the Django world for some time. Testing within Django has always been something I’ve struggled with. The platform has never really “encouraged” testing in a way that I was used to in the Ruby on Rails or Pylons world. Likely this was more of an internal personal struggle of trying to figuring out how to fit testing within my workflow within the Django world than an actual shortcoming in the framework. For me, Ms. Tracey’s book was exactly what I needed to put things into perspective and to get clarity on an appropriate testing workflow in Django.

The book is very well written and quite readable. I found only a few minor code problems, and likely the result of chasing an ever evolving framework than actual oversight. I was able to digest the book over three days and began to put some of the teachings in the book into practice immediately.

The book starts off with some basic testing setup items and discusses testing approaches. Quickly Ms. Tracey moves into talking about doctests. Although I’m not a huge fan of doctests, I found the discussion easy to follow and Tracey does a great job of presenting the advantages and disadvantages of doctests. In chapter three Unit Tests using TestCase are covered and again Ms. Tracey does a very thorough job of covering the pros and cons of this approach. There were two areas of the book that probably helped fill in gaps for me the most, the chapter on using Client to do integration tests and the chapter on integrating third-party test tools. I still haven’t had a chance to dig into Twill but I definitely want to experiment in using Twill for my integration tests. The last half of the book is spent talking about debugging approaches and figuring out how to find and solve problems with your code. Although I personally didn’t get a lot of new information out of this section of the book, programmers new to Django / Python will find it to be an excellent resource in outlining the options that are available when things go wrong. The book finishes up with a chapter on moving your applications to production, debugging production problems, and load testing your applications.

I really only have two criticisms of the book and they are both minor. In chapter 5 where Ms. Tracey discusses integrating Django testing with third-party tools, I thought the book should have gone a little deeper. Coverage and Twill are covered in depth but not a lot of time is spent on using Nose as a test runner other than to provide the basic approach. I understand the book is not about extending Nose but it would have been nice to have a bit more to work with there. The only other criticism of the book was with the final chapter. Although there’s useful information in the “moving your app to production” chapter, it seemed out of scope for this book and a subject matter that is really deserving of an entire book itself. That said, I did enjoy the discussion on load testing and found it very helpful.

In summary, if you’re developing with Django this is another “must have” book in my opinion. There’s so much good information in this book, and it is presented in a very readable and easy to understand way. I’m planning to order a copy for each member of my team.

I'm Alive!

written by Michael Trier, on Jul 5, 2010 11:14:00 PM.

Yes, I’m alive! The past six months have been grueling and a ton of hard work but definitely worth it. I’ve ignored pretty much every aspect of life except for coding. And I’m talking about heads down, all night, coding. It’s what I love; it’s who I am, but still after a certain amount of time you feel like you need to come up for air.

Well I’m coming up for air. I’ll be posting more to my blog, I’ll be contributing more to open source projects like SQLAlchemy, I’ll be working on some of my own stuff, and I’ll be entertaining my brain in whatever interests me at the moment. If that’s all you care about then know that I’m back. If you want to know more about what I’ve been doing then read on.

For the past year I’ve been involved in a very large project at work. The project involved the redesign of our websites at Presbyterian Church (U.S.A.). The first two sites went live this past week. They are:

http://www.pcusa.org/

http://gamc.pcusa.org/

Both sites are built on Python. So in addition to building out these sites, I’ve also been training and transitioning my development team to Python programming. That means a lot of Python 101 / 102 classes, pair programming, code reviews, and unit testing. To say we’re transitioning is a bit of an overstatement. In one sense we’re transitioning from .NET development, but in another we’re not. We’re supplementing the current architecture with Python. Most upcoming projects will make more sense if written in Python, but not all. Regardless, we’ll always use the right tool for the job.

Things have been going quite well and I’m very pleased with where we are at the moment. Hopefully I’ll have an opportunity to talk about some of the interesting technological and architectural decisions we’ve made along the way. Until then I’m happy to be back in the game.

GitPython Release 0.1.6

written by Michael Trier, on Jan 24, 2009 9:33:00 PM.

I just released GitPython version 0.1.6. This version has some backwards incompatible changes to be sure to read through the changes below before upgrading.

GitPython is a python library that makes it easy to interact with Git repositories. The emphasis so far has been on introspection and less on manipulation, although some manipulation level functionality is present. For a good tutorial on getting started, check out the source distribution documentation files.

This version includes Sphinxification of the documentation. If you haven’t worked with Sphinx yet, I highly recommend it for documenting your projects. I just touched the surface with it and I was really amazed on the “out-of-the-box” functionality.

I hope you enjoy GitPython.

CHANGES

General

  • Added in Sphinx documentation.
  • Removed ambiguity between paths and treeishs. When calling commands that accept treeish and path arguments and there is a path with the same name as a treeish git cowardly refuses to pick one and asks for the command to use the unambiguous syntax where ’—’ seperates the treeish from the paths.
  • Repo.commits, Repo.commits_between, Reop.commits_since, Repo.commit_count, Repo.commit, Commit.count and Commit.find_all all now optionally take a path argument which constrains the lookup by path. This changes the order of the positional arguments in Repo.commits and Repo.commits_since.

Commit

  • Commit.message now contains the full commit message (rather than just the first line) and a new property Commit.summary contains the first line of the commit message.
  • Fixed a failure when trying to lookup the stats of a parentless commit from a bare repo.

Diff

  • The diff parser is now far faster and also addresses a bug where sometimes b_mode was not set.
  • Added support for parsing rename info to the diff parser. Addition of new properties Diff.renamed, Diff.rename_from, and Diff.rename_to.

Head

  • Corrected problem where branches was only returning the last path component instead of the entire path component following refs/heads/.

Repo

  • Modified the gzip archive creation to use the python gzip module.
  • Corrected commits_between always returning None instead of the reversed list.

This Week in Django 38 - 2008-09-22

written by Michael Trier, on Sep 24, 2008 10:46:00 PM.

This Week in Django is a weekly podcast about all things Django.

This week we do a DjangoCon retrospective, feature a special live interview with Pownce developers Leah Culver and Mike Malone, discuss a few source commits and some cool projects from the community.

Check it out…

DjangoCon - Enjoy the Fun

written by Michael Trier, on Sep 16, 2008 2:08:00 PM.

Last weekend I had the unique privilege to attend and participate in DjangoCon, the first international Django based conference. It was a wonderful experience and I had the great opportunity to meet a lot of incredibly smart people. I was especially excited to be able to participate by Moderating two discussion panels and doing the This Week in Django show live. The whole thing was held at Google, which is just amazing, and they recorded all of the presentations and have made them available. I encourage you to enjoy the fun. note, if you want higher quality videos watch them on YouTube and select “watch in high quality”. I participated in the following:

Panel: Django Technical Design

A technical design discussion panel featuring core developers: Jacob Kaplan-Moss, Adrian Holovaty, Simon Willison, James Bennett, Malcolm Tredinnick. This one was a ton of fun and I only wish we had more time. I had a bunch of questions that I did not get the opportunity to ask, and others that were covered in prior keynotes so I thought it was best not to harp on them any longer.

Panel: Schema Evolution

A panel discussion on Schema Evolution and three popular approaches to this problem for Django. Featured project leads Simon Willison (dmigrations), Russ Keith-Magee (django-evolution), Andrew Godwin (South). This panel had some spirited discussion on schema evolution and their different approaches. It seems that there are enough similarities that we will hopefully see some collaboration among the projects.

TWiD Live

Michael Trier & Brian Rosner do a live presentation of the This Week in Django podcast. We were a bit nervous about this one since in our regular weekly podcast we have an opportunity to stop and start or do certain item over again. With the exception of a couple of minor mistakes it turned out great and was tons of fun. I was quite surprised by the number of questions that were asked. The only bummer about this one right now is that it cuts off the intro and the outro, but we’re trying to get Google to restore that.

Django 1.0

written by Michael Trier, on Sep 3, 2008 7:46:00 PM.

Well it’s finally here. Django 1.0 is the moment a lot of us have been waiting for. It’s a very exciting moment for the Django team but even more so for the development community at large. It represents a huge milestone in the web framework space.

Django, without a doubt, brings forth some incredibly innovative ideas that help take web development to the next level. So I am pleased to be a part of this, in some small way, but also looking forward to what’s next for Django and its popularity as a web framework.

If you haven’t had the pleasure to experience Django I encourage you to do so now. You’re programming mind will thank you for the experience.

This Week in Django 36 - 2008-08-31

written by Michael Trier, on Sep 3, 2008 1:35:00 PM.

This Week in Django 36 has been posted. It’s a great episode with our special guest James Bennett. Hear James talk about the book, the blog, speaking, and a whole lot more.

This Week in Django 35 - 2008-08-24

written by Michael Trier, on Aug 26, 2008 12:21:00 AM.

This Week in Django 35 has been posted. Don’t miss it. We catch up with Robert Lofthouse, Chairman of DjangoCon and EuroDjangoCon.

Django Docs Refactor

written by Michael Trier, on Aug 23, 2008 6:40:00 PM.

Django documentation has been refactored (Changeset 8506) using the excellent Sphinx – Python documentation generator. This is the same package used to generate the new Python documentation Check out the new docs at http://docs.djangoproject.com/. Now I have to go and update all my shortcut snippets. Thanks go especially to Jacob Kaplan-Moss and numerous contributors for all of their hard work on this one.

This Week in Django 34 - 2008-08-17

written by Michael Trier, on Aug 18, 2008 11:11:00 PM.

This Week in Django 34 has been posted.

This week we discuss Django 1.0 Beta 1, a bunch of source commits, some cool projects from the community, and a tip of the week.