betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

17 August 2011

Chameleon PT Checkboxes

It's the same... almost the same

With pyramid, web developers have the choice to use various templating engines. Coming from Zope, "Chameleon ZPT Templates" are a good choice, as they are compatible to the ZPTs I've gotten used to over the years. The thing is, these templates are compatible, but there are differences.

One thing that had me wondering was how to set the "checked" attribute on checkbox input fields. In Zope's ZTPs, you can do something like tal:attributes="checked somevariable" and if somevariable is evaluated to True, then the checked-attribute will be set to "checked", otherwise it will not be there at all. It's a special case that is necessary for the way some browsers handle this attribute.

In Chameleon's PT, I got a lot of "None type is not callable" errors, or else it would show the box as checked when it shouldn't... and I was overall confused. Turns out the incantation that works for me here is something like this: tal:attributes="checked 'checked' if somevariable else None". It seems in order to not insert the "checked" attribute, Chameleon PT wants the value to be None, but it doesn't like python's True for a value either, therefore putting in the string 'checked'.


Posted by betabug at 09:56 | Comments (0) | Trackbacks (0)
23 August 2011

Reading on Board

Pick a book

So, I'm on the boat again. Going to Naxos. It's the 2nd time this summer. It's also the 2nd time I did not bring the Arca with me. Just got the little Canon, with some donated old Fuji Sensia slide film, which I plan to cross process in C41.

The ebook reader (Bookeen Cybook Opus) works out very well for travelling. I can put it into the side pockets of my shorts and pick it up whenever I want to read. The obvious nice thing is to have a library with you on the go.

I'm catching up on some of the classics - and as if by coincidence, lots of the stuff has to do with the sea.


Posted by betabug at 10:19 | Comments (0) | Trackbacks (0)