Michael Brunton-Spall on Django, The Guardian
Find me on
  1. On 03rd of February, 2010 at 17:48
    Posted in Django, Python, PyCharm

    Did you see my link a few days ago, about PyCharm being released by JetBrains?  I hope so because it is a very interesting IDE for python and django developers.

    Introduction

    PyCharm attempts to up the Python IDE stakes, by bringing the expertise of the rather brilliant IntelliJ Java IDE to the python world. The idea is nice, and the execution is good, especially with the Django integration.

    Installation

    Installation was as simple as downloading the linux tar.gz file and extracting it.

    My first issue was that on a 64 bit system, it fails to start up with the message 

    Error occurred during initialization of VM
    Could not find agent library on the library path or in the local directory: yjpagent

    This is because it attempts to load a library for java profiling that is 32bit compatible only.  The easy workaround is to edit bin/pycharm.vmoptions and delete the line "-agentlib:yjpagent=disablej2ee,sessionname=PyCharm".  I think you could also download the 64 bit version of yjpagent and put it in the lib or bin directory, but haven't tried it yet.

    Google App Engine

    I did open directory and opened an existing Google App Engine project, which opened quite nicely.  I immediately got some nice warnings to let me know that I was not overriding some methods correctly along with a spurious error that self.request and self.response are unresolved attributes.  I guess that's a slight problem, the IDE can't possibly know that webapp.RequestHandler.initialise will be called before the get method, and since the __init__ method doesn't create those attributes the IDE can't be sure that they exist.  

    This kind of bug is the exact reason that python IDE's are hard, and not as helpful as in Java.  In Java the fact that RequestHandler has a request attribute would have to be declared in the class.  Since in python it doesn't, the IDE can't tell what type that attribute is, and therefore can't autocomplete the methods on it.  So using this for the App Engine webapp framework is no better than any other application.

    Django

    I next opened the pure django implementation for this website.  I had a weird issue here.  I use pip and virtualenv to ensure I have the correct version of django installed for each python project I build.  However PyCharm doesn't support a per project set of library dependencies, and my work machine doesn't actually have django installed system-wide.  I installed Django 1.1 system wide, and using Settings -> Python Interpreter -> Reload I was able to get PyCharm to reload.

    I was struck by some issues immediately.  Where I was previously doing import home.models I now need to include the project name, so import bruntonspall.home.models.  I also have a funky bit of python path manipulation in my settings.py, unfortunately PyCharm doesn't seem to handle them properly.  So several of my imports did not work anymore, which caused weird warnings everywhere.

    Final Thoughts

    This is only an early access program, and I will admit that for creating a new project from scratch, for general python programming this is as good an IDE as I've used.  It doesn't handle all of the really weird behaviours that I've started to use in my django projects, but for non-advanced systems it's probably highly useful.

    The biggest issue as far as I am concerned is the lack of good support for virtualenv, pip and pythonpath modification in settings.py.  It's possible that I've missed something, and the next few days I'll be using it heavily to test it out and find out what it does well, and what it does poorly.

  2. On 01st of January, 2010 at 15:13
    Posted in The Guardian, Web Development, Python, Scale Camp, Personal

    So as 2009 draws to a close, I look back over the year and consider what has happened.  With this being the end of the decade for everyone but pedants (that will be another year yet), I've also thought about the previous decade.

    10 years ago I was halfway through my degree, determined that I would become a famous game designer, or at least be designing with a  major games studio.  I was still determined not to become a programmer, and instead wanted to spend my days fiddling with excel, scripting langauges and writing design documents and so forth.  Fast forward 10 years and I'm now working as a programmer in the web industry, speaking at conferences and even organising conferences like scale camp!

    This year has been real fun, I've really settled into my role at the Guardian newspaper, and the coming year will hopefully see me extending that role into more developer evangalism focused areas.  I was pleased to recently read a list of a number of technologies that one "must have used" in 2009, including a NoSQL datastore, a dynamic language framework and a non-blocking long poll framework such as node.js.  I've had the opportunity this year to spend time using Reddis, Django, Python and even a brief play with node.js and the tornado framework.

    How about resolutions for 2010?  Well I'd like to increase the quantity and quality of my blogging.  That will hopefully mean writing more often, as I'm repeatedly told that the best way to improve ones writing abiity is to practice it as often as possible.  I wont promise any particular update schedule, as I've tried that before, but rest assured like all new years resolutions, january will be more active before I get bored and forget to do any more!

    I also wish to try my hand at some more new technologies, trying to keep up with the changes in the industry and the way in which programming is changing.  The main aims for the early year is going to be trying to have a play with Yahoo Application Framework and the Facebook platform, and trying out some more social tools to explore the concepts and patterns involved.

    I hope you have had a great 2009, and have a good new year and an enjoyable 2010.