[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/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
Fri, 1 Mar 2002 01:37:15 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ZPTPage/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv10334/ZPTPage/Views/Browser
Added Files:
Tag: srichter-OFS_Formulator-branch
ZPTPageEdit.py ZPTPageEval.py __init__.py browser.zcml edit.pt
Log Message:
Okay, I am finally ready to check this stuff in:
- Reorganized the internal directory structure of every content object. For
each content object you have now a Views directory that contains further
directories for different protocols, such as Browser (HTML), XUL, FTP ...
Note: None of the directories is file-type, but functionality-based. It
is a bad idea to create directories for a particular file type, as
it was common in Zope 2.
- Made Folder, File and Image forms Formulator-based. This allows us now to
create forms for new protocols. such as XUL very quickly (often just a
few lines of code). More to Formulator when it is being checked in.
- Cleaned up most files. Almost all files should have now the correct
license disclaimer.
- A new object called LoadedFolder was added. LoadedFolder currently
provides two new functionalities to folders:
1. Ordering. You can change the order of the objects. This idea was
taking from the Zope 2 product OrderedFolders.
2. Limit. You can specify the maximal amount of items the folder is
allowed to store. This idea was also taken from OrderedFolders.
Note: Due to much rearranging during this development, there are no tests
yet written for this. This needs to be done, before we merge with
the Zoep-3x-branch again.
- Started XUL implementation of screens.
- Fixed some bugs I found lying around.
=== Added File Zope3/lib/python/Zope/App/OFS/ZPTPage/Views/Browser/ZPTPageEdit.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 editing.
"""
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
class ZPTPageEdit( AttributePublisher ):
__implements__ = AttributePublisher.__implements__
def __init__( self, zptpage ):
self._zptpage = zptpage
def editAction(self, source, REQUEST=None):
zptpage = self.getContext()
zptpage.setSource(source)
if REQUEST is not None:
return self.index(REQUEST, msg='ZPT Page Edited.')
def getContext( self ):
return self._zptpage
index = PageTemplateFile('edit.pt')
=== Added File Zope3/lib/python/Zope/App/OFS/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
from Zope.PageTemplate.Expressions import SecureModuleImporter
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,
#XXX 'root': root,
'modules': SecureModuleImporter,
}
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.RESPONSE.setHeader('content-type',
self.getContect.content_type)
except AttributeError:
pass
# Execute the template in a new security context.
self.getContext()._cook()
return self.getContext().pt_render(extra_context=bound_names)
def document_src(self, REQUEST=None, RESPONSE=None):
"""Return expanded document source."""
if RESPONSE is not None:
RESPONSE.setHeader('Content-Type', self.content_type)
return self.read()
=== Added File Zope3/lib/python/Zope/App/OFS/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/01 06:37:13 srichter Exp $
"""
=== Added File Zope3/lib/python/Zope/App/OFS/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.ZPTPage.ZPTPage.IZPTPage."
factory="Zope.App.OFS.ZPTPage.Views.Browser.ZPTPageEval." />
<security:protectClass
name="Zope.App.OFS.ZPTPage.Views.Browser.ZPTPageEval."
permission_id="Zope.View" methods="index" />
<browser:view name="edit"
for="Zope.App.OFS.ZPTPage.ZPTPage.IZPTPage."
factory="Zope.App.OFS.ZPTPage.Views.Browser.ZPTPageEdit." />
<security:protectClass
name="Zope.App.OFS.ZPTPage.Views.Browser.ZPTPageEdit."
permission_id="Zope.View" methods="index, editAction" />
<!-- Registering all the field views for the browser -->
</zopeConfigure>
=== Added File Zope3/lib/python/Zope/App/OFS/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="options/msg | nothing">
Message will go here.
</p>
<form action="editAction" method="post" enctype="multipart/form-data">
<table class="EditTable">
<tbody>
<tr>
<th class="EditAttributeName">Source</th>
<td class="EditAttributeValue">
<textarea name="source" cols="80" rows="10"
tal:content="here/getSource">Source</textarea>
</td>
</tr>
</tbody>
</table>
<input type="submit" name="edit" value="Save Changes">
</form>
</div>
</body>
</html>