Dougma (dŭg·mə) n.

  1. An authoritative principle, belief, or statement of ideas or opinion, especially one considered to be absolutely true by Doug; who is often wrong.
  2. A specific tenet or dougtrine authoritatively laid down, as by Doug.
  3. A system of principles or tenets, for Doug.
August 16th, 2007

Potter Silverlight PyCon-Tech Storm sans Pocky

As life is short I will start at the end with dessert and mention that I am out of Pocky.

There is a lot going on, so consider this a quick overview of things to come (maybe).

Executive overview: Potter good, Silverlight/CLR amazing, PyCon-Tech kicking, Storm brewing, and send more Pocky.

I did finally get a chance to read the last book of Harry Potter. I broke down on vacation and went to the Book Exchange, a great used book shop. I spent about an hour visiting and rediscovering some old friends, and left with one new one. (Translation: I perused books I love, buying the first two John Saul books I ever read, and picked up HP7.) The only negative of the entire book was the epilogue. It was either too short, or too long. I would have either liked to know a bit more, or done without it. There, how is that for no spoilers? Oh, and I am ranked #37 on potterpredictions! (which is now accepting comments) Given some of the predictions people added, I suspect some gaming of the system (i.e. some people read the images posted online the week before the books release).

Just before going on vacation, there was the July Cambridge Python Meetup, on Silverlight by Chris Bowen. This was a fantastic presentation, with live running demonstrations, including a python interpreter running in firefox, with the same objects being accessed in python, javascript, and VB! I know, I know, VB… But just think about it. It’s 100% in the browser, and the same object is accessible in all virtual machines at the same time (because it is really a common VM under it all). No, it’s not slow. Say what you want about Microsoft, but you cannot say they do not do innovative and revolutionary work. Well you can say that, and people do; they are just wrong. I will do an extensive writeup on this topic later, including the (extremely poor) audio of the talk and information on the linux port later. I should also note that Chris did a fantastic job and weathered some rather pointed questions quite well.

It’s PyCon-Tech Time!!!!! I would like to give a special thank you to Noah Kantrowitz for hosting the new PyCon-Tech Trac site. This means we now have a proper bug tracking system, and a roadmap! So come to the online meeting, give feedback, and join the fun. There is a ton of work to be done. We need people to take screen shots of the system running for documentation. We need code documentation. We also need some good examples of talk proposals (most likely taken from previous years). We will also be adding some cool new features to the system. things like change history, atompub feeds, comments in the schedule, social network integration, and will be fully functional even if you have no javascript. Oh, and if you think the web site is ugly, clustered, confusing, and think you can do better? Great! Let’s talk! Thought I was going to say ‘do it’? No, I don’t expect some mythical web guru to come in and replace the entire web design and whip a site out of their proxy. It’s all about a team effort.

Tonight was the August Cambridge Python Meetup on Storm by Chris Armstrong. Storm is an ORM for a new machine management system called Landscape. I have spent some time looking over Storm and reversed my initial reaction to it. I really like the multiple database support, and the advanced caching (more like instance management) is fantastic. It is very verbose, but very slim (huh?). Many of the issues I have with the Django ORM are solved by Storm. Unfortunately all the things I love about the Django ORM are missing. It is just a very different take on DB-Object mapping than other systems, and yet looks very very similar to all the others. The python classes are not special. There are no meta classes, nothing to inherit from, no ‘magic’. Well there is SOME magic, but it is relatively thin. All in all a very contradictory system ;-) I will have a much larger post going into details on this soon. I have the presentation, and will post the audio. I was able to get my hands on a wireless mic, mixer, noise filter, amp, and digital recorder. That means the audio, for once, does not suck.

Immortal words of Gabe, ‘…tell them to bring more Pocky‘.

August 9th, 2007

Monkey goes to Montana

Like most other children, our son has a favorite item, a little stuffed monkey, aptly named, monkey. Monkey went with us to Montana, and here is a Tabblo immortalizing the trip from his unique perspective.


NOTE: There is a picture of us standing around a broken frostfree hidden in there.

August 3rd, 2007

Django template navel gazing

or staring at grains of salt.

I am currently very very frustrated as I am trying to create a brine for making a nice smoked shoulder for a party Saturday and for the life of me, I have been unable to find pickling salt! Pickling salt is very very fine and does not contain the anti-clump agents (usually corn starch and potassium nitrate), and iodine (that which makes the ocean smell like the ocean). It also dissolves in cold water. Regular table salt gives pickles or brined meats a brown-orange color, can add a somewhat ‘fishy’ smell to them, and does not readily dissolve in cold water. Defiantly not what I want for smoked pork. I am heading to a local ethnic butcher in the morning to pick up my meat order, and I am hoping they have some. All this reminded me I wanted to make a post about the recent discussions around the default template system in Django.

There are a number of posts about logic in Django templates. The short version for those who do not want to do a bunch of reading:

  • Django template logic contains a minimal set of functional operators, but no real logic operations (i.e. you can’t write {% if len(items) < 3 %})
  • Why not just use python as the template language?
  • You can use other template engines in Django, the doc is very poor on this, or how such integrations would work.
  • Django tries to strike a balance and meet the 80/20 rule for template use cases or ‘hit the big bulgy part’ of the bell curve of users.
  • Complex logic in templates is bad. The language should be minimal, and designed for UI writers.
  • Complex logic in templates is good. UI writers are not stupid, give them power!
  • Design is now in CSS, and HTML is the structure, thus an integral part of the programming producing that structure, not design.

Ok, that is the extreme cliff notes version, and I apologize if I am misrepresenting anyone here. There are many good points being made and some differences of opinion. I have my own opinions here, but first lets see what a very experienced PHP expert has to say on the matter circa early 2006:

Hopefully you found some simple ways to improve your template design, but also recognised that some complexities can arise when doing this and sometimes comprimises must be made.
One (simplified) way to look at it is like this:

You should be able to completely change templates, including all image files and CSS files, without having to touch any of your PHP files.

All fundamental data required in your templates should be fetched or determined ahead of time and assigned to your templates (this doesn’t include meta data, such as the length of a string, etc.).

That bolding is the authors emphasis, not mine. I believe the Django template system helps make this type of separation between templates and logic. I agree with Jacob that it strikes the right balance and hits that sweet spot. There was another blog post which summed up my feelings quite nicely, but of course, I cannot find it for the life of me. For PyCon-Tech I added a lot of logic to the templates. I felt I could make up the difference in the CSS. For some of the CSS, I templetized that as well! I made custom template tags for modifying the local context (variable evaluation and assignment no less), and went so far as to have a filter which modified and saved the model! The Idea there was if you included or extended the template, you were viewing that data, and you wanted to update the ‘last_viewed’ record.

PyCon UK is using PyCon-Tech, for the proposal system at least. But the templates are so complex, and the logic for the structure is very difficult to integrate into another site which is not based around having the navigation style of us.pycon.org. The end result is the coolest applications will not be used. The templates are code, and thus the structure is part of the code. The end result is, the templates are not templates, they are code. It might as well be python, and thus to use the conference framework for your conference of choice, you must change the code. This is with old Django functionality even. YUCK! My main mistake here is that I have much of the page structure determined by user permissions which are determined in the template. Once you make that decision, it kind of cascades to everything else.

Now some people have no problem with this, and are smart enough to keep their html structure generation code clean enough that CSS is all you need to change (Plone comes to mind here). For those people, I guess there is nothing wrong with python as the template language. Coincidentally I was talking with a friend about implementing PHP in python recently. We came to the conclusion that this would not be too hard to do. It would require a bit of encoding magic, a custom import loader, a module level meta class, some minor monkey patching to __builtins__. Now there is no need to do all this if what you want is python as the template language. For that, a custom encoding, and a module level metaclass should be enough:

# -*- encoding: python-template -*-
<%python
import pytpl
__metaclass__ = pytpl.metaclass
python%>
<head>
<title>foo</title>
</head>
<body>
<%python
for i in xrange(30):
    echo(i) # importing pytpl, and the metaclass adds echo to the module global namespace,
          # maybe it does a magic_escape? wait, thats another post…
python%>
</body>

This is basicly a pybraces on steroids, and adding an ‘echo’ and maybe some other minor additional helper functions. The encoder code builds a template document model for the local contexts and replaces them with ‘echo’ calls for that text. All echo does is add the text to a document or string queue. the metaclass deals with things like adding a __main__ block which if run from the command line will print the string queue to stdout. If a imported as a module, well there are other features added to the module like functions for adding variables (context) to the template, dealing with other template imports, getting the rendered string, etc. I have no real desire to work on such a project, but some times an idea grabs a hold of you. Why not use python as the template language? Well I have my opinions on why I would never use such a system, but that is my choice.

|