[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser - ZPTPageEdit.py:1.3 configure.zcml:1.8 edit.pt:1.3

Stephan Richter srichter@cbu.edu
Fri, 19 Jul 2002 09:13:04 -0400


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

Modified Files:
	ZPTPageEdit.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/ZPTPage/Views/Browser/ZPTPageEdit.py 1.2 => 1.3 ===
 # 
 ##############################################################################
 """
-
 $Id$
 """
-
-from Zope.App.Formulator.Form import Form
 from Zope.App.PageTemplate import ViewPageTemplateFile
-
-
-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 = ViewPageTemplateFile('edit.pt')
+from Zope.App.Forms.Views.Browser import Widget
+from Zope.App.Forms.Widget import CustomWidget
+from Zope.App.Forms.Views.Browser.FormView import FormView
+
+class ZPTPageEdit(FormView):
+    form = ViewPageTemplateFile('edit.pt')
+    custom_widgets = {'source': CustomWidget(Widget.TextAreaWidget,
+                                             cols=80, rows=15)}
+    fields_order = ('source',)


=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/Views/Browser/configure.zcml 1.7 => 1.8 ===
     for=".ZPTPage.IZPTPage."
     factory=".Views.Browser.ZPTPageEdit." >
 
-  <browser:page name="editForm.html" attribute="index" />
+  <browser:page name="editForm.html" attribute="form" />
   <browser:page name="edit.html" attribute="action" />
 
 </browser:view>
 
-<!-- Registering all the field views for the browser -->
-
-<browser:view
-    name="SourceFieldView"
-    for=".ZPTPage.IZPTPage."
-    factory=".ZPTPageFields.SourceField. 
-             Zope.App.Formulator.Widgets.Browser.TextAreaWidget." />
-
 <!-- tabs for ZPT Page -->
 
 <browser:menuItems menu="zmi_views" for=".ZPTPage.IZPTPage.">
   <browser:menuItem title="Edit" action="editForm.html"/>
   <browser:menuItem title="View" action="."/>
-  <!-- XXX This isn't working
-  <browser:menuItem title="Role Permissions"
-           action="AllRolePermissions.html"/>
-  -->
+  <browser:menuItem title="Role Permissions" action="AllRolePermissions.html"/>
 </browser:menuItems>
 
 <browser:icon name="zmi_icon" for=".ZPTPage.IZPTPage." file="zpt.gif" />


=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/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="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 page template.</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">
+        <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>