[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-devel] Re: ViewMTN multi-db
From: |
Roland McGrath |
Subject: |
[Monotone-devel] Re: ViewMTN multi-db |
Date: |
Wed, 20 Feb 2008 20:22:01 -0800 (PST) |
Thanks, Grahame! Now that I know nagging works, I'll have to figure out
whom to badger thrice a week to have someone fix the db locking, integrate
multi-db netsync (usher/whatnot) with a sensible mtn: url schema, and
whatever else I've forgotten I can't possibly live without! ;-)
I had been imagining the option of:
dbfiles = lambda prefix: ...
for dynamically looking up a prefix in some other table, filesystem, etc.
But that approach does not mesh so well with the nice db selector page,
a feature I was not expecting to have. Nice!
What happens if I don't set a defaultdb? What I'd really like is for the
top-level url to just get to the 'Change DB' page (with slightly different
titling and text for no db currently selected). Really swift would be a
configurable inserted chunk of html for that page, so that could just be
the top-level page of a hosting site with some random local content above
the db selection list.
Can the description strings contain random html?
What I'm now toying with is:
import os.path
import glob
def _flatten(l):
return reduce(lambda a, b: a + b, l)
def _dbfile_tuple(file):
dir = os.path.dirname(file)
name = os.path.basename(dir)
description = None
try:
description = open(os.path.join(dir, 'description')).read()
except IOError:
pass
return (name, file, description)
dbfiles = _flatten(map(_dbfile_tuple, glob.glob('/srv/mtn/*/db.mtn')])
I don't really know Python, so perhaps I missed something obvious. But
note how the flattening is necessary because you want a single tuple of
several triples, instead of a sequence of sequences of some sort. It would
seem more in keeping with e.g. config.graphopts to make it:
dbfiles = ({'name' : 'foo', 'description' : 'bar',
'dbfile' : '/srv/mtn/foo/db.mtn'},
{'name' : 'quux, 'description' : 'yowza,
'dbfile' : '/srv/mtn/quux/db.mtn'})
Or at least simpler all round to make it:
dbfiles = [('foo', '/.../db.mtn', 'bar') ('quux', '/.../db.mtn', 'xx')]
But I did conquer it for a more complex case in about 10 minutes without
knowing Python, so it clearly doesn't much matter.
This was the last piece preventing me from figuring out how I wanted to do
things in Fedora packaging to make a viewmtn server setup work more or less
out of the box. (As soon as I get that packaged setup working, I can get
it deployed on fedorahosted.org.)
Unfortunately, it's not working for me at all. :-(
The setup I did for Fedora packaging is under Apache with mod_wsgi.
http://people.redhat.com/roland/tmp/ has the setup I did for that.
If you use Fedora you can do 'yum localinstall viewmtn-*.noarch.rpm'
to get mod_wsgi and everything else you need for a test install.
This was working before with 0.09/0.08, though I sure never really
understood mod_wsgi or web.py when I got it working.
Now I always get this:
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] Traceback (most recent
call last):
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] File
"/usr/lib/python2.5/site-packages/viewmtn/web/webapi.py", line 304, in wsgifunc
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] result = func()
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] File
"/usr/lib/python2.5/site-packages/viewmtn/web/request.py", line 131, in <lambda>
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] func = lambda:
handle(inp, fvars)
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] File
"/usr/lib/python2.5/site-packages/viewmtn/web/request.py", line 22, in handle
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] for url, ofno in
utils.group(mapping, 2):
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] File
"/usr/lib/python2.5/site-packages/viewmtn/web/utils.py", line 325, in group
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] seq = iter(seq)
[Wed Feb 20 19:16:25 2008] [error] [client 127.0.0.1] TypeError: 'module'
object is not iterable
The mod_wsgi glue magic in the rpm is via this .../viewmtn/__init__.py file:
from viewmtn import *
application = web.wsgifunc(web.webpyfunc(urls, globals()))
Maybe that idiom has changed?
Thanks,
Roland