[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage - ZPTPage.py:1.2 ZPTPageFields.py:1.2 __init__.py:1.2 zptpage.zcml:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:37 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/ZPTPage
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Content/ZPTPage
Added Files:
ZPTPage.py ZPTPageFields.py __init__.py zptpage.zcml
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/ZPTPage.py 1.1 => 1.2 ===
+#
+# 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 Interface import Interface
+from Interface.Attribute import Attribute
+from Persistence import Persistent
+from Zope.PageTemplate.PageTemplate import PageTemplate
+from Zope.App.PageTemplate.Engine import AppPT
+from Zope.ContextWrapper import ContextMethod
+from Zope.Proxy.ContextWrapper import getWrapperContainer
+from Zope.Security.Proxy import ProxyFactory
+from Zope.App.OFS.Content.IFileContent import IFileContent
+
+class IZPTPage(Interface):
+ """ZPT Pages are a persistent implementation of Page Templates.
+
+ Note: I introduced some new methods whose functionality is
+ actually already covered by some other methods but I
+ want to start inforcing a common coding standard.
+ """
+
+ def setSource(text, content_type='text/html'):
+ """Save the source of the page template.
+ """
+
+
+ def getSource():
+ """Get the source of the page template.
+ """
+
+class IRenderZPTPage(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.
+ """
+
+
+class ZPTPage(AppPT, PageTemplate, Persistent):
+
+ # XXX Putting IFileContent at the end gives an error!
+ __implements__ = IFileContent, IZPTPage, IRenderZPTPage
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.OFS.ZPTPage.ZPTPage.IZPTPage
+
+ def getSource(self):
+ '''See interface IZPTPage'''
+ return self.read()
+
+
+ def setSource(self, text, content_type='text/html'):
+ '''See interface IZPTPage'''
+ self.pt_edit(text, content_type)
+
+ #
+ ############################################################
+
+
+ def pt_getContext(self, instance, request, **_kw):
+ # instance is a View component
+ namespace = super(ZPTPage, self).pt_getContext(**_kw)
+ namespace['request'] = request
+ namespace['context'] = instance
+ return namespace
+
+ def render(self, request, *args, **keywords):
+
+ instance = getWrapperContainer(self)
+
+ request = ProxyFactory(request)
+ instance = ProxyFactory(instance)
+ if args: args = ProxyFactory(args)
+ kw = ProxyFactory(keywords)
+
+ namespace = self.pt_getContext(instance, request,
+ args=args, options=kw)
+
+ return self.pt_render(namespace)
+
+ render = ContextMethod(render)
+
=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/ZPTPageFields.py 1.1 => 1.2 ===
+#
+# 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 Zope.App.Formulator.FieldRegistry import getField
+from Zope.App.Formulator.ValidatorRegistry import getValidator
+
+
+SourceField = getField('StringField')(
+ id = 'source',
+ title = 'ZPT Page Source',
+ description = 'Page Template Source Code',
+ default = ''
+ )
=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/__init__.py 1.1 => 1.2 ===
+#
+# 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$
+"""
=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/zptpage.zcml 1.1 => 1.2 ===
+ xmlns='http://namespaces.zope.org/zope'
+ xmlns:security='http://namespaces.zope.org/security'
+ xmlns:browser='http://namespaces.zope.org/browser'
+ xmlns:zmi='http://namespaces.zope.org/zmi'
+>
+
+ <content class=".ZPTPage.">
+ <zmi:factory
+ id="ZPTPage"
+ permission="Zope.ManageContent"
+ title="ZPT Page"
+ description="A simple, content-based Page Template" />
+ <security:require permission="Zope.View"
+ attributes="content_type __call__" />
+
+ <security:require permission="Zope.ManageContent"
+ interface=".ZPTPage.IZPTPage" />
+ <security:require permission="Zope.View"
+ interface=".ZPTPage.IRenderZPTPage" />
+ </content>
+
+
+ <adapter
+ factory="Zope.App.OFS.Annotation.AttributeAnnotations."
+ provides="Zope.App.OFS.Annotation.IAnnotations."
+ for=".ZPTPage." />
+
+
+ <!-- tabs for ZPT Page -->
+
+ <zmi:tabs for=".ZPTPage.IZPTPage.">
+ <zmi:tab label="Edit" action="editForm.html"/>
+ <zmi:tab label="View" action="."/>
+ <!-- XXX This isn't working
+ <zmi:tab label="Role Permissions"
+ action="AllRolePermissions.html"/>
+ -->
+ </zmi:tabs>
+
+ <include package=".Views" file="views.zcml" />
+
+</zopeConfigure>