[Zope3-checkins] CVS: Zope3/src/zope/products/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
Wed Feb 11 11:29:20 EST 2004


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

Added Files:
      Tag: philikon-movecontent-branch
	__init__.py browser.py configure.zcml dtml.gif dtmlpage.py 
	fssync.py interfaces.py 
Log Message:
Get rid of zope.products.content and zope.products.codecontent and move
content components in their own packages at zope.products.

See the package geddon proposal: http://dev.zope.org/Zope3/PackageGeddon


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


=== Added File Zope3/src/zope/products/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/11 16:29:18 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/products/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'
    >

  <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.interfaces.folder.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.products.dtmlpage.DTMLPage"
      permission="zope.ManageContent"
      />

  <browser:addMenuItem
      class=".dtmlpage.DTMLPage"
      title="DTML Page"
      view="zope.products.dtmlpage.DTMLPage"
      permission="zope.ManageContent"
      />

</configure>


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

=== Added File Zope3/src/zope/products/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/11 16:29:18 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.products.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/products/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/11 16:29:18 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/products/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/11 16:29:18 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