logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r1607 - trunk: . docs lib: msg#00053

Subject: svn commit: r1607 - trunk: . docs lib
Author: cmpilato
Date: 2007-04-16 07:54:01-0700
New Revision: 1607

Modified:
   trunk/docs/upgrading-howto.html
   trunk/lib/config.py
   trunk/lib/viewvc.py
   trunk/viewvc.conf.dist

Log:
Add support for per-root option overrides using sections named
root-ROOTNAME-CONFIGSECTION.

In order to keep the configuration section naming conventions
consistent, change the way virtual host override sections are named
from VHOSTNAME-CONFIGSECTION to vhost-VHOSTNAME-CONFIGSECTION.

* lib/config.py
  (Config.load_config): Add optional 'rootname' parameter.  Actually
    make use of self.conf_path.  If there is a rootname provided,
    overlay per-root options.
  (Config._process_vhost): Now expect vhost section names to begin
    with the prefix "vhost-".
  (Config._find_canon_vhost): Minimize some logic.
  (Config.overlay_root_options, Config._process_root_options): New.
  (ViewVCConfigurationError, IllegalOverrideSection): New.
  (MalformedRoot): Now inherit from ViewVCConfigurationError.
  
* lib/viewvc.py
  (Request.run_viewvc): Once the rootname is determined, overlay
    per-root configuration options.

* viewvc.conf.dist
  (vhosts): Update vhosts docs and examples to note the new "vhost-"
    section name prefix.

* docs/upgrading-howto.html
  Note the change in vhost override section naming expectations.


Modified: trunk/docs/upgrading-howto.html
Url: 
http://viewvc.tigris.org/source/browse/viewvc/trunk/docs/upgrading-howto.html?view=diff&rev=1607&p1=trunk/docs/upgrading-howto.html&p2=trunk/docs/upgrading-howto.html&r1=1606&r2=1607
==============================================================================
--- trunk/docs/upgrading-howto.html     (original)
+++ trunk/docs/upgrading-howto.html     2007-04-16 07:54:01-0700
@@ -177,6 +177,29 @@
 <p>The <code>use_rcsparse</code> option was moved from the "general"
    section to the "options" section.</p>
 
+<p>Custom sections which define per-virtual-host configuration option
+   overrides must now have their names prefixed with "vhost-".  For
+   example, the following configuration which was valid in ViewVC 1.0
+   is no longer valid:</p>
+
+<blockquote><pre>[vhosts]
+all = viewvc.*
+
+[all-options]
+allow_tar = 1
+</pre>
+</blockquote>
+
+<p>This now needs to be written like so:</p>
+
+<blockquote><pre>[vhosts]
+all = viewvc.*
+
+[vhost-all-options]
+allow_tar = 1
+</pre>
+</blockquote>
+
 </div>
 
 <div class="h3">

Modified: trunk/lib/config.py
Url: 
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/config.py?view=diff&rev=1607&p1=trunk/lib/config.py&p2=trunk/lib/config.py&r1=1606&r2=1607
==============================================================================
--- trunk/lib/config.py (original)
+++ trunk/lib/config.py 2007-04-16 07:54:01-0700
@@ -47,12 +47,12 @@
     for section in self._sections:
       setattr(self, section, _sub_config())
 
-  def load_config(self, pathname, vhost=None):
+  def load_config(self, pathname, vhost=None, rootname=None):
     self.conf_path = os.path.isfile(pathname) and pathname or None
     self.base = os.path.dirname(pathname)
-
+    
     parser = ConfigParser.ConfigParser()
-    parser.read(pathname)
+    parser.read(self.conf_path or [])
 
     for section in self._sections:
       if parser.has_section(section):
@@ -61,6 +61,9 @@
     if vhost and parser.has_section('vhosts'):
       self._process_vhost(parser, vhost)
 
+    if rootname:
+      self._process_root_options(parser, rootname)
+
   def load_kv_files(self, language):
     kv = _sub_config()
 
@@ -113,22 +116,23 @@
       setattr(sc, opt, value)
 
   def _process_vhost(self, parser, vhost):
+    # find a vhost name for this vhost, if any (if not, we've nothing to do)
     canon_vhost = self._find_canon_vhost(parser, vhost)
     if not canon_vhost:
-      # none of the vhost sections matched
       return
 
-    cv = canon_vhost + '-'
+    # overlay any option sections associated with this vhost name
+    cv = 'vhost-%s-' % (canon_vhost)
     lcv = len(cv)
     for section in parser.sections():
       if section[:lcv] == cv:
-        self._process_section(parser, section, section[lcv:])
+        base_section = section[lcv:]
+        if base_section not in self._sections:
+          raise IllegalOverrideSection('vhost', section)
+        self._process_section(parser, section, base_section)
 
   def _find_canon_vhost(self, parser, vhost):
-    vhost = string.lower(vhost)
-    # Strip (ignore) port number:
-    vhost = string.split(vhost, ':')[0]
-
+    vhost = string.split(string.lower(vhost), ':')[0]  # lower-case, no port
     for canon_vhost in parser.options('vhosts'):
       value = parser.get('vhosts', canon_vhost)
       patterns = map(string.lower, map(string.strip,
@@ -139,6 +143,24 @@
 
     return None
 
+  def _process_root_options(self, parser, rootname):
+    rn = 'root-%s-' % (rootname)
+    lrn = len(rn)
+    for section in parser.sections():
+      if section[:lrn] == rn:
+        base_section = section[lrn:]
+        if base_section not in self._sections or base_section == 'general':
+          raise IllegalOverrideSection('root', section)
+        self._process_section(parser, section, base_section)
+
+  def overlay_root_options(self, rootname):
+    "Overly per-root options atop the existing option set."
+    if not self.conf_path:
+      return
+    parser = ConfigParser.ConfigParser()
+    parser.read(self.conf_path or [])
+    self._process_root_options(parser, rootname)
+
   def set_defaults(self):
     "Set some default values in the configuration."
 
@@ -257,7 +279,18 @@
   return roots
 
 
-class MalformedRoot(Exception):
+class ViewVCConfigurationError(Exception):
+  pass
+
+class IllegalOverrideSection(ViewVCConfigurationError):
+  def __init__(self, override_type, section_name):
+    self.section_name = section_name
+    self.override_type = override_type
+  def __str__(self):
+    return "malformed configuration: illegal %s override section: %s" \
+           % (self.override_type, self.section_name)
+  
+class MalformedRoot(ViewVCConfigurationError):
   def __init__(self, config_name, value_given):
     Exception.__init__(self, config_name, value_given)
     self.config_name = config_name

Modified: trunk/lib/viewvc.py
Url: 
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/viewvc.py?view=diff&rev=1607&p1=trunk/lib/viewvc.py&p2=trunk/lib/viewvc.py&r1=1606&r2=1607
==============================================================================
--- trunk/lib/viewvc.py (original)
+++ trunk/lib/viewvc.py 2007-04-16 07:54:01-0700
@@ -221,6 +221,7 @@
     if self.rootname:
       # Create the repository object
       if cfg.general.cvs_roots.has_key(self.rootname):
+        cfg.overlay_root_options(self.rootname)
         self.rootpath = os.path.normpath(cfg.general.cvs_roots[self.rootname])
         try:
           if cfg.options.use_rcsparse:
@@ -243,6 +244,7 @@
         # required so that spawned rcs programs correctly expand $CVSHeader$
         os.environ['CVSROOT'] = self.rootpath
       elif cfg.general.svn_roots.has_key(self.rootname):
+        cfg.overlay_root_options(self.rootname)
         self.rootpath = cfg.general.svn_roots[self.rootname]
         try:
           if re.match(_re_rewrite_url, self.rootpath):

Modified: trunk/viewvc.conf.dist
Url: 
http://viewvc.tigris.org/source/browse/viewvc/trunk/viewvc.conf.dist?view=diff&rev=1607&p1=trunk/viewvc.conf.dist&p2=trunk/viewvc.conf.dist&r1=1606&r2=1607
==============================================================================
--- trunk/viewvc.conf.dist      (original)
+++ trunk/viewvc.conf.dist      2007-04-16 07:54:01-0700
@@ -666,25 +666,25 @@
 #
 # After you've named and defined your vhosts, you may then create new
 # configuration sections whose names are of the form
-# VHOSTNAME-CONFIGSECTION.  Inside those configuration sections, you
-# override the standard ViewVC options typically found in the
+# vhost-VHOSTNAME-CONFIGSECTION.  Inside those configuration sections, you
+# override the standard ViewVC options typically found in the base
 # configuration section named CONFIGSECTION ("general", "option", etc.)
 #
 # Here is an example:
 #
 # [vhosts]
-# svn-vhost = svn.yourdomain.*
-# cvs-vhost = cvs.yourdomain.*
+# svn = svn.yourdomain.*, viewvc.*
+# cvs = cvs.yourdomain.*
 #
-# [svn-vhost-general]
+# [vhost-svn-general]
 # cvs_roots = 
 # svn_roots = svnroot: /var/svn/repos
 # default_root = svnroot
 #
-# [svn-vhost-options]
+# [vhost-svn-options]
 # show_logs = 1
 #
-# [cvs-vhost-general]
+# [vhost-cvs-general]
 # cvs_roots = cvsroot: /var/cvs/cvsroot
 # svn_roots = 
 # default_root = cvsroot


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
db.firebase.por...    text.xml.xalan....    qnx.openqnx.dev...    user-groups.zar...    internationaliz...    kde.devel.konve...    finance.e-gold....    emacs.latex.pre...    gis.therion/200...    web.webmin.gene...    yellowdog.gener...    vserver/2003-08...    redhat.release....    sysutils.tivoli...    xfree86.expert/...    mail.becky.user...    hardware.netapp...    netbsd.ports.xe...    python.distutil...    boot-loaders.gr...    culture.interne...    java.springfram...    activedir/2006-...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe