[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/SQLScript/Views/Browser - SQLScriptEdit.py:1.4 configure.zcml:1.3 edit.pt:1.2

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


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

Modified Files:
	SQLScriptEdit.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/SQLScript/Views/Browser/SQLScriptEdit.py 1.3 => 1.4 ===
 """
 $Id$
 """
-from Zope.ComponentArchitecture import getService
-from Zope.App.Traversing import getParent
-
-from Zope.Publisher.Browser.BrowserView import BrowserView
-from Zope.App.OFS.Content.SQLScript.ISQLScript import ISQLScript
-
-class SQLScriptEdit(BrowserView):
-    """Edit View for SQL Scripts"""
-    __implements__ = BrowserView.__implements__
-    __used_for__ = ISQLScript
-
-    def edit(self, connection, arguments, sql):
-        if arguments != self.context.getArgumentsString():
-            self.context.setArguments(arguments)
-        if sql != self.context.getSource():
-            self.context.setSource(sql)
-        if connection != self.context.getConnectionName():
-            self.context.setConnectionName(connection)
-        return self.request.response.redirect(self.request['nextURL'])
+from Zope.App.PageTemplate import ViewPageTemplateFile
+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 SQLScriptEdit(FormView):
+    form = ViewPageTemplateFile('edit.pt')
+    custom_widgets = {'connectionName': CustomWidget(Widget.ListWidget,
+                                                     size=1),
+                      'arguments': CustomWidget(Widget.TextAreaWidget,
+                                                height=3, width=40),
+                      'source': CustomWidget(Widget.TextAreaWidget,
+                                             height=10, width=80)}
+    fields_order = ('connectionName', 'arguments', 'source')
 
     def getAllConnections(self):
         parent = getParent(self.context)


=== Zope3/lib/python/Zope/App/OFS/Content/SQLScript/Views/Browser/configure.zcml 1.2 => 1.3 ===
     for=".ISQLScript."
     permission="Zope.View"
     factory=".Views.Browser.SQLScriptEdit.">
-  <browser:page name="editForm.html" template="Views/Browser/edit.pt" />
+
+  <browser:page name="editForm.html" attribute="form" />
   <browser:page name="edit.html" attribute="edit" />
+
 </browser:view>
 
 <browser:menuItems menu="zmi_views" for=".ISQLScript.">


=== Zope3/lib/python/Zope/App/OFS/Content/SQLScript/Views/Browser/edit.pt 1.1 => 1.2 ===
 <html metal:use-macro="views/standard_macros/page">
-<head>
-  <title>Edit SQL Script</title>
-</head>
-<body>
-
+  <body>
   <div metal:fill-slot="body">
-    <form action="." method="post">
+
+    <p>This edit form allows you to make changes to the properties 
+      of this sql script.</p>
+
+    <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">
       <input type="hidden" name="nextURL" value=""
-          tal:attributes="value request/URL">
-    
-      <table>      
-    	<tbody>       	
-    	  <tr>
-    	    <th>Connection:</th>
-    	    <td>
-	      <select size="1" name="connection">
-                 <tal:block repeat="name view/getAllConnections">
-                   <option value="" selected=""
-                     tal:condition="python: name==context.getConnectionName()"
-                     tal:attributes="value name" tal:content="name" />
-                   <option value=""
-                     tal:condition="python: name!=context.getConnectionName()"
-                     tal:attributes="value name" tal:content="name" />
-                 </tal:block>
-	      </select>
-            </td>
-    	  </tr>
-    	  <tr>
-    	    <th>Arguments:</th>
-    	    <td>
-	      <textarea name="arguments" cols="60" rows="5"
-                  tal:content="context/getArgumentsString"></textarea> 
-            </td>
-    	  </tr>
-    	  <tr>
-    	    <th>SQL Template:</th>
-    	    <td>
-	      <textarea name="sql" cols="60" rows="10"
-                  tal:content="context/getSource"></textarea> 
-            </td>
-    	  </tr>
-    	    	
-    	</tbody>     
+          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="edit.html:method" value="Save Changes" />
-    
-    </form> 
+ 
+      <input type="submit" name="save" value="Save Changes" />
+
+    </form>
+
   </div>
+  </body>
 
-</body>
-</html>
\ No newline at end of file
+</html>