Tuesday, June 20, 2006
Trac Spam
The pages that are most viewed are the ones with code examples on them, and the spammers were kind enough to delete that code, making the pages useless. The code is now restored and can be referenced again. In particular, the following projects were impacted most heavily:
I've now got the wiki set for auth users only. If you want to contribute to the wikis, just send me an email.
Monday, June 19, 2006
Nevow Needs a Screencast
Case in point: on a *whim* I decided to migrate a site I built last year in z3 to nevow. I had a spare hour, so what the hell. It took me *minutes*. And I don't mean 6487 minutes -- I mean 30 minutes. Here's what I did:
- Copied HTML output from the other site and used as the basis for an XHTML template
- Copied CSS and images from the other site
- Wrote a backend data store that uses RFC 2822 (python's email package)
- Wrote a ui.UI class, subclassing nevow.rend.Page (including children, data calls, etc)
- Added data and render calls in the XHTML template
- Wrote a .tac file
- Populated 5 RFC 2822-compliant files with data and headers for the content
- Started up the server and watched the new site scream
Let me emphasize a crucial point here: *none* of that was stubbed. No helper-scripts. No installers. There was pre-existsing HTML, CSS and images, and that's it. I did some dicking around and tweaking in the process, so I'm *sure* I could do the whole thing -- from start to finish -- in less than 20 minutes. Probably 15.
I don't understand why more developers aren't using Nevow. It just kicks ass. Yeah, every platform has its issues, and Nevow's no exception. But DAMN. I get record-setting development times with it, it runs fast, and it's insanely flexible.
Saturday, June 03, 2006
Sets as an Elegant Alternative to Logic
A few years ago I was working on a sub-project of CoyoteMonitoring
where we were writing a database "layer" for the file system,
essentially allowing us to query for files using standard SQL commands.
We needed to do some exclusionary logic for filtering bad user input.
Though mathematically equivalent, I deal with Set Theory and Logic very
differently: I'm a set guy, and I really hate using series of if/else
statements for problems that lend themselves easily to an approach that
is "set theoretic" (we're talking super-mundane set stuff -- nothing
really sexy).
changes I had made that eliminated a series of ugly ifs:
[03-Oct-2004 02:02]you know, we could do this really
quickly with sets :-)
[03-Oct-2004 02:02]check this out:
[03-Oct-2004 02:02]lets say our table has 4 fields:
[03-Oct-2004 02:03]['A','B','C','D']
[03-Oct-2004 02:03]and we're doing a select for ['D', 'A',
'C']
[03-Oct-2004 02:05]and lets say we've got a bad query
['Z', 'B', 'C']
[03-Oct-2004 02:07]then, if we perform a set difference on
select
tables against defs, the returned set will be zero
[03-Oct-2004 02:07]and if we do the same with bad against
defs,
we'll get a non-empty set, in this case a set with one element, 'Z'
I then shared some python 2.3 code (no built-in set object) that
basically illustrated the changes I had made. For me, the results were
much more readable. The code was certainly much shorter.Since then, I've found all sorts of uses for this approach. I've
recently made use of this in a Nevow project that has to authenticate
off of a Zope instance. There are a series of group and role names that
can be qualified under one of three "group-groups" (tiers):
Later in the code, we do checks like this:
# setup sets for each class of user
admins = set(cfg.user_database.admin_roles)
libs = set(cfg.user_database.tiertwo_roles)
vols = set(cfg.user_database.tierone_roles)
# and then a convenience collection
legal_roles = admins.union(libs).union(vols)
I like this much more than explicitly checking for the presence of
if admins.intersection(avatarRoles):
return IAdministratorResource
elements in lists.
Baz Camp, Day 1
Well, the folks at tummy.com have done
it again :-)
Baz camp is rocking. We're right on
the lake, with beaches and 90-degree weather in Loveland, CO... so you
can imagine that the view is most agreeable :-) We not only have
wireless access donated by the most gracious local provider
LP Broadband, but some of
the boys brought a big-screen projector for outdoor movies at night as
well as satellite TV. So yeah, we're *really* roughing it.
chili!) and the menu has been just great. We've got shaded gazebos up,
tents. Watched Primer and Hackers last night (Hackers was enjoyed a la
MST3K). Sean shared Icelandic treats he brought back from the Need for
Speed sprint, including fish jerky. Yummy.I also happen to be getting a lot of work done, too :-) All offices
should operate like Hack Camp.Hey Radix: why aren't you here? Evelyn Mitchell and I were talking
about fellow social geeks and agreed that this would be just your style
:-)