As a kind of first-experiment both in appropriating another package
and in poking Paste (and setuptools) conventions into a package, I
have Trac now working with Paste,
both the WSGI side (using their WSGI branch) and the installation. It
works like this:
easy_install 'PasteScript[Cheetah]==dev' 'PasteDeploy==dev' 'Paste>=0.4.1'
paster make-config TracPaste mypackage
# You can edit mypackage/conf/trac.ini now
paster setup-app mypackage/conf/trac.ini
paster serve mypackage/conf/trac.ini
And that's all you need to setup a project. Now, you might say that
this is not really much easier than Trac is normally. Except, of
course, you now can run it with Paste. You are probably not
impressed.
But it does use a clever easy_install hack. TracPaste is in the
Cheese Shop, but has
no packages yet -- purely svn. The WSGI branch of Trac isn't in the
Cheese Shop, but I can link to it from the TracPaste page, and get
easy_install to automatically install it by using the requirement
Trac==wsgi,==1.0dev -- the branch itself is labelled 1.0dev, but I
put a link to the branch with #egg=Trac-wsgi appended. You have
to give both versions because easy_install will download based on
that link (guessing that ==wsgi will match), but the result
installation does not satisfy the ==wsgi requirement since it is
marked upstream as 1.0dev.
Paste Script also uses two-phase install. trac-admin uses an
interactive installation, where it asks you questions. I find this
very annoying, because I don't know what questions are coming up, and
I don't know the answers without doing ^Z a bunch of times. This
version installs the config file, but doesn't set anything up until
you call setup-app (which writes the database and some files).
The config file is still just a randomly-ordered set of sections
(blame ConfigParser), but in a better setup it would be a nice config
file with helpful comments and with commonly-changed things at the
top.
In related news, here's a quick setup for a Catwalk SQLObject model browser:
easy_install http://svn.cherrypy.org/trunk/
easy_install -f http://turbogears.org/download/ TurboGears==dev CherryPaste
I don't have a make-config setup for it, and I'm not sure I'll
make one. You just make your own config like:
[app:main]
use = egg:CherryPaste#catwalk
model = mypackage.mymodel
# If you need to configure a db connection:
database = mysql://...
[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 8080
Then do paster serve catwalk.ini and you'll be set. Now you don't
have to be using TurboGears to use Catwalk -- you can even embed
Catwalk into your own (WSGI/Paste) application with relative ease,
because that configuration file just maps (exactly) to this Python:
# egg:CherryPaste#catwalk is defined as this import in
# CherryPaste/setup.py:
from cherrypaste.tg import make_catwalk
app = make_catwalk({}, model='mypackage.mymodel',
database='mysql://...')
Being able to do exactly this was actually one of my primary
motivations for CherryPaste.