The unified diff between revisions [f8db548c..] and [b5d299ba..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "config.py.example"
#  from [cbb57defe7f906cedae2a13c87aaec4bdb06a0f3]
#    to [1372c7ff5e516d80f25ac66c939bd66e3fcb3a9f]
#
# patch "viewmtn.py"
#  from [74a4f0416cdabd92532bb1ed2f1a6fbe7f52183f]
#    to [4711109e7e0e383a480fde9fae671de24ce92401]
#
============================================================
--- config.py.example	cbb57defe7f906cedae2a13c87aaec4bdb06a0f3
+++ config.py.example	1372c7ff5e516d80f25ac66c939bd66e3fcb3a9f
@@ -42,13 +42,18 @@ monotone = '/usr/bin/mtn'
 #
 # Database files:
 # You can do this two ways.
-# (1) Define "dbfile" as follows. VieWMTN will only
-#     allow access to one database.
-# (2) Define "dbfiles". This tuple will describe several
-#     databases which ViewMTN will allow users to access.
-#     The format is as ( name , path, description, ... )
-#     - just follow the patten in the example.
-#     The default database is defined via "defaultdb".
+# ( 1) Define "dbfile" as follows. VieWMTN will only
+#      allow access to one database.
+# (2a) Define "dbfiles". This tuple will describe several
+#      databases which ViewMTN will allow users to access.
+#      The format is as ( name , path, description, ... )
+#      - just follow the patten in the example.
+#      The default database is defined via "defaultdb".
+# (2b) Define "dbfiles" as a function taking no arguments,
+#      and returning a tuple in the format specified under
+#      (2a). dbfiles must be a function, not just code, to
+#      avoid running a scan every time the config.py module
+#      is imported.
 #
 # If you have defined "dbfiles", it takes precedence over
 # "dbfile".
@@ -61,11 +66,23 @@ monotone = '/usr/bin/mtn'
 # Style (1)
 # dbfile = '/path/to/my/viewmtn.db'

-# Style (2)
+# Style (2a)
 # dbfiles = ("database1", "/path/to/stuff.db", "my stuff",
 #            "database2", "/path/to/junk.db", "my other stuff")
 # defaultdb = "database1"

+# Style (2b)
+# WARNING: this will publish _all_ the databases in the directory
+# matched by the call to glob, if they have a corresponding .descr
+# file. Check this is really what you mean to do!
+#
+# import os,glob
+# dbfiles = lambda: reduce (lambda a, b: a+b,
+#                           [ (os.path.basename(t).split('.',1)[0],
+#                              t,
+#                              open(t+'.descr').read().strip()
+#                             ) for t in glob.glob("/Users/grahame/mtn/db/*.db")
+#                             if os.access(t+'.descr', os.R_OK)])

 # highlight from http://andre-simon.de/
 # if you don't have this available, just comment
============================================================
--- viewmtn.py	74a4f0416cdabd92532bb1ed2f1a6fbe7f52183f
+++ viewmtn.py	4711109e7e0e383a480fde9fae671de24ce92401
@@ -9,7 +9,7 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 # PURPOSE.

-import os, sys, urllib
+import os, sys, urllib, types
 from itertools import izip, chain, repeat
 from urlparse import urljoin
 import web
@@ -54,7 +54,14 @@ class RequestContextFactory(object):
         self.default = None
         # has the user specified a dbfiles hash? if so, use it
         if hasattr (config, "dbfiles"):
-            for name, dbfile, description in grouper(3, config.dbfiles):
+            # is dbfiles a function? if so, call it..
+            dbfiles = config.dbfiles
+            if isinstance(dbfiles, types.FunctionType):
+                dbfiles = dbfiles()
+            # we should have something iterable now; if not, abort
+            if not hasattr(dbfiles, "__iter__"):
+                raise Exception("dbfiles defined incorrectly. It must be an interable (eg. tuple or list) or a function taking no arguments which returns an iterable.")
+            for name, dbfile, description in grouper(3, dbfiles):
                 self.add_to_store(name, ops=mtn.Operations([config.monotone, dbfile]),
                                         branchdivs=branchdiv.BranchDivisions(),
                                         dbdescr=description)