ACCU Friday

Well we made it back to Indiana last night after about 12 hours of blissfully uneventful travel. Friday at ACCU/PyUK was fairly interesting, although not as “darn cool” as the Nokia presentation Thursday. After the previously covered keynote, the morning session on the Python track was John Pinner’s presentation on PayThyme, an open source, Python based payroll system. Even though John chose my presentation on Thursday as his nap time (from the front row, I might add), his presentation was one I had missed at PyCon, and which Vern had indicated was slightly interesting.

The most interesting thing about the talk was the brief discussion of business model. Clocksoft, John’s company, licenses their software under the GPL. While there may be valid skepticism about making money from support for commodity applications such as word processors and spreadsheets, John made an interesting point: everyone has to do payroll, no one wants to figure out the changes to the law every year. And since it is so integral to businesses across the board, everyone is willing to pay for a reasonable support contract. I think that if someone is looking to make money off of open source software, this is an important point: look deeper than the apps on “everyone’s” desk for the app that only a handful of people in the company use, but which is vital to operation: payroll, accounting, etc. These aren’t the sexiest apps to write, but people are willing to pay if they work right (and often, from my observation, even when they don’t).

The first block of the afternoon’s Python track was devoted to two XP related talks. First, about sprint driven development, and second regarding doctest. Both were interesting in passing, although I didn’t really learn anything new and spent most of the time playing with the Nokia Series 60 Emulator.

The final block of the day consisted of two talks I was looking forward to: Aspects in Python and Network Protocol Development with Generators. One talk met expectations, the other did not. First, I had hoped Aspects in Python would provide me with a greater understanding of what AOP is, and how it can be useful. Before the talk all I knew was that AOP consisted of marking areas of your code as able to be overriden or supplemented by other code. I’m not sure I really can answer the questions any better after the talk.

The real problem, I think, is that the presenter attempted to demonstrate how to implement a small-scale aspect system in Python, coming from a Java background. We have no lack of examples of people porting Java code to Python only to end up with Python code that doesn’t pass the “smell” test; that is, it’s right, it works (often well), but just doesn’t “smell” like Python, so there’s some aversion to continuing to use it. This aspect system was just like that. The biggest problem is that the presenter’s system went to great lengths to provide methods for wrapping code with common idioms, such as transaction handling. This in and of itself makes a great deal of sense, and is a great place to use decorators. But the presenter was resistant to decorators, calling them “Java annotations light”, and stating they “clutter” the code. Instead he advocated placing the wrapping (“weaving” in AOP terminology, apparently) after the code declaration, at the end of the module in his example.

Of course, when asked by a C++-track visitor how novice programmers could be made aware that the code they were editting was wrapped, he lamented the fact that there was no IDE support for AOP-in-Python today, and how that was often how Java programmers dealt with it. Instead, he recommended explicit commenting. I then commented that it seemed like he just made a case for using decorators instead of his approach, since it keeps the “weaving” and code close together and is often quite descriptive and explicit. He wasn’t convinced, and I wasn’t impressed.

The second talk was presented by Michael Sparks of BBC R&D on Kamaelia and Axon, their Python toolkits for creating single-threaded, psuedo-state machine network protocol implementations which they can use to test and development protocols for delivering multimedia to thousands of users simultaneously. The most interesting thing about their toolkit is the use of “inboxes” for communication between layers. That is, they have the idea of “inboxes” and “outboxes” in an object, which can be chained together to pass along responsibility for processing and handling.

For example, a LiveAudio object might have an outbox which consists of a raw PCM feed. An Encoder object’s inbox could be connected to that outbox to receive the raw feed, encode it in Ogg, and then pass it out to the inbox of a multicast server. Using Python generators, Axon and Kamaelia make this passing trivial, and the scheduler (which is currently a brain dead, straight forward approach, but could be replaced independently for better performance) activates the correct code object as necessary. Very cool.

Overall I’d say PyUK was a success. I came away with several ideas I want to explore, and saw some new things I hadn’t run into before. It’s hard to make a direct comparison to PyCon, however. Due to its ascociation with the ACCU, PyUK definitely has a more of a computer science focus. PyCon, on the otherhand, embraces non-CS applications along side really geeky discussions of optimizing memory management which is rather refreshing. Both are interesting in their own right, and I hope that the organizers of PyUK (er, Andy) continue to increase the offerings of talks next year, both in terms of quantity and overall quality. Good job guys, maybe I’ll cross the pond again next year for another go round.

date:2005-04-24 11:37:10

ACCU Keynote, Day 2

This morning’s keynote wasn’t nearly as interesting as Bjarne’s yesterday. I say this even though I have little desire to code in C++; I still enjoyed Bjarne’s keynote from a purly theortical perspective.

Jim Coplien gave a talk entitled “The Curse of Symmetry”, but I’ll be damned if I could figure out exactly what that curse was by the end of the hour. All I could figure out was, he thought it was bad, even though starfish and milk drops have some symmetrical properties. Oh, and Bjarne isn’t symmetrical. I was actually sitting directly behind Bjarne, and it was more interesting to watch him shake his head in what appeared to be anguish as Jim spoke. So at least I wasn’t alone. Who knows, maybe I was just part of the 50% that didn’t get it, but the other 50% loved it. I guess by my own definition, that’d make the keynote a success.

UPDATE: I forgot to mention the highlight of the keynote, which was a joke told by an audience member. I have no idea what the context was, but the joke was rather amusing:

So America was helping Iraq write their new constitution. But then they realized they weren’t using their own, so they could just give it to Iraq.
date:2005-04-22 04:51:02

Ourmedia @

I haven’t blogged about this (at all) yet, but I’ve been tangentially involved in the Ourmedia project for the past few months. Specifically I’ve been responsible for adapting ccPublisher to Ourmedia Publisher, which is their desktop upload tool. I figure I should announce here that the Ourmedia Publisher source code is now available at Sourceforge in the Ourmedia Projects.

As we move towards ccPublisher 2, it’s my hope that ccPublisher and Ourmedia Publisher will both become special cases of a more generalized code base, since they share 90% of their backend code.

date:2005-04-22 03:49:33

London Calling

So today was my first day at PyUK, which is being presented as part of the ACCU Conference. The day opened with a keynote on improving generic programming from Bjarne Stroustrup (of C++ fame). Bjarne’s presentation centered around the development of a concept he referred to as “Concepts”. Concepts attempt to completely and perfectly separate the declaration and implementation of templated code. If effectively implemented, they allow programmers to make predicate declarations about the signatures of templated code as well as the parameters. For example, without knowing type you could make the assertion that a templated function requires an iterable paramter. A crappy example, but the jet lag is still killing me.

After the keynote the Python track proper started. The remainder of the morning was consumed by Andy Robinson’s brief presentation on PyUK and the ACCU, a repeat of Greg Stein’s PyCon Google keynote, and an unscheduled appearance by a developer evangelist from Microsoft on IronPython. While the IronPython presentation was mostly a rehashing of Jim’s PyCon keynote, it was interesting for a couple of reasons.

First, the presenter (I really wish I could remember his name) went from zero to implementing a C# delegate in Python and calling it from Python in under 24 hours. Admittedly this was with the help of Jim’s slides, but it’s impressive none the less. It lends credence to Greg Stein’s 2-2-2 rule: You can understand Python in 2 hours, write Python in 2 days, and be proficient in 2 months. Second, it helps to allay my fears (somewhat) that IronPython is going to be given the short end of the stick by Microsoft. I can’t give any justification for my fears, it’s just a feeling. Hopefully I’ll be proven wrong.

After lunch, I presented a longer reprise of my PyCon talk on Desktop Applications. With a 90 minute time slot, I was able to go into some more detail on specific cross-platform issues, as well as talk about i18n for wxPython and the beginning of my testing framework implementation. Updated slides and the sample code are available. Despite the gentleman in the front row falling asleep (thanks, buddy), I think the talk was a success. If I had to guess, I’d say it was either too linear or too in depth for about half the audience, but the other half really got it and seemed to appreciate it based on the feedback afterwards. I call that a success. If I were to submit the talk again, I’d probably want to use the 90 minute material in a 45 or 50 minute slot, just so the pacing would be a bit quicker.

After my talk there were two more excellent talks. First was a presentation from Tallgren of Nokia’s R&D group. He presented historical and developmental background regarding Python on the Nokia Series 60. While it sounds like there are still issues to be worked out regarding distributing applications (i.e., how to distribute your Python app and the runtime in a single bundle), it’s definitly exciting to think about how it will lower the bar for development.

The final talk of the day was originally to be presented by Kevin Altis. Alex Tweedly, however, did an excellent job of discussing PythonCard. PythonCard is a simplified wrapper around wxPython. Altis’s development philosophy has been to focus on the simple tasks for which wxPython is too heavy, and that not all the wxPython functionality should be exposed to users. When I last looked at PythonCard, it was an interesting toy, but not something I felt would work for “real” development. I think I’ll need to look at it again to reevaluate that conclusion.

Tomorrow’s talks look excellent as well, and I’m looking forward to reading the new Knuth fascicles I picked up at the Blackwell’s display today.

PS: Apologies for the cheesy title… I couldn’t resist.

date:2005-04-21 15:24:46

A Plan for GUI Testing

During my presentation on Developing Desktop Applications with Python at PyCon last month, one question in particular intrigued me: “How do you handle unit testing for user interfaces.” My answer, at the time, was the paragon of short and accurate: “I don’t.” But I’ve been thinking about it since then, and I think I have an answer. This post is my attempt to work out the details in my head before actually implementing anything. I ran across Twill the other day. Twill is an application which allows you to execute scripts against web applications for the purposes of testing. You can find a sample script in the Twill README. This idea of scripts got me thinking about testing GUI applications. The thoughts went something like this:

  • If you want to test a GUI, you often want to make sure things happen in a certain order, or that changes to widgets (buttons pressed, etc) cause the correct change to occur.
  • I think I could script at least 75% (and maybe more) of the tests I’d like to perform in a fairly straightforward manner. I think.
  • Integration of GUI testing with unit tests would make my code better. I’m certain of this.

Of course, anyone who’s done much GUI programming, particularly with wxPython, knows that there is the problem of main loops and threads. The main loop is what listens for GUI events, and fires the correct methods. It’s also blocking (i.e., as long as your app is running, it’s running). In wxPython, trying to interact with the GUI from another thread is a sure fire way to crash things in a dramatic and spectacular way. But I remembered seeing a presentation on matplotlib at PyCon, and in it the presenter used the IPython shell to modify a plot in place.

IPython is an enhanced interactive shell for Python (and is incidentally also used by the Twill project). I got to looking at IPython last night, and found that doing something like:

% ipython -wthread

launches IPython, runs in a separate thread and dumps you at the interactive prompt. From there you can introspect into loaded modules, etc. You can’t access instances from the application, but that’s not a problem with wxPython. In wxPython, calling wx.GetApp() will return the application object (which is a Singleton for a given process), and the App has it’s own cooresponding method GetTopLevelWindow(), which returns the parent of all widgets and subwindows for the running application. Armed with these two pieces of knowledge, you can easily introspect the state of widgets in a running wxPython application from the IPython shell.

So let’s consider a hypothetical test for the classic “currency-converter” application:

tester = wxTester()

        make sure the appropriate widgets exist
    assert_ (tester.widgetById(“txtCurrency”))assert_ (tester.widgetById(“txtRate”))assert_ (tester.widgetById(“cmdCalculate”))assert_ (tester.widgetById(“txtValue”))

    tester.widgetById(“txtCurrency”).SetValue(“10”)tester.widgetById(“txtRate”).SetValue(“10”) (tester.widgetById(“cmdCalculate”))assertEqual (tester.widgetById(“txtValue”).GetValue(), “100”)

So you can see the wxTester class provides a convenience method, widgetById, for finding a widget by it’s unique identifier. I imagine we’d also want to have methods for finding widgets by numeric ID and possibly label, as well. These methods return the actual wxPython object, so you can make calls like SetValue and GetValue to interact with the UI.

I imagine that the click method is actually a special case of a more generic sendMessage method. Since clicks in wxPython (and most other UI toolkits) are sent as messages, we generate a mouse click message, and send it to the appropriate widget. This lets us emulate mouse interactions.

So what are the unanswered questions? Well, I’d like to use the existing unittest framework for running tests. This would allow me to take advantage of it’s convenience methods and error reporting. I think this will be possible; the wxTester object will find the running application’s top level window when instantiated, so you should be able to simply instatiate the object within a particular testcase method. I may also want to have the initializer for wxTester to also run the application script, so that each test starts with a clean instance.

Additionally, there will need to be some experimentation to figure out how to (essentially) run two scripts simultaneously: the tester script and the tested script. IPython has a %run command which allows you to run an external Python script with a given set of command line arguments, and still introspect into it. If the %run command is available from our test script, we have our answer.

Finally, this will require the use of IPython for executing test scripts. This isn’t a deal killer, but doesn’t thrill me. A possible future improvement would be to use the IPython source to instantiate the threads and magic from within a standard Python interpreter. And while we’re on the subject of future improvements for vaporware, some sort of GUI toolkit abstraction would make the library useful for more than just wxPython applications. Someday.

date:2005-04-14 19:00:39
category:development, pycon2005

Everybody Wants You

I’m doing some research on reasons for opposing same-sex marriage. I’m trying to take a step back from my obvious emotional ties to the issue, and making myself read the Family Research Council’s website. But this was just too good to pass up:

Why does “defending marriage” and “defending the family” require opposing same-sex unions? How does a homosexual union do any harm to someone else’s heterosexual marriage? It may come as a surprise to many people, but homosexual unions often have a more direct impact on heterosexual marriages than one would think. For example, the Boston Globe reported June 29, 2003, that “nearly 40 percent” of the 5,700 homosexual couples who have entered into “civil unions” in Vermont “have had a previous heterosexual marriage.”

So am I to read this as “if we legalize same-sex marriage, 40% of all married men will realize that they just crave cock and leave their chilly, overbearing wives”? Damn, Vermont’s in trouble.

update (14 April 2005) Since writing this post yesterday, I’ve realized my interpretation of the numbers was incorrect. It’s not that 40% of straight men will realize they’re gay, but that 40% of gay men were once in heterosexual marriages. The real implication of the FRC statement is that it’s better to stay in a dishonest, un-natural (assuming homosexuality is the natural state for those men) relationship than to leave and allow everyone to live more honestly. And I can’t accept that conclusion, either.

date:2005-04-13 14:24:59

CC at Notacon

Yesterday was the first day of Notacon in Cleveland, OH. While there was one talk devoted to a brief history of copyright in the US, the most exciting talk, for me, was completely unexpected.

Jerry Rockwell presented a talk called “Evolution of a Tune: My process of arranging and composing in a Home Studio.” I went because I have a MIDI keyboard hooked up to my iMac that doesn’t get nearly the use it should. Jerry’s talk was absolutely amazing, and it was done without the use of any props more advanced than a CD player. While I expected him to talk about the software and hardware he uses in his home studio, he instead focused on how he starts with a basic tune or melody, and builds layers and tracks on top of that. Coming from a folk and jazz guitar background, Jerry plays guitar, dulcimer and synth tracks (“my evolved click track”) to create amazing compositions.

So what’s the CC connection? Jerry demonstrated taking the traditional tune “Skip to my Lou”, and building completely transformative, derivative works from it. The final product was a Latin 8-8 beat dulcimer/guitar number that sounded nothing like the original work it was built on. You could still hear the chord structures underneath it all, but there was no denying that Jerry had created an original composition, drawing from culture in the public domain. Talking to Jerry afterwards, I commented on how the final composition sounded nothing like “Skip to my Lou”, but how it could not have existed without “Skip to my Lou” to build upon. “Exactly! I chose Skip to my Lou because I hate that song, and wanted to appropriate it for something better,” Jerry enthusiastically responded. It was something of an epiphany for me: here was the reason CC is important, in the flesh. If “Skip to my Lou” wasn’t a public domain, traditional number, there’s no way Jerry would have come up with his composition. Or if he had, he would not have been allowed to contribute his work to our culture. CC is important in this respect because the Jerry’s of the future may have nothing to build on if copyright protections continue to grow unfettered. And that would be criminal.

date:2005-04-09 08:10:31
category:culture, notacon2005

I Don’t Understand

So the citizens of Kansas decided that laws aren’t laws until their enshrined in the constitution and voted to ban gay marriage. Actually they voted to ban any status which would grant the privileges associated with marriage, apparently afraid we’ll destroy civil unions for the straights just like we did marriage. Oh wait. This move mirrors fairly closely moves under way in Indiana. The State House voted to approve a consitutional amendment to ban gay marriage last month, and the Senate is expected to approve a similar measure before the end of this session. That’s not the last word, exactly; in Indiana it still has to be approved again by another congress (theoretically in 2007), and then go to a public referendum. So there is hope, but not much.

And I really don’t understand all this posturing and, well, hate. There’s currently talk of requiring Indiana’s public universities to use the same health and benefits plan as that used by employees of the state government. Both Indiana University and Purdue University offer benefits to domestic partners (of both the same and opposite sex) and there’s a law on the books prohibiting the state government from offering benefits to same sex partners. You can see where this is going. Did I mention that Garrett, my partner, works for IPFW, which, as a regional joint campus of IU and Purdue, offers the same benefits package as Purdue? Did I also mention that when I took my job at CC last year Garrett and I codified our relationship and registered as partners? I did? OK, so maybe I’ll get one of those fund-raising bats like Howard had, to collect money to cover health care when the state mandates I be dropped from Garrett’s benefit plan.

I’ve got to say it again, I just don’t understand. My Man Mitch, Indiana’s new [STRIKEOUT:fuhrer] governor campaigned on a platform of making Indiana appealing for business, stopping the problem of “brain drain” which has plagued the state and enforcing laws on the books instead of giving business and individuals a pass. As an educated “knowledge worker”, shouldn’t I be one of the people he desires to retain in Indiana? What motivation do I have to do so after graduation next year, when it seems like the entire popular attitude is opposed to a central part of my identity?

In regards to the final item on Mitch’s list, yesterday’s Journal-Gazette reported that local bar owners are upset that the State Excise Police are suddenly enforcing a ban on illegal electronic gambling machines. Regardless of whether or not you agree with the ban, you can see the logic: enforce the law, or change the law. I think there’s a strong argument to be made that ignoring laws based on the views of a particular administration or enforcement official is a dangerous precendent to establish. So how is gay marriage any different? Regardless of whether or not you agree with gay marriage, laws exist which currently ban it. So why don’t we just enforce those, and deal with the constitutional question if and when it arises?

Proponents of the amendment will tell you that protecting against “activist judges” who may strike down the existing law as unconstitutional is imperative. However, I question whether such protection is really necessary. A challenge was raised to the law late last year, and plantiffs lost. They chose not to appeal to the Indiana Supreme Court. This raises the question in my mind: if a segment of the population is too afraid to challenge laws in the highest court of the land, for fear of dangerous precedent or inciting public opinion, isn’t there something wrong? And isn’t there something equally wrong with further enforcing their status as second class citizens?

In reality, I think the argument regarding “activist judges” is something of a red herring. Wasn’t the judiciary established as separate from the legislature and executive to make sure neither over stepped their bounds? And doesn’t part of that check involving interpretting what lawmakers intended when they passed certain types of legislation, and additionally interpretting whether or not said laws are in conflict? How, by definition, can we have non-activist judges? It seems to me that the best judges are those who are passionate about the law, and passionate about the rights of everyone, including us sodomites. You’re free to disagree with me, of course, but it seems to me that the conservative movement is all for judicial activism when it suits them.

The Family Research Council will tell you that they don’t want to treat gays and lesbians as second class citizens, that gays and lesbians can marry — someone of the opposite sex, of course. In their position papers, they present the restriction on same sex marriage as a simple analog of the restriction of marriage between siblings or first cousins. I, of course, think there’s a fundamental difference. The restriction on marriage between siblings and close relatives serves an important public health need: we know that children of such marriages are more likely to retarded or suffer from birth defects. I suppose you can approach the issue from one of two sides: the restriction exists to protect future children from suffering, or the restriction exists to protect “society” from having to care for such individuals. Either way, there is no analagous situation with same sex marriage. I’ve yet to hear a convincing argument against gay marriage based on public health, and most seem to hinge on Biblical morality, which is why church and state are segregated.

There seems something inherently bilious for the same article which proposes that same sex marriage is equivalent to marriage of siblings to also accuse “homosexual activists” of improperly “hitch[ing] their caboose to the civil rights train.” The author, Peter Sprigg, gives a brief list of reasons racial discrimination is banned in the United States, ending with the comment “[p]lus, race appears in the Constitution.” He’s right, it is mentioned: in the context of blacks counting as 3/5 of a person when it comes to the census. I don’t understand how that is relevant; perhaps a new 3/5 Compromise is in order: gays can marry, but we’ll only get 3/5 of the benefits associated with it.

In closing, I’ve been thinking about this issue quite a bit recently. And I really just don’t understand. My best friend and parents both thinks that homosexuality is wrong, and Biblically immoral. I might not agree with that, but I understand how one reaches that conclusion. People frequently choose external source to base their external ethics on, and it seems that if you choose a literal reading of the Bible as your base, this is a valid conclusion. But we don’t get to choose the base for our society’s legal system; it’s been laid out by the founding fathers, and it has been consistently interpretted (as far as I know) to be religion-agnostic: that is, not making decisions which give preferrential treatment to one religion over another. How does that precedent square with making this decision, the decision that my relationship doesn’t matter as much as my sisters’?

And if you disagree with my conclusion that legal and legislative decisions shouldn’t be made on the basis of one religion or another, how does this seemingly rabid desire to ban same sex marriage square with what seems like complete disregard or willful ignorance of other Biblical admonisions? I truly don’t understand.

date:2005-04-06 11:33:23
category:my life

Life News

Last time I visited by physician for my quarterly meds check, I mentioned the fact that I frequently feel fatigued and exhausted by mid-morning. He referred me to a neurologist, and over the weekend I had a sleep study performed. This morning the neurologist’s office called and confirmed Garrett’s prediction: I have severe obstructive sleep apnea. I go back in tomorrow night for another night of observation, and to be fitted for a CPAP machine. While I’m looking forward to the increased rest and alertness that I’ve been told I can expect, I’m amazed at how medieval looking the head gear fixtures are. Regardless, I’m really hoping to get the machine and gain some experience sleeping with it before heading to PyUK in a couple of weeks.

This weekend I’m heading over to Cleveland for Notacon. The schedule looks nice and geeky, so I’m expecting a good weekend. I’m particularly interested in hearing what this guy has to say about Creative Commons.

date:2005-04-05 15:35:34
category:my life