[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser - ImageEdit.py:1.3 configure.zcml:1.9 edit.pt:1.3
Stephan Richter
srichter@cbu.edu
Fri, 19 Jul 2002 09:13:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv24805/lib/python/Zope/App/OFS/Content/Image/Views/Browser
Modified Files:
ImageEdit.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/Image/Views/Browser/ImageEdit.py 1.2 => 1.3 ===
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
-Define view component for image editing.
+"""Define view component for image editing.
-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 ImageEdit(Form):
-
- __implements__ = Form.__implements__
-
- name = 'editForm'
- title = 'Edit Form'
- description = ('This edit form allows you to make changes to the ' +
- 'properties of this image.')
-
- _fieldViewNames = ['ContentTypeFieldView', 'DataFieldView']
- template = ViewPageTemplateFile('edit.pt')
-
- def getImageSize(self):
- size=self.context.getImageSize()
- return "%d x %d" % (size[0], size[1])
+class ImageEdit(FormView):
+ form = ViewPageTemplateFile('edit.pt')
+ custom_widgets = {'data': Widget.FileWidget}
+ fields_order = ('contentType', 'data')
=== Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/configure.zcml 1.8 => 1.9 ===
xmlns:browser="http://namespaces.zope.org/browser"
package="Zope.App.OFS.Content.Image">
+<browser:defaultView for=".Image.IImage." name="data" />
+
<!-- Image View Directives -->
<browser:view
@@ -12,32 +14,16 @@
allowed_attributes="__call__ tag"
factory=".Views.Browser.ImageData." />
-<browser:defaultView for=".Image.IImage." name="data" />
-
<browser:view
for=".Image.IImage."
permission="Zope.ManageContent"
factory=".Views.Browser.ImageEdit.">
- <browser:page name="editForm.html" attribute="index" />
+ <browser:page name="editForm.html" attribute="form" />
<browser:page name="edit.html" attribute="action" />
</browser:view>
-<!-- Formulator directives -->
-
-<browser:view
- name="DataFieldView"
- for=".Image.IImage."
- factory=".ImageFields.DataField.
- Zope.App.Formulator.Widgets.Browser.FileWidget." />
-
-<browser:view
- name="ContentTypeFieldView"
- for=".Image.IImage."
- factory=".ImageFields.ContentTypeField.
- Zope.App.Formulator.Widgets.Browser.TextWidget." />
-
<!-- I18n Image View Directives -->
<browser:view
@@ -48,11 +34,11 @@
factory=".Views.Browser.I18nImageData." />
<browser:defaultView
- for="Zope.App.OFS.Content.Image.I18nImage.II18nImage"
+ for=".I18nImage.II18nImage"
name="data" />
<browser:view
- for="Zope.App.OFS.Content.Image.I18nImage.II18nImage"
+ for=".I18nImage.II18nImage"
permission="Zope.ManageContent"
factory=".Views.Browser.I18nImageEdit.">
=== Zope3/lib/python/Zope/App/OFS/Content/Image/Views/Browser/edit.pt 1.2 => 1.3 ===
<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>
-
- <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 image.</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" enctype="multipart/form-data">
-
- <table class="EditTable">
- <tbody>
-
- <tr>
- <th class="EditAttributeName">Size</th>
- <td class="EditAttributeValue"
- tal:content="view/getImageSize">
- </td>
- </tr>
-
- <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:define="size context/getImageSize"
+ tal:content="python: str(size[0]) + ' x ' + str(size[0])">
+ 103 x 45</span> pixels
+ </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>