[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/DTMLPage - DTMLPage.py:1.1 DTMLPageFields.py:1.1 __init__.py:1.1 configure.zcml:1.1 dtml.gif:1.1
Stephan Richter
srichter@cbu.edu
Wed, 10 Jul 2002 20:17:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/DTMLPage
In directory cvs.zope.org:/tmp/cvs-serv13931/DTMLPage
Added Files:
DTMLPage.py DTMLPageFields.py __init__.py configure.zcml
dtml.gif
Log Message:
Similar to the ZPT Page we should also have a DTML Page. Currently it does
not implement the DTML 2 proposal (no time). :(
=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/DTMLPage.py ===
##############################################################################
#
# 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: DTMLPage.py,v 1.1 2002/07/11 00:17:01 srichter Exp $
"""
from Interface import Interface
from Interface.Attribute import Attribute
from Persistence import Persistent
from Zope.ContextWrapper import ContextMethod
from Zope.Proxy.ContextWrapper import getWrapperContainer
from Zope.Security.Proxy import ProxyFactory
from Zope.DocumentTemplate.pDocumentTemplate import MultiMapping
from Zope.DocumentTemplate.DT_HTML import HTML
from Zope.App.OFS.Content.IFileContent import IFileContent
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.
"""
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.
"""
class DTMLPage(Persistent):
# XXX Putting IFileContent at the end gives an error!
__implements__ = IFileContent, IDTMLPage, IRenderDTMLPage
def __init__(self, source=''):
self.setSource(source)
############################################################
# Implementation methods for interface
# Zope.App.OFS.DTMLPage.DTMLPage.IDTMLPage
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
###########################################
# Zope.App.OFS.DTMLPage.DTMLPage.IDTMLRenderPage
def render(self, request, *args, **kw):
"""See interface IDTMLRenderPage"""
instance = ProxyFactory(getWrapperContainer(self))
request = ProxyFactory(request)
for k in kw:
kw[k] = ProxyFactory(kw[k])
kw['REQUEST'] = request
return self.template(instance, request, **kw)
#
############################################################
render = ContextMethod(render)
__call__ = render
=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/DTMLPageFields.py ===
##############################################################################
#
# 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: DTMLPageFields.py,v 1.1 2002/07/11 00:17:01 srichter Exp $
"""
from Zope.App.Formulator.FieldRegistry import getField
from Zope.App.Formulator.ValidatorRegistry import getValidator
SourceField = getField('StringField')(
id = 'source',
title = 'DTML Page Source',
description = 'DTML Source Code',
default = ''
)
=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/__init__.py ===
##############################################################################
#
# 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: __init__.py,v 1.1 2002/07/11 00:17:01 srichter Exp $
"""
=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/configure.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:browser='http://namespaces.zope.org/browser'
>
<content class=".DTMLPage.">
<factory
id="DTMLPage"
permission="Zope.ManageContent"
title="DTML Page"
description="A simple, content-based Page Template" />
<require permission="Zope.View"
attributes="content_type __call__" />
<require permission="Zope.ManageContent"
interface=".DTMLPage.IDTMLPage" />
<require permission="Zope.View"
interface=".DTMLPage.IRenderDTMLPage" />
</content>
<adapter
factory="Zope.App.OFS.Annotation.AttributeAnnotations."
provides="Zope.App.OFS.Annotation.IAnnotations."
for=".DTMLPage." />
<include package=".Views" />
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/OFS/Content/DTMLPage/dtml.gif ===
<Binary-ish file>