[Zodb-checkins] CVS: Packages/ZConfig - loader.py:1.3

Fred L. Drake, Jr. fred@zope.com
Fri, 3 Jan 2003 17:37:09 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv27486

Modified Files:
	loader.py 
Log Message:
- remove zconfig: URL support; that's not the "right way"
- make sure we convert URLs to 8-bit string before passing to
  urllib2.urlopen(), since the Python 2.1 version is broken in that
  case


=== Packages/ZConfig/loader.py 1.2 => 1.3 ===
--- Packages/ZConfig/loader.py:1.2	Fri Jan  3 16:05:51 2003
+++ Packages/ZConfig/loader.py	Fri Jan  3 17:37:05 2003
@@ -79,15 +79,14 @@
         # resources.  The policy needs to support both re-retrieve on
         # change and provide the cached resource when the remote
         # resource is not accessible.
-        parts = list(urlsplit(url))
+        url = str(url)
+        parts = urlsplit(url)
         fragment = parts[-1]
         if fragment:
+            parts = list(parts)
             parts[-1] = ''
             url = urlunsplit(tuple(parts))
-        if parts[0] == 'zconfig':
-            file = _open_resource_file(url)
-        else:
-            file = urllib2.urlopen(url)
+        file = urllib2.urlopen(url)
         return self.createResource(file, url, fragment or None)
 
     def normalizeURL(self, url):
@@ -112,15 +111,6 @@
         return "file://" + urllib.pathname2url(os.path.abspath(name))
     else:
         return None
-
-
-def _open_resource_file(url):
-    parts = urlsplit(url)
-    assert parts[0] == 'zconfig'
-    fn = os.path.join(RESOURCE_DIR, parts[2])
-    if not os.path.isfile(fn):
-        raise ValueError("no such resource: " + `parts[2]`)
-    return open(fn)
 
 
 class SchemaLoader(BaseLoader):