Living on the Edge

This Week in Django 28 - 2008-06-30

Posted on July 01, 2008

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

This week we talk about quite a few source commits (kicking-ass), some cool projects from the community, the Tip of the Week, and a question from the IRC.

Let us know if downloads are better for those of you in Europe.

Please see the Show Notes below for all the pertinent information and links

Downloads

AAC Enhanced Podcast (50.3 MB, 1:01:06, AAC)

MP3 Edition (42 MB, 1:01:06, MP3)

OGG Edition (32.9 MB, 1:01:06, Vorbis)

The Enhanced Podcast version contains screenshots and easy access links to all of the items we discuss throughout the podcast.

Feeds Available

iTunes Feeds are available. By subscribing using the iTunes feeds the podcasts will automatically be downloaded for you when we release them.

iTunes Feeds

This Week in Django – AAC Edition

This Week in Django – MP3 Edition

Regular RSS Feeds

This Week in Django – AAC Edition

This Week in Django – MP3 Edition

This Week in Django – OGG Edition

Give Us Feedback

Want to give us some feedback on the show? We’re always looking for ideas or suggestions that will help improve each episode. Please contact us at feedback __at__ thisweekindjango.com.

Show Notes

Big News

Malcolm Tredinnick is back!!!

Tracking Trunk (1:08)

Community Catchup (19:28)

  • Kss in DjangoKSS is a javascript framework that aims to allow Ajax development without javascript. It uses stylesheets with CSS-compliant syntax to setup behaviours in the client and a set of well-defined commands that are marshalled back from the server to manipulate the DOM.

Tip of the Week (43:49)

Ever need to reorder the fields on your Model Form?


class TranslationForm(BookForm):
    translator = forms.CharField(max_length=40)

    def __init__(self, *args, **kwargs):
        super(TranslationForm, self).__init__(*args, **kwargs)
        self.fields.keyOrder = ['title', 'author', 'translator', 'publisher', 'copyright']

IRC Ad Nauseam (47:10)

Django IRC FAQ

Backwards Incompatible Changes Information

Charlie O’Keefe say, “I’ve gotten into designing restful URL schemes, basically organizing a web app around resources. Learning Django I was frustrated to find that nothing seems to be done this way. Is there any tool that can help with that?”

Thank You! (50:58)

IRC Personals

Posted on June 27, 2008

I think I’m hanging out in the wrong channels:

Thanks Alex Gaynor, that was very creative.

Bill Gates Unhinged

Posted on June 26, 2008

I love stuff like this. It’s always nice to see the human side of someone like Bill Gates. With the volume of antitrust suits against the company, I imagine we’ll be seeing this kind of material for a long time to come.

“Someone decided to trash the one part of Windows that was usable? The file system is no longer usable. The registry is not usable. This program listing was one sane place but now it is all crapped up.”

and continues…

“The lack of attention to usability represented by these experiences blows my mind. I thought we had reached a low with Windows Network places or the messages I get when I try to use 802.11. (don’t you just love that root certificate message?)”

Hard to believe this was from 2003. Five years ago and nothing has changed…

The Website Is Down

Posted on June 25, 2008

If you have a few spare moments, you have to check this out. I’m pretty convinced this guy works for me. Thank you Jezdez for the cool links.

SQLAlchemy Code Swarm Visualization

Posted on June 24, 2008

Someone please stop Brian Rosner. He’s out of control. Although I must say, no surprises on this one.

Words Matter

Posted on June 24, 2008

You have to word your invitations carefully. Depending on which way this goes, I might just cozy up to a nice glass of wine.

Django Code Swarm Visualization

Posted on June 24, 2008

In the closing remarks of This Week in Django 26 Brian Rosner pointed out a code swarm visualization created for Python as well as a couple of other open source projects. Well, in typical Brian fashion, he couldn’t leave well enough alone, so he created a wicked cool Django Code-Swarm Visualization. Definitely check this out. Thanks Brian.

This Week in Django 27 - 2008-06-22

Posted on June 23, 2008

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

This week we talk about the Django Software Foundation, some source commits, some cool projects from the community, a Tip of the Week. and a couple IRC items. It’s a packed show.

Please see the Show Notes below for all the pertinent information and links

Downloads

AAC Enhanced Podcast (55.8 MB, 1:08:08, AAC)

MP3 Edition (46.8 MB, 1:08:08, MP3)

OGG Edition (38.5 MB, 1:08:08, Vorbis)

The Enhanced Podcast version contains screenshots and easy access links to all of the items we discuss throughout the podcast.

Feeds Available

iTunes Feeds are available. By subscribing using the iTunes feeds the podcasts will automatically be downloaded for you when we release them.

iTunes Feeds

This Week in Django – AAC Edition

This Week in Django – MP3 Edition

Regular RSS Feeds

This Week in Django – AAC Edition

This Week in Django – MP3 Edition

This Week in Django – OGG Edition

Give Us Feedback

Want to give us some feedback on the show? We’re always looking for ideas or suggestions that will help improve each episode. Please contact us at feedback __at__ thisweekindjango.com.

Show Notes

SPONSOR: This Week in Django is brought you by Justin Lilly, who according to all historic accounts, once scissor kicked Angela Landsbury. Thank you Justin.

Big News (2:18)

New foundation for Django – Lawrence-Journal World announces new Django foundation and code commits change license ownership.

Tracking Trunk (5:02)

Branching and Merging (9:50)

Community Catchup (15:57)

  • DebugFooter Redux – Last week we talked about Andreas Marr very cool Django Snippet to add debug information into the footer of each webpage. This week he did it one better based on some suggestions from our program. Now that’s what I call Podcast Driven Development™.

Tip of the Week (43:22)

This tip comes from Alexander Solovyov in his blog post Render To Improved.

Sometimes you want to return a RequestContext from a view. One way to do that is to specify the response code using a decorator.


@render_to('mytemplate.html')
def myview(request):
  return ({'id': 1, 'name':'empty'})

# example with override
@render_to('mytemplate.html')
def myview(request):
  return ({'name':'empty'}, 'override.html')

# python 2.3 example with override
def myview(request):
  return ({'name':'empty'}, 'override.html')
myview = render_to(myview, 'mytemplate.html')

You can also return a tuple where the second item is a string that overrides the default template specified in render_to.

IRC Ad Nauseam (51:11)

Django IRC FAQ

Backwards Incompatible Changes Information

What’s the difference between Abstract Base Classes and Multi-Table Inheritance?

Abstract Base Classes are where you provide a base class, like Person, and then a derived class like Employee. Django will create a single database table for the Person model that contains the combined fields from both the base and derived classes.

Multi-Table Inheritance also has the base and derived class but at the database level you end up with two tables: one for the base class and one for the derived class, with a one-to-one field added in to connect the two.

Again, we highly recommend the excellent post by Kevin Fricovsky that we mentioned in Community Catchup. Plus, as always, the excellent Django documentation.

Is there a way to pass the filter arguments as string to the QuerySet?

QuerySet parameters are standard Python keyword arguments, and can use standard keyword argument expansion.


Post.objects.filter(datetime__year=2008)

Post.objects.filter(**{'datetime__year': 2008})

Thank You!

Hacking Pythons

Posted on June 23, 2008

Someone is very creative. I love it!

“What the hell is going on? This is fucking incredible.” Jacob Kaplan-Moss said. Kaplan-Moss is the chief architect of Django and said nothing like this had ever happened before. “They’re all naked, and these chicks don’t shave anything!”

Werkzeug Debugger in Django

Posted on June 21, 2008

A new feature to come to the Django-Command-Extensions project is the implementation of a new management command called runserver_plus. For now the “plus” part means that I’ve replaced the standard Django traceback pages with the Werkzeug Debugger traceback page in it’s place.

Getting Started

This item requires that you have the Werkzeug WSGI utilities installed, in addition to the django-command-extensions app.

To get started we just use the `runserver_plus` command instead of the normal `runserver` command:


$ python manage.py runserver_plus

 * Running on http://127.0.0.1:8000/
 * Restarting with reloader...
Validating models...
0 errors found

Django version 0.97-newforms-admin-SVN-unknown, using settings 'screencasts.settings'
Development server is running at http://127.0.0.1:8000/
Using the Werkzeug debugger (http://werkzeug.pocoo.org/)
Quit the server with CONTROL-C.

Note: all normal runserver options apply. In other words, if you need to change the port number or the host information, you can do so like you would normally.

Using

Whenever we hit an exception in our code, instead of the normal Django traceback page appearing, we see the Werkzeug traceback page instead.

Along with the typical traceback information we have a couple of options. These options appear when you hover over a particular traceback line. Notice that two buttons appear to the right:

The options are:

View Source

This displays the source below the traceback:

Being able to view the source file is handy because you are able to get more context information around where the error occurred. The actual traceback areas are highlighted so they are easy to spot.

One awkward piece about this is that the page is not scrolled to the bottom. At first I thought nothing was happening because of this.

Interactive Debugging Console

When you click on this button a new pane will open up below the traceback line you’re on. This is the money shot:

An ajax based console appears in the pane and you can begin debugging away. Notice in the screenshot above I did a print environ to see what was in the environment parameter coming into the function.

Summary

I’ve only been using the Werkzeug debugger on my Django projects for a day now. But I’m loving it. I encourage you to check it out. Plus if you’re not a current Django-Command-Extensions user, you’re going to find tons of really cool additions in there.

WARNING: This should never be used in any kind of production environment. Not even for a quick check into a problem. I cannot emphasize this enough. The interactive debugger allows you to evaluate python code right against the server. You’ve been warned.