a blog by Marius Gedminas

Posts tagged Python

Random hackery

We finished a rather major restructuring of the internals of a system last week at work. I finally got to experimentally test Martin Fowler's refactoring techniques (small steps) on a big change. It was fun and I tended to stay late at work because I wanted to finish what I was working on. I missed that feeling. Oh, and Subversion is good, but merging is a big inconvenience. During nights I worked on PySpaceWar: added sound effects, support for background music (but didn't look for freely redistributable soundtracks yet), some visual effects, some more configuration options.

Easy Zope 3 forms with formlib: add forms.

A short tutorial of zope.formlib. Here's how you create an add form for a notional content object Fruit: # This is the mypackage.browser module from zope.formlib import form from mypackage.interfaces import IFruit from mypackage.fruit import Fruit class FruitAdd(form.AddForm): form_fields = form.Fields(IFruit) def create(self, data): # In our example Fruit class has an __init__ # that accepts all the fields as keyword arguments return Fruit(**data) Here's how you register it in ZCML