[Zope-Checkins] CVS: Zope/lib/python/Controller - Directives.py:1.1.2.5
Chris McDonough
chrism@zope.com
Fri, 11 Oct 2002 14:34:35 -0400
Update of /cvs-repository/Zope/lib/python/Controller
In directory cvs.zope.org:/tmp/cvs-serv15045
Modified Files:
Tag: chrism-install-branch
Directives.py
Log Message:
Convert locations to URLs so ZConfig can handle them.
=== Zope/lib/python/Controller/Directives.py 1.1.2.4 => 1.1.2.5 ===
--- Zope/lib/python/Controller/Directives.py:1.1.2.4 Wed Oct 9 01:05:55 2002
+++ Zope/lib/python/Controller/Directives.py Fri Oct 11 14:34:34 2002
@@ -76,8 +76,8 @@
def reconfigure(self, config_filename):
self.resetDefaults()
- self.location = munge_config_loc_name(config_filename)
- zconfig = ZConfig.load(self.location)
+ self.location = config_filename
+ zconfig = ZConfig.load(filename2url(self.location))
for name, value in zconfig.items():
directive = self._names[name][1]
directive.set(value, zconfig)
@@ -201,13 +201,18 @@
klass = dispatch[d['type']]
return apply(klass, (), d)
-def munge_config_loc_name(name):
- name.strip()
- prefixes = ('http://', 'file://', 'https://')
- has_prefix = not not filter(lambda x,n=name: n.startswith(x), prefixes)
- if has_prefix:
+def filename2url(name):
+ if filter(name.startswith, ('http://', 'https://', 'ftp://', 'file://')):
+ # smells like its already a URL
return name
- return 'file://%s' % name
+ from urllib import pathname2url
+ try:
+ url = pathname2url(name)
+ except IOError:
+ # pathname was probably already a URL
+ return name
+ else:
+ return 'file:' + url
DirectiveRegistry = DirectiveRegistry()