[Zope3-checkins] CVS: Zope3/src/zope/app/dtmlpage - __init__.py:1.2 browser.py:1.2 configure.zcml:1.2 dtml.gif:1.2 dtmlpage.py:1.2 fssync.py:1.2 interfaces.py:1.2

Philipp von Weitershausen philikon at philikon.de
Tue Feb 24 11:50:09 EST 2004


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

Added Files:
	__init__.py browser.py configure.zcml dtml.gif dtmlpage.py 
	fssync.py interfaces.py 
Log Message:


Moved the DTML Page content type to its own package below zope.app,
including its interfaces and browser views.




=== Zope3/src/zope/app/dtmlpage/__init__.py 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/__init__.py	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,2 @@
+#
+# This file is necessary to make this directory a package.


=== Zope3/src/zope/app/dtmlpage/browser.py 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/browser.py	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Define view component for ZPT page eval results.
+
+$Id$
+"""
+__metaclass__ = type
+
+class DTMLPageEval:
+
+    def index(self, REQUEST=None, **kw):
+        """Call a Page Template"""
+
+        template = self.context
+        return template.render(REQUEST, **kw)


=== Zope3/src/zope/app/dtmlpage/configure.zcml 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/configure.zcml	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,124 @@
+<configure
+    xmlns='http://namespaces.zope.org/zope'
+    xmlns:browser='http://namespaces.zope.org/browser'
+    xmlns:fssync='http://namespaces.zope.org/fssync'
+    i18n_domain='zope'
+    >
+
+  <!-- Module alias for backward compat
+       Will go away once we have a conversion script -->
+
+  <modulealias
+      module=".dtmlpage"
+      alias="zope.app.content.dtmlpage"
+      />
+
+  <modulealias
+      module=".interfaces"
+      alias="zope.app.interfaces.content.dtmlpage"
+      />
+
+
+
+  <interface 
+      interface=".interfaces.IDTMLPage" 
+      type="zope.app.interfaces.content.IContentType"
+      /> 
+
+  <content class=".dtmlpage.DTMLPage">
+    <factory
+        id="DTMLPage"
+        permission="zope.ManageContent"
+        title="DTML Page"
+        description="A simple, content-based DTML Page"
+        />
+
+    <require
+        permission="zope.View"
+        attributes="__call__"
+        />
+
+    <require
+        permission="zope.ManageContent"
+        interface=".interfaces.IDTMLPage" 
+        set_attributes="source"
+        />
+
+    <require
+        permission="zope.View"
+        interface=".interfaces.IRenderDTMLPage"
+        />
+
+    <implements
+       interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+       />
+  </content>
+
+  <adapter 
+      for="zope.app.folder.interfaces.IFolder"
+      provides="zope.app.interfaces.file.IFileFactory"
+      name=".dtml"
+      factory=".dtmlpage.DTMLFactory"
+      permission="zope.ManageContent"
+      />
+
+  <fssync:adapter
+      class=".dtmlpage.DTMLPage"
+      factory=".fssync.DTMLPageAdapter"
+      />
+
+
+  <!-- browser directives -->
+
+  <browser:page
+      name="index.html"
+      for=".interfaces.IDTMLPage"
+      permission="zope.View"
+      class=".browser.DTMLPageEval"
+      attribute="index"
+      />
+
+  <browser:editform
+      schema=".interfaces.IDTMLPage"
+      name="edit.html"
+      menu="zmi_views"
+      label="Edit a DTML page"
+      permission="zope.ManageContent"
+      />
+
+  <browser:icon
+      name="zmi_icon"
+      for=".interfaces.IDTMLPage"
+      file="dtml.gif"
+      />
+
+  <browser:addform
+      schema=".interfaces.IDTMLPage"
+      label="Add a DTML Page"
+      content_factory=".dtmlpage.DTMLPage"
+      name="zope.app.dtmlpage.DTMLPage"
+      permission="zope.ManageContent"
+      />
+
+  <browser:addMenuItem
+      class=".dtmlpage.DTMLPage"
+      title="DTML Page"
+      description="A simple, content-based DTML page"
+      view="zope.app.dtmlpage.DTMLPage"
+      permission="zope.ManageContent"
+      />
+
+
+  <!-- Preview view - requires zope.app.preview -->
+
+  <configure package="zope.app.preview">
+    <browser:page
+        for="zope.app.dtmlpage.interfaces.IDTMLPage"
+        name="preview.html"
+        template="preview.pt"
+        permission="zope.ManageContent"
+        menu="zmi_views" title="Preview"
+        />
+  </configure>
+
+</configure>


=== Zope3/src/zope/app/dtmlpage/dtml.gif 1.1 => 1.2 ===
  <Binary-ish file>

=== Zope3/src/zope/app/dtmlpage/dtmlpage.py 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/dtmlpage.py	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,73 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+from persistent import Persistent
+
+from zope.security.proxy import ProxyFactory
+from zope.documenttemplate.dt_html import HTML
+from zope.interface import implements
+
+from zope.app.interfaces.annotation import IAnnotatable
+from zope.app.interfaces.file import IFileFactory
+from zope.app.container.contained import Contained
+
+from zope.app.file.interfaces import IFileContent
+from interfaces import IDTMLPage, IRenderDTMLPage
+
+class DTMLPage(Persistent, Contained):
+    #XXX Putting IFileContent at the end gives an error!
+    implements(IFileContent, IDTMLPage, IRenderDTMLPage, IAnnotatable)
+
+    def __init__(self, source=''):
+        self.setSource(source)
+
+    def getSource(self):
+        '''See interface IDTMLPage'''
+        return self.template.read()
+
+    def setSource(self, text, content_type='text/html'):
+        '''See interface IDTMLPage'''
+        self.template = HTML(text.encode('utf-8'))
+        self.content_type = content_type
+
+    def render(self, request, *args, **kw):
+        """See interface IDTMLRenderPage"""
+
+        instance = ProxyFactory(self.__parent__)
+        request = ProxyFactory(request)
+
+        for k in kw:
+            kw[k] = ProxyFactory(kw[k])
+        kw['REQUEST'] = request
+
+        return self.template(instance, request, **kw)
+
+
+    __call__ = render
+
+    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


=== Zope3/src/zope/app/dtmlpage/fssync.py 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/fssync.py	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""Filesystem synchronization support.
+
+$Id$
+"""
+
+from zope.interface import implements
+from zope.fssync.server.entryadapter import ObjectEntryAdapter
+from zope.fssync.server.interfaces import IObjectFile
+
+class DTMLPageAdapter(ObjectEntryAdapter):
+    implements(IObjectFile)
+
+    def getBody(self):
+        return self.context.getSource()
+
+    def setBody(self, data):
+        self.context.setSource(data)


=== Zope3/src/zope/app/dtmlpage/interfaces.py 1.1 => 1.2 ===
--- /dev/null	Tue Feb 24 11:50:09 2004
+++ Zope3/src/zope/app/dtmlpage/interfaces.py	Tue Feb 24 11:49:37 2004
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+import zope.schema
+from zope.interface import Interface, Attribute
+from zope.app.i18n import ZopeMessageIDFactory as _
+
+class IDTMLPage(Interface):
+    """DTML Pages are a persistent implementation of DTML."""
+
+    def setSource(text, content_type='text/html'):
+        """Save the source of the page template."""
+
+    def getSource():
+        """Get the source of the page template."""
+
+    source = zope.schema.Text(
+        title=_(u"Source"),
+        description=_(u"""The source of the dtml page."""),
+        required=True)
+
+
+class IRenderDTMLPage(Interface):
+
+    content_type = Attribute('Content type of generated output')
+
+    def render(request, *args, **kw):
+        """Render the page template.
+
+        The first argument is bound to the top-level 'request'
+        variable. The positional arguments are bound to the 'args'
+        variable and the keyword arguments are bound to the 'options'
+        variable.
+        """




More information about the Zope3-Checkins mailing list