[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser - ZPTPageEdit.py:1.1.2.1 ZPTPageEval.py:1.1.2.1 __init__.py:1.1.2.1 browser.zcml:1.1.2.1 edit.pt:1.1.2.1

Stephan Richter srichter@cbu.edu
Wed, 27 Mar 2002 10:54:42 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv12282/Content/ZPTPage/Views/Browser

Added Files:
      Tag: Zope-3x-branch
	ZPTPageEdit.py ZPTPageEval.py __init__.py browser.zcml edit.pt 
Log Message:
New Content Objects:

- NaiveFile --> all the data is stored in one string
- File --> Uses a BTree to store the data in chunks (more efficient)
- Image --> Can store and display an image a la Z2 (based on File)
- ZPTPage --> A simple version of ZPT for the content space to allow some 
  dynamics data (please do not use this for scripting)

Also:

- Expansion of supported views
- all edit screens are Formulator supported



=== Added File Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/ZPTPageEdit.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: ZPTPageEdit.py,v 1.1.2.1 2002/03/27 15:54:41 srichter Exp $
"""

from Zope.App.Formulator.Form import Form
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile


class ZPTPageEdit(Form):

    __implements__ = Form.__implements__

    name = 'editForm'     
    title = 'Edit Form'
    description = ('This edit form allows you to make changes to the ' +
                   'source code of this ZPT Page.')

    _fieldViewNames = ['SourceFieldView']
    template = PageTemplateFile('edit.pt')


=== Added File Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/ZPTPageEval.py ===
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
"""

from Zope.Publisher.Browser.AttributePublisher import AttributePublisher


class ZPTPageEval( AttributePublisher ):

    __implements__ = AttributePublisher.__implements__
    
    def __init__( self, zptpage ):
        self._zptpage = zptpage


    def getContext( self ):
        return self._zptpage
    

    def pt_getContext(self, inst=None, REQUEST=None):
        #root = self.getPhysicalRoot()
        c = {'template': self.getContext(),
             'nothing': None,
             }
        if inst is not None:
            c['here'] = inst.getContext()
            c['container'] = inst
            c['views'] = ViewMapper(inst.getContext(), REQUEST)
        return c


    def index(self, inst=None, REQUEST=None, **kw):
        """Call a Page Template"""
        bound_names = {}
        bound_names.update(self.pt_getContext(inst, REQUEST))
        bound_names['options'] = kw
        bound_names['request'] = REQUEST

        try:
            self.REQUEST.getResponse().setHeader('content-type',
                                            self.getContext().content_type)
        except AttributeError:
            pass

        # Execute the template in a new security context.
        self.getContext()._cook()
        return self.getContext().pt_render(bound_names)


    def document_src(self, REQUEST=None):
        """Return expanded document source."""

        if REQUEST is not None:
            REQUEST.getResponse().setHeader('Content-Type', self.content_type)
        return self.read()



=== Added File Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/__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 1.1 (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.2.1 2002/03/27 15:54:41 srichter Exp $
"""


=== Added File Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/browser.zcml ===
<zopeConfigure
   xmlns='http://namespaces.zope.org/zope'
   xmlns:security='http://namespaces.zope.org/security'
   xmlns:browser='http://namespaces.zope.org/browser'
>

  <!-- ZPT Page View Directives -->

  <browser:defaultView name="eval"
    for="Zope.App.OFS.Content.ZPTPage.ZPTPage.IZPTPage."
    factory=".ZPTPageEval." />

  <security:protectClass 
    name=".ZPTPageEval."
    permission_id="Zope.View" methods="index" />

  <browser:view name="edit"
    for="Zope.App.OFS.Content.ZPTPage.ZPTPage.IZPTPage."
    factory=".ZPTPageEdit." />

  <security:protectClass 
    name=".ZPTPageEdit."
    permission_id="Zope.View" methods="index, action" />


  <!-- Registering all the field views for the browser -->

  <browser:view name="SourceFieldView"
    for="Zope.App.OFS.Content.ZPTPage.ZPTPage.IZPTPage."
    factory="Zope.App.OFS.Content.ZPTPage.ZPTPageFields.SourceField. 
             Zope.App.Formulator.Widgets.Browser.TextAreaWidget." />

</zopeConfigure>


=== Added File Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/edit.pt ===
<html metal:use-macro="views/standard_macros/page">
  <head>
    <style metal:fill-slot="headers" type="text/css">
      <!--
      .ContentIcon {
	  width: 20px;
      }
      
      .ContentTitle {
	  text-align: left;
      }
      -->
    </style>
  </head>

  <body>
    <div metal:fill-slot="body">

 
 
      <p tal:content="here/msg"
         tal:condition="python: hasattr(here, 'msg')">
        Message will go here.
      </p>

      <p tal:content="container/description">
        Description of the Form.
      </p>


      <div tal:condition="python: options.has_key('errors') and options['errors']">
        Errors:
        <div tal:repeat="error options/errors | nothing"
             tal:content="error">Foo </div>
      </div>

      <form action="action" method="post">

        <table class="EditTable">      
	  <tbody>   
  
	    <tr tal:repeat="fieldView python:container.getFieldViews(request)">
	      <th class="EditAttributeName"
                  tal:content="python: fieldView.getContext().getValue('title')">Title</th>
	      <td class="EditAttributeValue"
	          tal:content="structure fieldView/render"><input />
              </td>
	    </tr>
  
	  </tbody>     
      </table>

      <input type="submit" name="edit" value="Save Changes">

      </form> 

    </div>
  </body>
</html>