I spent way more time than I planned or wanted to spend on CherryPaste
today, mostly trying to get Catwalk to work correctly.
First, CherryPy's WSGI application doesn't use SCRIPT_NAME like it should. After getting
a less than enthusiastic response on that ticket, I thought I would
just not bother pursuing that and fix it myself. CherryPaste could
then be seen simply as the valid-to-spec WSGI application for
CherryPy. That ended up being a pain in the butt. The
VirtualPathFilter
recipe I built off of is just a silly hack, frankly, despite the fact
that it's a likely part of any realistic deployment. The WSGI
environment is thrown away, so if you planned to pass information
through WSGI into the CherryPy request you can't. I haven't looked very hard, but I haven't yet found the
way to turn off CherryPy's catching of exceptions (which I want
because Paste has a better exception handler). CherryPy eats exceptions
from some filter methods.
This all to get Catwalk to run under something besides the root path.
Then I realize CatWalk has entirely hardcoded URLs. That's just
silly. turbogears.view.stdvars creates dynamic values that it
should be using; that was an easy enough change. Except TurboGears
bases those values off something calculated at server startup, and
stores it in a module global. So I have to patch in a threadlocal
value that poses as a string. Lastly Catwalk patches the
configuration to add static paths when you access the index page; but
since I'm keeping configuration information isolated to each request
that doesn't work. So I have to add a specific hack to the Catwalk
entry point to fix up the configuration on each request.
In the end it all works, at least for this one case. But damn. This
is not what I want to be working on. I feel like I'm just cleaning up
other people's shit. I have enough shit of my own that needs cleaning up.
It's not like this is Paste-specific stuff. No one knows how to do
this stuff in CherryPy. No one seems to have any authoritative answer
on how you deploy these apps -- how you move between servers, how you
change the application root, how you put apps together into a single
server. Everything is ad hoc stuff that just barely works for one app
on one server. It's all "recipes". Recipes are often just stuff that
no one cares enough about to do right. This is too central to what
CherryPy is supposed to be doing to be a recipe.
It occurs to me that TurboGears was extracted from an application that
runs on the local machine. In that case none of these issues would
have been apparent. But that's not similar to how people are actually using
TG. I think these shaky underpinnings are risky for the
project.