[Zope3-checkins]
SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/
Fix obscure case of files without extensions in resource
directories.
Fred L. Drake, Jr.
fdrake at gmail.com
Fri Aug 6 14:57:44 EDT 2004
Log message for revision 26942:
Fix obscure case of files without extensions in resource directories.
Files with names that matched the extensions being checked for could
have the wrong kind of resource created for them; imparticular, files
named simply "png" or "gif" (a really weird case) would have image
resources created for them rather than simple file resources. Fixed,
added a test case.
Use a instance of object for the marker value, since that's a simpler,
immutable object with a smaller memory requirement.
(merged from Zope 3 trunk revision 26941)
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/directoryresource.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
A Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/testfiles/png
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/directoryresource.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/directoryresource.py 2004-08-06 18:55:23 UTC (rev 26941)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/directoryresource.py 2004-08-06 18:57:44 UTC (rev 26942)
@@ -29,7 +29,7 @@
from pagetemplateresource import PageTemplateResourceFactory
from resources import empty
-_marker = []
+_marker = object()
# we only need this class a context for DirectoryResource
class Directory:
@@ -43,12 +43,12 @@
implements(IBrowserPublisher)
resource_factories = {
- 'gif': ImageResourceFactory,
- 'png': ImageResourceFactory,
- 'jpg': ImageResourceFactory,
- 'pt': PageTemplateResourceFactory,
- 'zpt': PageTemplateResourceFactory,
- 'html': PageTemplateResourceFactory,
+ '.gif': ImageResourceFactory,
+ '.png': ImageResourceFactory,
+ '.jpg': ImageResourceFactory,
+ '.pt': PageTemplateResourceFactory,
+ '.zpt': PageTemplateResourceFactory,
+ '.html': PageTemplateResourceFactory,
}
default_factory = FileResourceFactory
@@ -75,7 +75,7 @@
if default is _marker:
raise NotFoundError(name)
return default
- ext = name.split('.')[-1]
+ ext = os.path.splitext(os.path.normcase(name))[1]
factory = self.resource_factories.get(ext, self.default_factory)
resource = factory(filename, self.context.checker)(self.request)
resource.__parent__ = self
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-08-06 18:55:23 UTC (rev 26941)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-08-06 18:57:44 UTC (rev 26942)
@@ -110,6 +110,8 @@
self.assert_(isinstance(removeAllProxies(template), PageTemplateResource))
file = resource['test.txt']
self.assert_(isinstance(removeAllProxies(file), FileResource))
+ file = resource['png']
+ self.assert_(isinstance(removeAllProxies(file), FileResource))
def test_suite():
return makeSuite(Test)
Copied: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/testfiles/png (from rev 26941, Zope3/trunk/src/zope/app/publisher/browser/tests/testfiles/png)
Property changes on: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/testfiles/png
___________________________________________________________________
Name: cvs2svn:cvs-rev
+ 1.1
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list