[Zope-Checkins] CVS: Zope/lib/python/webdav - NullResource.py:1.34.2.1

Brian Lloyd brian@digicool.com
Wed, 5 Dec 2001 09:56:51 -0500


Update of /cvs-repository/Zope/lib/python/webdav
In directory cvs.zope.org:/tmp/cvs-serv28118

Modified Files:
      Tag: Zope-2_5-branch
	NullResource.py 
Log Message:
Added recognition of '.pt' extension in default PUT handler to create 
PageTemplate objects.


=== Zope/lib/python/webdav/NullResource.py 1.34 => 1.34.2.1 ===
 from zExceptions import Unauthorized
 
+
 class NullResource(Persistent, Acquisition.Implicit, Resource):
     """Null resources are used to handle HTTP method calls on
     objects which do not yet exist in the url namespace."""
@@ -63,14 +64,18 @@
     DELETE=TRACE=PROPFIND=PROPPATCH=COPY=MOVE=HEAD
 
     def _default_PUT_factory( self, name, typ, body ):
-        #   Return DTMLDoc/Image/File, based on sniffing.
-        from OFS.Image import Image, File
-        from OFS.DTMLDocument import DTMLDocument
-        if typ in ('text/html', 'text/xml', 'text/plain'):
+        # Return DTMLDoc/PageTemplate/Image/File, based on sniffing.
+        if name and name.endswith('.pt'):
+            from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+            ob = ZopePageTemplate(name, body, content_type=typ)
+        elif typ in ('text/html', 'text/xml', 'text/plain'):      
+            from OFS.DTMLDocument import DTMLDocument
             ob = DTMLDocument( '', __name__=name )
         elif typ[:6]=='image/':
+            from OFS.Image import Image
             ob=Image(name, '', body, content_type=typ)
         else:
+            from OFS.Image import File
             ob=File(name, '', body, content_type=typ)
         return ob