2008/04/08

Thank you, wsgi

Thanks to all of the developers behind wsgi.

When I first heard about it, wsgi struck me as an unnecessary complication. Then someone showed me how it could simplify testing of web applications. And now:

High-Scalability:

Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor), including Django, CherryPy, Pylons, and web.py. You can bundle a framework of your choosing with your application code by copying its code into your application directory.

2008/04/04

Visual Web Developer "Failed to start monitoring changes"

I keep forgetting about this...

I'd like to do development on an ASP.NET web application which resides in a VMware Fusion shared folder. Unfortunately, as noted in the Microsoft Forums, Visual Web Developer 2005 Express Edition (at least) does not support hosting on a UNC share.

So, AFAICT, the only option is to do development in a local folder. To access that folder from the host operating system, it needs to be shared from the Windows VM.

VMware Fusion, OpenSUSE 10.3 x64, copy and paste

I recently installed a 64-bit OpenSUSE 10.3 virtual machine under VMware Fusion. Everything worked fine except cut&paste -- the vmware-user executable was not launching when X11 started.

ldd showed a dependency on libexpat.so.0, in addition to libexpat.so.1. I installed that using yast, rebooted, and -- huzzah -- cut&paste now works.

yast_install_libexpat.png

More details are available in the VMware Fusion discussions forum.

2008/03/26

Five Open Tools for 2D Structure Layout (aka Structure Diagram Generation)

Five Open Tools for 2D Structure Layout (aka Structure Diagram Generation)

Good summary of several alternatives. I've been using CDK of late, but am partial to tools written for CPython. I wonder if any of the alternatives make it as easy to extract coordinates as does CDK?

2008/03/21

TUAW Terminal Tip: Safari 3.1 brings true one-window mode

Terminal Tip: Safari 3.1 brings true one-window mode:

...true one-window mode is finally, finally, here for Safari. All you need to enter is the command below into Terminal, hit enter, and you're sorted.

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true


Yay!

Functest

Writing Functests:

"This is where functest really shines. When you run functest against any directory or file the collector actually compiles a dependency chain which includes any valid python modules in all the parent directories..."


Hm. So functest would let me dispense with this nonsense boilerplate in my test modules?
import sys
import os
thisdir = os.path.abspath(os.path.dirname(__file__))
def relpath(p):
return os.path.abspath(os.path.join(thisdir, p))
sys.path.insert(relpath("../"))



I wonder if nose does/will provide similar facilities? It's pretty nice in other respects...

Twill, CherryPy 3 and testing with internal servers

Twill can test CherryPy web servers "in process", without having to run them as servers. I've used twill this way with CherryPy 2, but when I recently tried to do the same thing with a CherryPy 3 server everything broke.

I had based my code on an old CherryPy 2 tutorial by Titus Brown, and was trying to grep through the CherryPy 3 code tree to figure out how to patch it up. Bad idea :)

Yesterday Google finally turned up a solution, from a talk Titus gave at PyCon 2007.

The upshot: don't use cherrypy._cpwsgi.CPWSGIApp. In CherryPy 3, your application itself is already a WSGIApp. What's more, I think cherrypy._cpwsgi.CPWSGIApp may be broken. For sure, it and twill have incompatible ideas about the correct type of the 2nd constructor argument.

Anyway, thanks to Titus, here's an example of how to connect twill to a CherryPy 3 application for in-process testing:

import twill
import cherrypy
...
wsgi_app = cherrypy.tree.mount(myApp, "/", myConfig)
cherrypy.engine.start(blocking=False)
twill.add_wsgi_intercept('localhost', 8080, lambda: wsgi_app)


[Update 2008/03/24] Ditched the cherrypy.server.quickstart() invocation, per fumanchu's comment. Reported as Ticket #801.

2008/03/10

waf build errors

I'm evaluating waf to see if it's easier to use than SCons (especially for Qt projects). So far the results are encouraging. In particular, waf reports many kinds of problems using straightforward (color-coded!) error messages, rather than Python tracebacks.

target 'build_info' does not exist

Sometimes waf does spew an unintelligible Python traceback reminiscent of SCons. For me, these typically end with a KeyError:

File "/path/to/.waf-1.3.2-blah/wafadmin/Task.py", line 290, in must_run
prev_sig = tree.m_sig_cache[key][0]
KeyError: -214303645


This error always translates to "you are trying to build a file which is part of your source tree."

My SConscripts work in situ, creating object files etc. in the same directories where the source code resides. waf prefers to put build products in a separate build/ subdirectory. When waf is instructed to generate an output file in its build tree, and when that file already exists in the source tree, waf fails with the KeyError traceback.

I'd bet this problem is most common in software projects which started life using build systems like Make or SCons -- tools which default to building in situ.

For example, I'm trying to use waf in a subversion workspace where I've been doing SCons builds for years. To make matters worse, one of the build products is a header file, containing revision number and date for the current build. This looks like a source file, so it's likely that I never checked whether it was properly removed by scons -u -c.

In retrospect, I should have started with a clean check-out...

2008/03/07

Rogue Amoeba: Code Signing and You

Code Signing and You:

"Code signing itself is a neutral technology, but it gives incredible power to the system vendor, and that power is just waiting to be exercised and abused."


It's possible that Apple intends to close off the OS X platform. If that happens, I'll go back to Linux.

2008/03/06

DailyTech - Researcher: Basic Greenhouse Equations "Totally Wrong"

From DailyTech:

"NASA refused to release the results.  Miskolczi believes their motivation is simple.  'Money', he tells DailyTech.  Research that contradicts the view of an impending crisis jeopardizes funding, not only for his own atmosphere-monitoring project, but all climate-change research.  Currently, funding for climate research tops $5 billion per year.
"

"The equations also answer thorny problems raised by current theory, which doesn't explain why "runaway" greenhouse warming hasn't happened in the Earth's past. The new theory predicts that greenhouse gas increases should result in small, but very rapid temperature spikes, followed by much longer, slower periods of cooling -- exactly what the paleoclimatic record demonstrates."

"Miskowlczi has used his theory to model not only Earth, but the Martian atmosphere as well, showing what he claims is an extremely good fit with observational results."


Hey, at least we still have peak oil.

2008/03/03

Intermittent Pickle Problems in Jython

The previous post mentioned "integrating" Jython and CPython by transmitting a stream of pickles between the two. I encountered one intermittent problem with this approach, and I'm unsure of its cause. (Hm, and I should probably post this to a Jython mailing list...)

Problem


In Jython I'd pickled the str() of a java.io.StringWriter, into which I'd just written the SD representation of a CDK molecule. Jython could create the pickle alright. But when I tried to unpickle it in CPython, sometimes, for some molecules, I got a traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 970, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle


The error occurred consistently in my application code, always on the same input structure. But I couldn't derive a simple test script to demonstrate the problem.

Investigation


Examination of the problematic pickle data showed that a Python unicode string literal marker had somehow been inserted, and the type code for the item was somehow S (for string) rather than V (for unicode):
...
sS'sdf'
p3
Su'ZINC00000181\n CDK...
^ What the... ?


Workaround


Google turned up a usable workaround: encode the offending string as utf-8 before trying to pickle it.


import codecs
enc = codecs.getencoder('utf8')
...
sdf = enc(sdf)
...


Ted Leung: The Sun is going to shine on Python

Congratulations to Ted Leung (and to Frank Wierzbicki):
The Sun is going to shine on Python.

Their work at Sun will extend well beyond Jython, but Ted's post reminded me of my recent experiences. Jython 2.2 sure made it pleasant and easy[1] to get what I needed out of CDK, and to integrate the results into a CPython app via pickle and subprocess.

I did miss some language features such as yield which have appeared in CPython since 2.2. Maybe at some point Ted and/or Frank will have time to re-sync Jython with CPython?

[1] I had one intermittent problem with this approach. See the next post.

2008/02/26

New Scientist: Fatal brain cancer tamed by gene therapy

Fatal brain cancer tamed by gene therapy - 25 February 2008 :

Previous attempts to treat glioblastomas with gene therapy failed because some tumour cells survived and regrew. The new treatment overcomes this problem by permanently priming the immune system to pick off any straggler tumour cells.

A harmless virus that only infects fast-dividing cancer cells is injected directly into the brain... One gene, HSV1-TK, kills the cancer cells by activating ganciclovir...


And here's the cool bit:
...a second gene, Flt3L... summons immune "dendritic" cells from the bloodstream into the brain.


(How does it do that?)

[The dendritic] cells engulf the debris and transport it back to lymph nodes, where they re-prime the immune system to attack any remaining tumour cells during and after treatment.


Lymph nodes seem like a gunnery school for white blood cells: you go there to learn how to distinguish friend from foe. (BTW fevers seem to help lymph nodes do their jobs.)

2008/02/25

Doc Searls: The FCC and the Giant Zero

The FCC and the Giant Zero:

"Message to Verizon and the rest: the Internet is not about ‘consumer choice’. We produce as well as consume. We need to be able to run our own servers. [emph. added] We need to be able to exercize supply as well as demand. We need symmetricality, not just neutrality."


Amen to that.

I live in Santa Fe. As far as I can tell, my choices are Earthlink (via Qwest DSL @ 1.5Mbps) and Comcast. If I want a static IP address, a useful step to server-hood, then my rates would go up by 30%. Bah.

Netgear WAN MTU Size

(Not sure why I haven't written this up yet. It sure was a problem for a long time...)

I used to work "offsite" -- outside the home -- several days a week. When offsite my laptop could perform subversion operations against a repository on my home network, with good performance. But when the notebook was "inside" the home network, those same operations would take forever.

Eventually I stumbled on the fix, clearly explained in the help sidebar of the WAN Setup page of my Netgear WGR614 router: change the MTU to 1492. (Shades of Christopher Columbus!)

Nobody reads documentation :\

The normal MTU (Maximum Transmit Unit) value for most Ethernet networks is 1500 Bytes, 1492 Bytes for PPPoE connections, or 1436 for PPTP connections.


2008/02/14

Site-specific browsers and web-app testing


 ?


Site-specific browsers should simplify testing of some types of web applications, e.g. those which support multiple registered users. On platforms such as Mac OS X, which typically run only one instance of each application, SSBs should allow you to launch multiple, distinct applications which point to the same website.

Is anyone doing this? Is it better (and does it always suffice) to simply run multiple copies of a twill script, and to dispense with browser-based tests?

I haven't tried Fluid yet, since my main work machine is still running Tiger.

Alas, I guess basic Prism apps won't do the job:

prism_one_copy.png


Technorati Tags:
, , ,


2008/02/13

DNA Articles du Jour

Next-generation pathogen sequencing

http://www.technologyreview.com/Biotech/20191/

454 Life Sciences have figured out how to isolate pathogen RNA from human tissue samples, and have used the process to identify previously-unknown pathogens as the likely cause of death for three transplant recipients.

In the 1980s, my brother's neighbor almost died from an illness whose cause was never determined. More recently, local doctors have been unable to figure out why a friend's daughter had a fever for three weeks. This process may make it possible to diagnose the causes of many more illnesses.

"...the sequence of the new virus was different enough that existing methods could not have detected [it]..."


"As many as 40 percent of cases of central nervous system disease cannot be traced back to a specific culprit. For respiratory illness, the figure is 30 to 60 percent."


"Usually, PCR requires some advance knowledge of the sequence in question because it relies on molecular primers that match the string of code to be amplified. But 454 sequencing avoids that problem by using a large number of random primers."



Combining DNA from >2 "parents"

http://www.dailytech.com/article.aspx?newsid=9835

I didn't know people could have problems with their mitochondrial DNA.

"...[the] research involved implanting the DNA from a [woman] with a mitochondrial disorder into the egg of a [woman] with healthy mitochondria. Thus the woman with the genetic disorder passed on the rest of her genetic legacy, while the other woman contributed only [healthy mitochondrial] DNA."


Ethical firestorm to follow...

2008/02/10

Installing PVM under MacPorts on Leopard

I've been having trouble getting PVM 3.4.5 to install under MacPorts on Leopard. The conf/DARWIN.def configuration file defines the FAKEXDRFLOAT preprocessor symbol; it may be needed for OS X 10.4, but it causes a compiler error w. GCC 4.0.1 under 10.5:

../../src/pmsg.c:785: error: static declaration of 'xdr_float' follows non-static declaration.


The workaround is simple: install the Darwin8 variant.

$ sudo port install pvm +darwin_8

2008/02/09

DailyTech - Solar Activity Diminishes; Researchers Predict Another Ice Age

DailyTech - Solar Activity Diminishes; Researchers Predict Another Ice Age:

Researcher Dr. Timothy Patterson, director of the Geoscience Center at Carleton University, shares the concern. Patterson is finding "excellent correlations" between solar fluctuations, a relationship that historically, he says doesn't exist between CO2 and past climate changes. [emphasis added] According to Patterson. we shouldn't be surprised by a solar link. "The sun [is] the ultimate source of energy on this planet," he says.


Oh no! Is it too late to start increasing our greenhouse gas emissions, to keep the planet from freezing over? ;)

Whatever is the truth about how we affect our environment, it's good to be reminded of our insignificance — and our uncertainty.

2008/01/30

Stephen Fry - Bloggery

No, no: Break a Leg.

Stephen Fry has broken his arm so badly it took ten screws to pin it in place. The x-rays look so bad they actually convey a sense of the pain he must be feeling.

Interesting to note that he suffered the break while filming a segment of "Last Chance to See" in Brazil. I didn't know there was such a series, but (from a selfish perspective) what serendipity: Douglas Adams was one of my favorite authors, and I'm a fan of Mr. Fry's work as well.

I have a little list of people I'd like to meet. No idea what I'd say to any of them, except perhaps, "Thank you." Stephen Fry is on that list. Douglas Adams was there, too, but I missed him by a year; like others he has slipped onto the list of missed opportunities.

Maybe I should just post a "get well soon" to Mr. Fry's blog :)