Commit d7165154 authored by Tres Seaver's avatar Tres Seaver

Fix 'zconfig:' URIs under Python 2.7.

The code worked around a bug in the stdlib's 'urlparse.urlsplit' for
Python < 2.7; that workaround broke under 2.7.

Fixes #5
parent fbda3845
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
Unreleased Unreleased
---------- ----------
- Fix 'zconfig:' URIs under Python 2.7. The code worked around a bug in
the stdlib's 'urlparse.urlsplit' for Python < 2.7; that workaround broke
under 2.7. See https://github.com/Pylons/zodburi/issues/5
- Dropped support for Python 2.5. - Dropped support for Python 2.5.
1.1 (2012-09-12) 1.1 (2012-09-12)
......
import os
import cgi import cgi
from cStringIO import StringIO from cStringIO import StringIO
import os
import sys
import urlparse import urlparse
from ZODB.config import ZODBDatabase from ZODB.config import ZODBDatabase
...@@ -167,8 +168,11 @@ class ZConfigURIResolver(object): ...@@ -167,8 +168,11 @@ class ZConfigURIResolver(object):
def __call__(self, uri): def __call__(self, uri):
(scheme, netloc, path, query, frag) = urlparse.urlsplit(uri) (scheme, netloc, path, query, frag) = urlparse.urlsplit(uri)
# urlparse doesnt understand file URLs and stuffs everything into path if sys.version_info[:2] == (2, 6):
(scheme, netloc, path, query, frag) = urlparse.urlsplit('http:' + path) # 2.6 urlparse doesnt understand file URLs and stuffs everything
# into path
(scheme, netloc, path, query, frag
) = urlparse.urlsplit('http:' + path)
path = os.path.normpath(path) path = os.path.normpath(path)
schema_xml = self.schema_xml_template schema_xml = self.schema_xml_template
schema = ZConfig.loadSchemaFile(StringIO(schema_xml)) schema = ZConfig.loadSchemaFile(StringIO(schema_xml))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment