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

Philipp von Weitershausen philikon at philikon.de
Fri Feb 20 14:36:24 EST 2004


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

Added Files:
      Tag: philikon-movecontent-branch
	__init__.py browser.py configure.zcml dtml.gif dtmlpage.py 
	fssync.py interfaces.py 
Log Message:
Added zope.app.dtmlpage.


=== Added File Zope3/src/zope/app/dtmlpage/__init__.py ===
#
# This file is necessary to make this directory a package.


=== Added File Zope3/src/zope/app/dtmlpage/browser.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.
#
##############################################################################
"""Define view component for ZPT page eval results.

$Id: browser.py,v 1.1.2.1 2004/02/20 19:36:23 philikon Exp $
"""
__metaclass__ = type

class DTMLPageEval:

    def index(self, REQUEST=None, **kw):
        """Call a Page Template"""

        template = self.context
        return template.render(REQUEST, **kw)


=== Added File Zope3/src/zope/app/dtmlpage/configure.zcml ===
<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 -->

  <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 Page Template"
        />

    <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:page
      for=".interfaces.IDTMLPage"
      name="preview.html"
      menu="zmi_views" title="Preview"
      template="preview.pt"
      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"
      view="zope.app.dtmlpage.DTMLPage"
      permission="zope.ManageContent"
      />

</configure>


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

=== Added File Zope3/src/zope/app/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.2.1 2004/02/20 19:36:23 philikon Exp $
"""
from persistence 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


=== Added File Zope3/src/zope/app/dtmlpage/fssync.py ===
##############################################################################
#
# 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: fssync.py,v 1.1.2.1 2004/02/20 19:36:23 philikon Exp $
"""

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)


=== Added File Zope3/src/zope/app/dtmlpage/interfaces.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: interfaces.py,v 1.1.2.1 2004/02/20 19:36:23 philikon Exp $
"""
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