[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/File - FileEdit.py:1.1.2.2 edit.pt:1.1.2.2

Stephan Richter srichter@cbu.edu
Fri, 25 Jan 2002 09:14:37 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/File
In directory cvs.zope.org:/tmp/cvs-serv22869/lib/python/Zope/App/OFS/File

Modified Files:
      Tag: Zope-3x-branch
	FileEdit.py edit.pt 
Log Message:
- Okay, that should be everything you need to update in order to see
  Formulator in action.



=== Zope3/lib/python/Zope/App/OFS/File/FileEdit.py 1.1.2.1 => 1.1.2.2 ===
+#
+# Copyright (c) 2001 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.
+# Version 2.0 (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.
-
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+# 
+##############################################################################
 """
     Define view component for naive file editing.
 """
 
-import os
-
-from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
+from Zope.App.Formulator.Form import Form
 from Zope.PageTemplate.PageTemplateFile import PageTemplateFile
 
 
-class FileEdit( AttributePublisher ):
-
-    __implements__ = AttributePublisher.__implements__
-    
-    def __init__( self, file ):
-        self._file = file
-
-
-    def edit(self, data, contentType, REQUEST=None):
-
-        file = self.getContext()
-        file.edit(data, contentType)
+class FileEdit(Form):
 
-        if REQUEST is not None:
-            return self.index(REQUEST, msg='File Edited.')
+    __implements__ = Form.__implements__
 
+    name = 'editForm'     
+    title = 'Edit Form'
+    description = ('This edit form allows you to make changes to the ' +
+                   'properties of this file.')
 
-    def getContext( self ):
-        return self._file
+    _fieldViewNames = ['ContentTypeFieldView', 'DataFieldView']
+    template = PageTemplateFile('edit.pt')
 
-    index = PageTemplateFile('edit.pt')


=== Zope3/lib/python/Zope/App/OFS/File/edit.pt 1.1.2.1 => 1.1.2.2 ===
       </p>
 
-      <form action="edit" method="post">
+      <p tal:content="container/description">
+        Description of the Form.
+      </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>
+
+      <form action="action" method="post">
 
         <table class="EditTable">      
 	  <tbody>   
   
-	    <tr>
-	      <th class="EditAttributeName">Content-Type</th>
-	      <td class="EditAttributeValue">
-        	<input type="text" name="contentType"
-        	  tal:attributes="value here/getContentType" />
+	    <tr tal:repeat="fieldView python:container.getFieldViews(request)">
+	      <th class="EditAttributeName"
+                  tal:content="python: fieldView.getContext().getValue('title')">Title</th>
+	      <td class="EditAttributeValue"
+	          tal:content="structure fieldView/render"><input />
               </td>
 	    </tr>
-  
-	    <tr>
-	      <th class="EditAttributeName">Data</th>
-	      <td class="EditAttributeValue">
-        	<textarea name="data"
-        	  tal:content="here/getData">Data</textarea>
-              </td>
-	    </tr>      
   
 	  </tbody>     
       </table>