Older blog entries for butchland (starting at number 1)

  • More Zope adventures

    I'm working on a new project -- I'm trying to develop a set of tools that I can use to test Zope products -- in effect, marrying Steve Purcell's PyUnit with Zope. My objective is to create a set of unit tests for any Zope product or even internal Zope components... which will then enable me to do XP-style refactoring stuff for my Zope projects...

    I've thought about several approaches (including doing this via the medusa monitor) but I think the best approach is to access Zope objects via the publish_module methods in the ZPublisher module...Of course, the downside of this approach is that I can't test the ZServer side of the Zope stuff -- but since I'm not likely to be doing anything on that part of Zope, this is just fine for me (and probably for a lot of other Zope developers as well).

    Where I am now: I've gotten to the point where I can call any object via its url string (e.g. '/index_html') and get the HTML output. I think I can use this to build a coarse-grained unit testing framework -- I can capture the HTML output, stick in some file, then run the unit test by comparing the HTML output from current run with the HTML output from a file...

    Where I'd like to get to: I want to be able to access the actual objects and call their individual methods (e.g. -- DTMLMethodObject1.__call__(client, REQUEST, RESPONSE,...)). Then I can do fine-grained unit tests.

    One of the things I need to add is some setup routines to create fresh copies of the ZODB -- I can't get a ZODB to get back to its original state even if i start undoing transactions and packing it...I've also tried deleting everything and packing... its just not at the same size as it was before...

    More Later...

  • Zope Adventures

    I just downloaded the latest version of Zope (2.2) last Friday and started figuring out how it worked all over again.

    It's been awhile since I touched anything Zope (or even Squishdot) -related so I'm fumbling over stuff a little...

    One of the nice things that's been added is the Zope Tutorial -- its bundled with the basic Zope distribution, but its not documented anywhere so you just kinda stumble into it while futzing around the management interface...

    I started downloading and playing around with some of the Zope Products. I found some of them worked and some didn't... -- for those that didn't., I couldn't figure out whether it was me who simply wasn't doing it right or whether it simply was broken... I'm just guessing how many other people couldn't figure them out either (and just turned them off away from Zope) .

    One problem I had was that it was very hard to figure out which Zope products (including the ones from DC) still worked with the latest version... I'm suspecting it has a lot to do with the jump from 2.1 to 2.2 (which set up a new security mechanism -- of which I have no idea what had been changed -- haven't had time to grok the new security how-tos) broke a lot (well, ok, some) of these products... My guess is that some of the broken products won't be fixed pretty soon simply because they've been abandoned or their author(s) doesn't have the time to fix them...

    Of course, another problem was that even the quality of these Zope products varied greatly -- some were 'toy' products -- early attempts (some even abandoned attempts) at grokking the Zope Zen... while some were really polished applications that had gone through extensive debugging... but you wouldn't know it right away (unless you searched through the docs, mailing lists, etc. or tried it yourself -- which was what I did)... Documentation quality also varied greatly -- from NONE to ones with lots of nice explanations and examples...

    What would really be nice would be a "ratings" system that kinda gave you an idea of the quality of the product right from the get-go...although two things might derail this: 1) what if product authors started getting shy about publishing their work for fear of getting negative reviews? and 2) what if the product users hesitated from giving negative reviews for fear of discouraging the product authors?

    Minor nitpick: There are some products (written by authors who really should know better...) that unpacked themselves incorrectly by not supplying the correct path from the installation home directory -- this is pretty common (and well-known) "standard" that's followed by most -- why can't they even bother to follow it?

    One good change I've found since I last worked with Zope is that there's more documentation now... but you have to know your way around the site(s) to get what you want quickly... good thing I'm pretty familiar with the layout so I generally found what I needed when I needed it...

    So anyway, I started hacking...

    A digression:BTW, this is how I usually work with Zope -- I use the management interface (ie. through the browser) to create the DTML methods then I use ftp to download/upload the files between my editor and the management interface... too bad this doesn't work with ZClass methods -- they're not visible through the ftp interface...

    So anyway, after getting tired playing around with some of these products, I started futzing around with PythonMethods. After searching through the Zope.org, I found a neat example that built a comics webpage. I copied it and followed the install instructions, ran it and of course, it didn't work. The nice thing was it could be converted to a python program and I could run/debug it as a regular python program... took me about 15 minutes to make it work. I converted back to a python method, and it ran under Zope...cool... Now I had a web page full of funnies. But...

    It ran kinda slow... I think it had something to do with all the gyrations it had to go through to figure out the url of the comics image from all these different websites... It would all be fine if I could cache it then just refresh the cache once a day... so I go off and look at caching solutions...I found one (SimpleCache) but it only refreshed itself if any of its dependent objects were updated... So I figure...umm... If i build a method that updated itself, and if the cache was set to be dependent on this then the cache would refresh itself too, -- but I had to have something that would call this method once a day... so I figured... maybe I could use Loren Stafford's ZScheduler to do this...

    Except when I tried to use it, I couldn't make it run... it kept coming back with an error... I tried looking for examples that worked, including the simplest one I found, but nothing worked... so either it didn't work or I just couldn't figure out how... so I got stuck...(and that's where I left it)...

    Anyway, I took a fresh path and started another futzing project... this time with the Calendar product... This one worked the first time out like a charm... Jon Udell had written a nice article that got me started... I added a simple ZClass-based Event object that had a date associated with it and also cataloged itself so I could use the Catalog in combo with the Calendar product to list events scheduled for a particular day... I zoned out... built an Add page that added events (complete with validation)... so now I had a toy scheduler...my mind is now buzzing with all the ideas on where to go with this one...

    More later...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!