betabug... Sascha Welter

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

Entries : Category [ pyramid ]
Stuff concerning the pyramid web development framework.
[digital]  [language]  [life]  [security]  [media]  [zope]  [tourism]  [limnos]  [mac]  [athens]  [travel]  [montage]  [food]  [fire]  [zwiki]  [schnipsel]  [music]  [culture]  [shellfun]  [photography]  [hiking]  [pyramid]  [politics]  [bicycle]  [naxos]  [swim] 

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)
25 October 2011

Always writing tests

It's the way of the egyptian

The coding standard in the Pyramid project is something that I attempt to get closer to. One thing that's there is that code always has tests. So in the current project (which happens to be using Pyramid), I make sure that code has 100% test coverage.

Sometimes it's a bit of a pain though. "Just let me write that one little method and I'll be done! The tests will only be bother!"

But then I start writing the tests anyway and $#!@ if there aren't a bunch of bugs being flushed out of the code. Writing tests simply pays off.

Posted by betabug at 19:26 | Comments (0) | Trackbacks (0)
07 November 2011

Welcome to Betabug Sirius

My new Company Site

It has been quite some time that I announced that I'd be working as a freelancer. Lots of stuff had to be done in that time, but finally things are ready. I've founded my own little company and set up a small website: Welcome to Betabug Sirius!

For once this isn't a "ZWiki-As-A-CMS" site (which is what I usually do when I want a site to go up fast), but a plain, static html site, done in vi. I know it won't scale when I'll want to expand it, but I had fun coding it up in the old style.

So far I already have a few customers, working with Zope (mostly in bugfixing and maintenance of existing / legacy sites) and with Pyramid (building a brand new web application). There is also a project to build something unique and "our own" on a longer horizon, involving technology and art.

There has been and still is a lot of bureaucracy, but so far the ride has been smooth and sometimes even fun. Part of the strategy is to work together with other companies to form flexible teams for each project. That's something that has worked real well so far, giving me fun and inspiration to work with others.

Posted by betabug at 10:26 | Comments (7) | Trackbacks (0)
06 October 2012


Hacking till the drinks are on fire

So, here I am, on the other corner of Europe. Together with graffic we flew via Madrid to La Coruna and then drove with Wu to his place in Lugo. Yesterday we started "sprinting" on our customer's pyramid app. Sprinting, what's that? It means that for some days we work really concentrated on programming this thing. It also means that for once we're working in the same room instead of cooperating over the net.

It's really great to work with these guys. Yesterday r0sk was working with us too. We got tons of things done already, despite "wasting" some hours at the start having a meeting about what to work on first. Now the sprint will continue till Tuesday and then we'll have our queimada and we'll be relaxing in the countryside of Galicia for a while.

Posted by betabug at 11:40 | Comments (1) | Trackbacks (0)
29 May 2015

Starting a New Project Naively Sure is Easier

Experience is not always an advantage

Starting a new pyramid fun project with some friends here. Sometimes I think that having experience with another pyramid project isn't always helpful. Instead of just writing my simple objects and growing them, I'm thinking: "well, for this kind of thing, we added xy and yz, and we made a feature to ..." and then instead of coding along, I'm sitting there, thinking if adding that feature right away makes sense, and if I should copy that bit of code or not.

Sure I could start with the simpler objects, but then I'd have to migrate them later on. On the other hand, if I try to do it all at once now, I can just sit there with a cup of tea for a couple of days and try to "waterfall" it all through. Have to find some middle ground somewhere, and have to accept that at least initially "migration" will be to the tune of "throw away your database and start over". Gotta get moving.

Posted by betabug at 18:04 | Comments (0) | Trackbacks (0)
31 March 2017

fstail in ZODB

Just a little peep into the inner workings

Back in my Zope days, I once hunted for some writes to the ZODB being too big. I wrote a post called "Quasi-Normal in Numbers" about the experience. Back then I checked the size of the Data.fs file in the file system.

Nowadays I'm more into using Pyramid instead of Zope, I still use the ZODB (what can I say, it works well for me). And I still get sometimes the problem that a write puts in too many Bytes (or even kBytes) into the DB.

I've moved ahead though: Instead of checking the size of the database file on the file system, I discovered fstail. It's a little script that examines the end of the DB file and displays the last 10 transactions. (By default, actually you can use the parameter -n to get more). I didn't find any documentation of it, so I had to read the source and figur it out as good as I could.

So far I haven't solved today's problem, but I managed to solve a small sub-problem: I had some transactions that were committed by my code, and I couldn't identify them in the output. So today I learned to put some info onto that transaction:

url = getattr(request, 'url', 'no url')
note = "mymethod %s " % (url,)
transaction.get().setUser(user, path='')

With this I can at least identify which of the transactions are caused by manually committing the transaction in my code at that spot.

Note: fstail comes with ZODB, so in my Pyramid virtualenv, it's already in the virtualenv's bin directory, ready to use: fstail -n 20 /path/to/Data.fs.

Posted by betabug at 20:30 | Comments (0) | Trackbacks (0)