# # # delete "www/viewmtn.diff" # # patch "www/viewmtn/config.py.example" # from [1372c7ff5e516d80f25ac66c939bd66e3fcb3a9f] # to [8d2d8bfe1c6e5664ddd6bbf74af7e726d3460c1f] # # patch "www/viewmtn/viewmtn.py" # from [4a6aa5a9f006b5d014e329d833f1a0df9a372f23] # to [4e0b57e1e24da5a5c6f33a93d250d4670b62150f] # ============================================================ --- www/viewmtn/config.py.example 1372c7ff5e516d80f25ac66c939bd66e3fcb3a9f +++ www/viewmtn/config.py.example 8d2d8bfe1c6e5664ddd6bbf74af7e726d3460c1f @@ -20,12 +20,39 @@ import sys # import sys +import os +import re +name = 'NAME' +confdir = 'CONFDIR' +conffile = confdir + '/hostconfig' + +def file_tokens(fn): + f = open(fn, 'r') + data = f.read() + f.close() + tok_str = r'"(?:[^"]|\\")*"' + tok_key = r'[^"\s[]\S*' + tok_hex = r'\[[[:xdigit:]]*\]' + anytok = '(%s|%s|%s)' % (tok_key, tok_str, tok_hex) + return re.split(anytok, data) + +config_data = {} + +for s in file_tokens(conffile): + if not re.match(r'^\s', s): + if re.match(r'^["[]', s): + config_data[lastkey].append(s[1:-1]) + else: + lastkey = s + config_data[lastkey] = [] + + # default addresses should work without modification # if running viewmtn standalone. You must change these # if you run viewmtn with a web server, see INSTALL. -dynamic_uri_path = 'http://localhost:8080/' -static_uri_path = 'http://localhost:8080/static/' +dynamic_uri_path = config_data['base_url'][0] + 'viewmtn/' +static_uri_path = config_data['base_url'][0] + 'viewmtn/static/' # Directory in which to find the templates/ files. # Depending on the web server setup, this might need to be absolute. @@ -34,10 +61,10 @@ templates_directory = 'templates/' # if you are running under Apache2, set this. # don't set it otherwise, it breaks any other configuration # including running standalone. -running_under_apache2 = False +running_under_apache2 = True # the path to the 'mtn' binary -monotone = '/usr/bin/mtn' +monotone = config_data['monotone'][0] # # Database files: @@ -84,6 +111,14 @@ monotone = '/usr/bin/mtn' # ) for t in glob.glob("/Users/grahame/mtn/db/*.db") # if os.access(t+'.descr', os.R_OK)]) +dbfiles = () + +def project_hostname(project): + if os.path.isdir("%s/%s" % (config_data['project_dir'][0], project)): + return project + "." + config_data['hostname'][0] + else: + return None + # highlight from http://andre-simon.de/ # if you don't have this available, just comment # the "highlight_command" line out ============================================================ --- www/viewmtn/viewmtn.py 4a6aa5a9f006b5d014e329d833f1a0df9a372f23 +++ www/viewmtn/viewmtn.py 4e0b57e1e24da5a5c6f33a93d250d4670b62150f @@ -84,10 +84,19 @@ class RequestContextFactory(object): return self.dbstore[k].get(name, default) def __getitem__(self, name): + host = config.project_hostname(name) + if host is None: + return None if name is None: name = self.default ops = self.get_from_store("ops", name) if ops is None: + self.add_to_store(name, + ops=mtn.Operations([config.monotone, host]), + branchdivs=branchdiv.BranchDivisions(), + dbdescr="No Description") + ops = self.get_from_store("ops", name) + if ops is None: return None else: dbdescr = self.get_from_store("dbdescr", name)