Jacob Kaplan-Moss

PyCon Braindump

I wrote this post in 2008, more than 16 years ago. It may be very out of date, partially or totally incorrect. I may even no longer agree with this, or might approach things differently if I wrote this post today. I rarely edit posts after writing them, but if I have there'll be a note at the bottom about what I changed and why. If something in this post is actively harmful or dangerous please get in touch and I'll fix it.

PyCon 2008 Brain Dump

There are some great roundups of the content at PyCon out there; this isn’t one of them. See, I have this notebook (Moleskine FTW!) I carry with me everywhere, and now it’s chock-full of note from PyCon; this is a braindump.

  • EAV

  • Mammoth replicator

  • Django 1.0 will support Python 2.3, but later releases likely will not. We’ll need to start working on moving to Python 3.0, and that means slowly dropping other Python versions until we reach 2.6 and can start using 2to3.

  • PEP 302.

  • import_in_py

  • You can nest {% regroup %}:

    {% regroup issues|dictsort:"client" by client as client_groups %}
    {% for client_group in client_groups %}
      <h2>{{ client_group.grouper.name }}</h2>
      {% regroup client_group.list|dictsort:"category" by category as category_groups %}
      {% for category_group in category_groups %}
        <h3>{{ category_group.grouper.name }}</h3>
        <ul>
          {% for issue in category_group.list %}
            <li>{{ issue }}</li>
          {% endfor %}
        </ul>
      {% endfor %}
    {% endfor %}
    
  • A pretty standard cache eviction strategy:

    def something_detail(request, something_id):
        key = "something:%s" % something_id
        value = cache.get(key)
        if value is None:
            value = calculate_value(something_id)
            cache.set(key, value, 600)
        return do_something_with(value)
    
    ...
    
    class Something(Model):
        ...
    
        def save(self):
            cache.delete("something:%s" % self.id)
    
  • Trestle:

    Trestle is a nose plugin that enables you to write testable documentation for web apps (or shell commands, but more on that later).

    To use trestle, write a reStructured Text document using a set of special directives to indicate the fixtures to be used for testing (including the http or mock http client), each request to be sent via the client, and the expected response from the application under test.

    Nice!

  • Saturday House

  • Thrift

  • pyxpcomext

  • haufe.eggserver

  • argparse

  • PythonSpeakers

  • Supervisor

  • “Guns don’t kill people; Magic Missiles do.”

  • This, apparently, is the year of Django on alternate VMs:

    • Django on Jython
    • Django on IronPython
    • I also saw a demo of Django on PyPy, but can’t seem to find a writeup. It’s not totally working yet because of some of the juju we do in django.dispatch, but that’ll be fixed (on our end, that is) shortly.

    I think this means that Django is the first web framework to run on four different VMs. Wonder if anyone’s working on Django on Parrot…

  • Speaking of PyPy, the sandbox is amazing.

  • Signals are finally getting a rewrite:

    class_prepared = Signal(...)
    
    ...
    
    class_prepared.connect(listener)
    
    ...
    
    class_prepared.send()
    

    The old API will still work, of course.

  • SnapLogic

  • SNPedia

  • python4ply

    for line in open("python_yacc.py"):
        if line =~ m/def (\w+)/:
            print repr($1)
    

    I can’t decide if this is brilliant or disgusting. Both, I suppose.

  • pvote:

    Pvote is prototype software for electronic voting machines. […] The current version is 460 lines of Python.

  • Transitive Grace Period Public License (“TGPPL”)

  • A few different takes on concurrency in Python:

  • An idea for multiple database connections:

    from django.db import connection
    
    class SomeOtherDatabase(connection.Connection):
        engine = "sqlite3"
        name = "/tmp/whatever.db"
    
    ...
    
    # Import data from the other database...
    OtherPerson = SomeOtherDatabase.ModelWrapper(Person)
    for p in OtherPerson.objects.all():
        Person.objects.create(**p.__dict__)
    
  • We’re improving INSTALLED_APPS:

    INSTALLED_APPS = (
        "some.app",
        app("some.app", label="other", db_prefix="whoa_")
    )
    
  • WebError

I need some more sleep.