Re: [viewvc-users] Configurable config file location?

John Beranek <[email protected]>
Newsgroups gmane.comp.version-control.cvs.viewcvs.user
Organization John@Home
Message-ID <4C485E4E.1080003__17909.1337057345$1279811166$gmane$org@redux.org.uk>
On 21/07/10 20:32, C. Michael Pilato wrote:
> On 07/19/2010 04:26 PM, John Beranek wrote:
>> My thought was that I'd change the code to allow the config file
>> location to be overridden by an environment variable. Looking at the
>> code it looks like there's already some kind of support for this. Is it
>> true that I only need to change all the places that define CONF_PATHNAME
>> to define it as "None"?
>>
>> If so, I could then set VIEWVC_CONF_PATHNAME in the Apache config, and
>> have multiple "viewvc.conf" files, one for each site. This would
>> certainly be an advance.
> 
> Yup.  You can do that today.

Hmm, unless I'm very much mistaken, this doesn't work in a mod_python
ViewVC installation.

I did:

SetEnv VIEWVC_CONF_PATHNAME /full/path/to/conf/file.conf

in the Apache vhost config and

CONF_PATHNAME = None

in bin/mod_python/viewvc.py and it appears not to load the config. I put
some stupid debug (I'm a bit of a Python newbie) in lib/viewvc.py in the
load_config function, and

os.environ.get("VIEWVC_CONF_PATHNAME")

comes out as "None".

I've implemented a nasty hack, diff attached - doesn't allow for more
than one ViewVC installation per machine, but that's currently not a
requirement for me.

Cheers,

John.

-- 
John Beranek                         To generalise is to be an idiot.
http://redux.org.uk/                                 -- William Blake

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4255&dsMessageId=2636951

To unsubscribe from this discussion, e-mail: [[email protected]].
diff.txt (text/plain, 833 B)
Index: lib/viewvc.py
===================================================================
RCS file: /home/sources/cvsroot/Admin/website/cgi-bin/viewvc/lib/viewvc.py,v
retrieving revision 1.2
diff -u -r1.2 viewvc.py
--- lib/viewvc.py	2010/07/19 21:33:31	1.2
+++ lib/viewvc.py	2010/07/22 15:05:18
@@ -4267,9 +4267,13 @@
 def load_config(pathname=None, server=None):
   debug.t_start('load-config')
 
+  import socket
+
   if pathname is None:
     pathname = (os.environ.get("VIEWVC_CONF_PATHNAME")
                 or os.environ.get("VIEWCVS_CONF_PATHNAME")
+                or os.path.join(os.path.dirname(os.path.dirname(__file__)),
+                                "viewvc.conf-" + socket.gethostname())
                 or os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                 "viewvc.conf"))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.