[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser - FileEdit.py:1.3 FileView.py:1.4 configure.zcml:1.12 edit.pt:1.4
Stephan Richter
srichter@cbu.edu
Fri, 19 Jul 2002 09:13:02 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv24805/lib/python/Zope/App/OFS/Content/File/Views/Browser
Modified Files:
FileEdit.py FileView.py configure.zcml edit.pt
Log Message:
Okay, I finished the Forms work. Schema and Forms completely replace the
old Formulator code now. I have switched all the Content objects to using
Schema + Forms; especially the SQL Script has an interesting demo on how
to write your custom fields.
However, I am not satisfied with all my design decisions. There is still
a lot of work to be done in Converters and Widgets. Please contact Martijn
and/or me if you would like to help.
=== Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/FileEdit.py 1.2 => 1.3 ===
#
##############################################################################
"""
-Revision information:
$Id$
"""
-
-from Zope.App.Formulator.Form import Form
from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.App.Forms.Views.Browser import Widget
+from Zope.App.Forms.Views.Browser.FormView import FormView
-
-
-class FileEdit(Form):
-
- __implements__ = Form.__implements__
-
- name = 'editForm'
- title = 'Edit Form'
- description = ('This edit form allows you to make changes to the ' +
- 'properties of this file.')
-
- _fieldViewNames = ['ContentTypeFieldView', 'DataFieldView']
- template = ViewPageTemplateFile('edit.pt')
-
+class FileEdit(FormView):
+ form = ViewPageTemplateFile('edit.pt')
+ custom_widgets = {'data': Widget.FileWidget}
+ fields_order = ('contentType', 'data')
=== Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/FileView.py 1.3 => 1.4 ===
class FileView(BrowserView):
- def __call__(self):
+ def show(self):
"""Call the File"""
request = self.request
if request is not None:
=== Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/configure.zcml 1.11 => 1.12 ===
<!-- File View Directives -->
-<browser:defaultView for=".IFile." name="view" />
+<browser:defaultView for=".IFile." name="show.html" />
<browser:view
- name="view"
for=".IFile."
permission="Zope.View"
- factory=".Views.Browser.FileView." />
+ factory=".Views.Browser.FileView.">
+ <browser:page name="show.html" attribute="show" />
+
+</browser:view>
<browser:view
for=".IFile."
permission="Zope.View"
factory=".Views.Browser.FileEdit.">
- <browser:page name="editForm.html" attribute="index" />
+ <browser:page name="editForm.html" attribute="form" />
<browser:page name="edit.html" attribute="action" />
</browser:view>
+<!-- I18n File View Directives -->
+
<browser:view
name="view"
for=".I18nFile.II18nFile."
@@ -30,7 +34,7 @@
factory=".Views.Browser.I18nFileView." />
<browser:view
- for="Zope.App.OFS.Content.File.I18nFile.II18nFile."
+ for=".I18nFile.II18nFile."
permission="Zope.View"
factory=".Views.Browser.I18nFileEdit.">
@@ -39,26 +43,13 @@
</browser:view>
-
-<!-- Registering all the field views for the browser -->
-
-<browser:view
- name="DataFieldView"
- for=".IFile."
- factory=".FileFields.DataField.
- Zope.App.Formulator.Widgets.Browser.TextAreaWidget." />
-
-<browser:view
- name="ContentTypeFieldView"
- for=".IFile."
- factory=".FileFields.ContentTypeField.
- Zope.App.Formulator.Widgets.Browser.TextWidget." />
+<!-- File Menu Directives -->
<browser:menuItems menu="zmi_views" for=".IFile.">
- <browser:menuItem title="View" action="."/>
- <browser:menuItem title="Edit" action="editForm.html"/>
- <!-- <browser:menuItem title="Role Permissions"
- action="AllRolePermissions.html"/> -->
+ <browser:menuItem title="View" action="show.html" />
+ <browser:menuItem title="Edit" action="editForm.html" />
+ <browser:menuItem title="Role Permissions"
+ action="AllRolePermissions.html" />
</browser:menuItems>
<browser:menuItem menu="add_content"
=== Zope3/lib/python/Zope/App/OFS/Content/File/Views/Browser/edit.pt 1.3 => 1.4 ===
<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="context/msg"
- tal:condition="python: hasattr(context, 'msg')">
- Message will go here.
- </p>
-
- <p tal:content="view/description">
- Description of the Form.
- </p>
+ <div metal:fill-slot="body">
+ <p>This edit form allows you to make changes to the properties
+ of this file.</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 tal:condition="python: options.has_key('errors') and
+ options['errors']">
+ <span style="font-weight: bold">Errors:</span>
+ <div tal:repeat="error options/errors | nothing">
+ <span tal:replace="python: error[0].title" />:
+ <span tal:replace="python: error[1].error_name" />
</div>
+ </div>
+ <br />
- <form action="edit.html" method="post">
-
- <table class="EditTable">
- <tbody>
-
- <tr tal:repeat="fieldView python:view.getFieldViews(request)">
- <th class="EditAttributeName"
- tal:content="python: fieldView.context.getValue('title')">Title</th>
- <td class="EditAttributeValue"
- tal:content="structure fieldView/render"><input />
- </td>
- </tr>
-
- </tbody>
+ <form action="./edit.html" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="nextURL" value=""
+ tal:attributes="value request/URL" />
+
+ <table class="EditTable">
+ <tr>
+ <th class="EditAttributeName">Size</th>
+ <td class="EditAttributeValue">
+ <span tal:content="context/getSize">1034</span> bytes
+ </td>
+ </tr>
+ <tal:block repeat="field view/getFields">
+ <tr>
+ <th class="EditAttributeName"
+ tal:content="field/title">Title</th>
+ <td class="EditAttributeValue"
+ tal:content="structure python: view.renderField(field)">
+ <input size="20" />
+ </td>
+ </tr>
+ </tal:block>
</table>
+
+ <input type="submit" name="save" value="Save Changes" />
- <input type="submit" name="edit" value="Save Changes">
-
- </form>
+ </form>
- </div>
+ </div>
</body>
-</html>
-
+</html>