In which I avoid the inverse unicode sandwich

Jun 22, 2012 | categories: python, toscawidgets, testing, turbogears View Comments

Problem #1 - I need to test tons of HTML output for correctness (because I maintain toscawidgets2). That output varies slightly because tw2 supports five different templating languages (mako, genshi, jinja2, kajiki, and chameleon). Using double-equals (==) just won't do it.

Solution #1 - We used strainer. It works!

Problem #2 - Imagine porting this to Python 3. Yes, that's right. The encoding is sniffed by hand and then used to encode regular expressions; these are in turn applied to parse XML. Think "inverse unicode sandwich with a side of Cthulhu."

Solution #2 - I wrote sieve: a baby module child of one corner of FormEncode and another corner of strainer. It works on pythons 2.6, 2.7, and 3.2. If you like, you may use it:

>>> from sieve.operators import eq_xml, in_xml
>>> a = "<foo><bar>Value</bar></foo>"
>>> b = """
... <foo>
...     <bar>
...         Value
...     </bar>
... </foo>
... """
>>> eq_xml(a, b)
>>> c = "<html><body><foo><bar>Value</bar></foo></body></html"
>>> in_xml(a, c)  # 'needle' in a 'haystack'

p.s. -- I looked into xmldiff. Awesome!

View Comments

ToscaWidgets2 Bugsprint Report

Mar 04, 2012 | categories: python, toscawidgets, pyramid, turbogears View Comments

Here's the rundown of the pre-PyCon tw2 bugsprint. The unstoppable Greg Jurman and I coordinated in google+ and IRC (with lots of ad-hoc visitors in both) and did all the damage we could do to the bug list. Our goal was to close enough that we could justify a solid 2.0 non-beta release but we didn't quite get there. We settled on 2.0 release candidate 1.

tl;dr - Big progress. We'll seal the deal on 2.0 at PyCon US next week.


Tickets closed:

Tickets worked on, but not complete:

Tickets created:

View Comments

Listing all my tw2 github repositories

Mar 03, 2012 | categories: python, toscawidgets, github View Comments

Just starting out on the tw2 bugsprint this morning. I'm working on adding CompoundValidator support and Greg Jurman is working on resolving the duplicate JS encoders. That later one is a real pain. There are tons of widget libraries out that that use one set of JS objects, and plenty that use the others. To find out what uses what (so we can refactor with less pain) I had to ping my github account to find out the full list of tw2 libraries I've written.

Here it is! Using github2 to get a list of every repo (so I can clone and $ grep -nr JSFuncCall tw2.*):

#!/usr/bin/env python
import github2.client

ghc = github2.client.Github()

# This was the trick.  I have too many repos!
all_repos, page = [], 0
while True:
    new_repos = ghc.repos.list('ralphbean', page)
    if not new_repos:
    page += 1

for repo in all_repos:
    if 'tw2' in repo.name:
        print repo.name
View Comments

TW2 Bugsprint; the Final Countdown

Mar 02, 2012 | categories: python, toscawidgets, pyramid, turbogears View Comments

Tomorrow marks the start of the toscawidgets2 24 hour bugsprint and I couldn't be more stoked. We haven't even started yet but tw2 development pushed ahead anyways.

We have:

Goal: (solidly) close as many bugs as possible and push as many libraries from beta to release as we can.

Here's to winning that game.

View Comments

New toscawidgets.org frontpage

Feb 26, 2012 | categories: python, toscawidgets View Comments

The toscawidgets2 24 hour bugsprint is this coming Saturday! In order to get you excited and to curry all of your favors, I decided to give http://toscawidgets.org a facelift.

The old http://toscawidgets.org site was confusing! 80% of the frontpage was about toscawidgets 1 which, while stable, has a diminishing number of maintainers and no active development. 20% of the page was a "news" bar on the right that pointed users to "Alpha releases" and "new documentation" for tw2, timestamped back in 2010!


I revamped it to more clearly differentiate between the two versions of the framework and to give it a more modern look (if we're building python widget libraries, we better be on top of CSS3 on our project page, right?)

View Comments

Next Page ยป