[three]Bean

Announcing -- 24 hour tw2 bug sprint for PyCon

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

(First published to the toscawidgets-discuss google group)

It came up in IRC the other day that tw2 has been through many, many beta iterations.  So many in fact, that a full on tw2 2.0 release is painfully overdue.

That said, there are still plenty of out-standing issues in our issue tracker:
    http://bitbucket.org/paj/tw2core

Before we tag and name the 2.0 final product, I'm proposing -- no, announcing -- a 24 hour tw2 sprint the weekend before PyCon.  We'll write docs, we'll automate tests, we'll settle the dispatch dispute and wax philosophic.

I invite you to join me Saturday, March 3rd at 18:00:00 UTC through Sunday, March 4th 18:00:00 UTC.  Hop into #toscawidgets on freenode or join me in a hangout on google plus.  We'll nail every last bug on deck and still have time for a beer.

Yours in widgetry-

 - threebean

View Comments

Hacking tw2 resource injection

Dec 13, 2011 | categories: python, toscawidgets, turbogears View Comments

Tonight, VooDooNOFX was asking in IRC in #turbogears how to disable the injection of jquery.js by tw2.jquery into her/his TG2 app. Using the inject_resources=False middleware config value wouldn't cut it, since she/he wanted tw2 to inject all other resources, they were loading jQuery via google CDN beforehand and tw2's injection was clobbering their code.

I came up with the following hack to myapp/lib/base.py which will remove tw2.jquery.jquery_js from the list of resources tw2 would inject into each page served by a TG2.1 app.

At the top of myapp/lib/base.py import:

import tw2.core.core
import tw2.jquery

and then replace:

        return TGController.__call__(self, environ, start_response)

with the following:

        stream = TGController.__call__(self, environ, start_response)

        # Disable the injection of tw2.jquery
        offending_link = tw2.jquery.jquery_js.req().link
        local = tw2.core.core.request_local()
        local['resources'] = [
            r for r in local.get('resources', list()) if r.link != offending_link
        ]

        return stream

The two tricks to this are

  • Simply knowing that tw2 resources register themselves with the 'request_local' object and that during the return-phase of the WSGI pipeline, the tw2 middleware refers to that list when injecting resources
  • Figuring out where in a TG2 app's request flow to place the call to alter that object after all widgets that might register jquery have declared their resources but before the resources list is injected into the output stream.

We came out of it with a bug filed in the tw2 issue tracker so we can take care of it properly in the future.

View Comments

python ansi2html makes taskwarrior fantas(k)tic

Oct 28, 2011 | categories: python, gtd View Comments

Over a year ago, I wrote a python module called ansi2html that takes colored ansi as input and produces colored, formatted html.

With it you can do something like the following:

$ ls --color=always | ansi2html > directory.html
$ sudo tail /var/log/messages | ccze -A | ansi2html > logs.html

Much more recently I discovered taskwarrior, a command line todo list manager that rocks. It features the ability to produce burndown charts of your todos over time.

I use the following in a cronjob to produce an online version of my burndown chart.

$ task burndown | ansi2html | ssh me@web "cat > ~/static/burndown.html"

My regularly-updated chart is hosted on threebean.org.

If you come up with any neat uses for ansi2html, please let me know. I'd love to hear about them.

View Comments

raptorizemw - Fact: Every WSGI app is better with a raptor.

Oct 03, 2011 | categories: python, lulz, pyramid, turbogears View Comments

It's done. An over-engineered WSGI middleware component that adds a velociraptor to every page served. Fact: Every WSGI app is better with a raptor.

It's called raptorizemw (pronounced "awesome") and the only way to use it is in production.

View Comments

TurboGears 2.1 and Foreclosures (more empty houses than homeless people)

Sep 24, 2011 | categories: python, politics, turbogears View Comments

I wrote an app that scrapes foreclosure data from my county of residence and plots it six ways from Sunday in a TurboGears2.1 app. You can find it at http://monroe-threebean.rhcloud.com/, hosted on redhat's openshift cloud.

It's used by activists with Take Back the Land, Rochester and my local branch of the ISO to find upcoming evictions before they happen and organize the neighborhoods to stop the shuttering of homes. Get a hundred people at the door of the house before the cops come, and no-one is getting evicted (we've had some successes).

We're living in some absurd times where banks got bailed out by the trillions yet still get to collect on our student debt and mortgages. Most of us are being ruined. If you're not, then your neighbor is.

If you're in Boston, check out Vida Urbana or if you're in Chicago, check out the Chicago Anti-Eviction Campaign. Anywhere you go, check out the ISO.

Fork my code, port it to your home town, and start organizing!

View Comments

« Previous Page -- Next Page »