[Zope3-checkins] CVS: Zope3/src/zope/app/content - configure.zcml:1.20 dtmlpage.py:1.5

Guido van Rossum guido@python.org
Thu, 29 May 2003 12:48:16 -0400


Update of /cvs-repository/Zope3/src/zope/app/content
In directory cvs.zope.org:/tmp/cvs-serv16005

Modified Files:
	configure.zcml dtmlpage.py 
Log Message:
Add a IFileFactory adapter named .dtml to create DTML pages.

=== Zope3/src/zope/app/content/configure.zcml 1.19 => 1.20 ===
--- Zope3/src/zope/app/content/configure.zcml:1.19	Thu May 29 12:36:41 2003
+++ Zope3/src/zope/app/content/configure.zcml	Thu May 29 12:48:16 2003
@@ -222,6 +222,14 @@
 
 </content>
 
+<adapter 
+  for="zope.app.interfaces.content.folder.IFolder"
+  provides="zope.app.interfaces.file.IFileFactory"
+  name=".dtml"
+  factory=".dtmlpage.DTMLFactory"
+  permission="zope.ManageContent"
+  />
+
 
 <content class="zope.app.content.file.File">
 


=== Zope3/src/zope/app/content/dtmlpage.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/content/dtmlpage.py:1.4	Tue May 27 10:18:14 2003
+++ Zope3/src/zope/app/content/dtmlpage.py	Thu May 29 12:48:16 2003
@@ -19,6 +19,7 @@
 from zope.app.interfaces.annotation import IAnnotatable
 from zope.app.interfaces.content.file import IFileContent
 from zope.app.interfaces.content.dtmlpage import IDTMLPage, IRenderDTMLPage
+from zope.app.interfaces.file import IFileFactory
 
 from zope.context import ContextMethod
 from zope.context import getWrapperContainer
@@ -62,3 +63,15 @@
 
     source = property(getSource, setSource, None,
                       """Source of the DTML Page.""")
+
+class DTMLFactory(object):
+
+    __implements__ = IFileFactory
+
+    def __init__(self, context):
+        self.context = context
+
+    def __call__(self, name, content_type, data):
+        r = DTMLPage()
+        r.setSource(data, content_type or 'text/html')
+        return r