[Zope3-checkins] CVS: Zope3/src/zope/app/browser/content - sqledit.pt:1.1 configure.zcml:1.45 sql.py:1.13

Madhavi Chaganti madhavi79 at yahoo.com
Thu Dec 18 10:25:55 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/content
In directory cvs.zope.org:/tmp/cvs-serv26403/src/zope/app/browser/content

Modified Files:
	configure.zcml sql.py 
Added Files:
	sqledit.pt 
Log Message:
Customized edit view for SQLScript




=== Added File Zope3/src/zope/app/browser/content/sqledit.pt ===
<html metal:use-macro="context/@@standard_macros/page">

  <head>
    <title>SQL Script</title>
  </head>
  <body>
 
    <div metal:fill-slot="body">
        
       <div metal:use-macro="view/generated_form/macros/body">
            <input type="submit" value="Change And Test" 
                  metal:fill-slot="extra_buttons" name="change_test" />
       </div>
   </div>
  </body>

</html>


=== Zope3/src/zope/app/browser/content/configure.zcml 1.44 => 1.45 ===
--- Zope3/src/zope/app/browser/content/configure.zcml:1.44	Thu Dec 18 05:42:17 2003
+++ Zope3/src/zope/app/browser/content/configure.zcml	Thu Dec 18 10:25:23 2003
@@ -322,22 +322,15 @@
       class=".sql.SQLScriptAdd"
       /> 
       
-   
-  <!-- <view name="zope.app.content.sql"
-	      for="zope.app.interfaces.container.IAdding"
-              class="zope.app.browser.content.sql.SQLScriptAdd"
-              permission="zope.ManageContent">
-
-    <page name="add.html" template="sqladd.pt" />
-    <page name="action.html" attribute="action" />
-  </view> -->
-
   <editform
       schema="zope.app.interfaces.content.sql.ISQLScript"
       name="edit.html"
       menu="zmi_views"
       label="Edit an SQL script"
-      permission="zope.ManageContent" />
+      permission="zope.ManageContent"
+      template="sqledit.pt"
+      class=".sql.SQLScriptEdit" 
+      />
 
   <pages
       for="zope.app.interfaces.content.sql.ISQLScript"


=== Zope3/src/zope/app/browser/content/sql.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/browser/content/sql.py:1.12	Tue Dec 16 10:41:59 2003
+++ Zope3/src/zope/app/browser/content/sql.py	Thu Dec 18 10:25:23 2003
@@ -142,5 +142,85 @@
         
         
 
+# *********** Edit ************
+
+class SQLScriptEdit(object):
+    """Provide interface to Edit and Test  SQL Script """
+     
+
+        
+    def update(self):
+
+        """ Set the Update variable for Change and Test
+        >>> from zope.publisher.browser import TestRequest
+        
+        >>> rqst = TestRequest()
+        >>> class Base(object):
+        ...     def __init__(self, request):
+        ...         self.request = request
+        ...         self.errors  = ('no errors')
+        ...     def update(self):
+        ...         self.updated = 1
+        ...         return "update returned"
+        
+         
+        >>> class V(SQLScriptEdit, Base):
+        ...     pass
+        
+        >>> dc = V(rqst)
+        >>> res = 0
+        >>> dc.update()
+        'update returned'
+        >>> dc.updated
+        1
+        >>> 'UPDATE_SUBMIT' in rqst
+        False
+        >>>
+        
+
+        >>> d = {'change_test':1}
+        >>> rqst1 = TestRequest(form = d)
+        >>> dc1 = V(rqst1)
+        >>> dc1.errors = ()
+        >>> dc1.update()
+        'update returned'
+        >>> 'UPDATE_SUBMIT' in rqst1
+        True
+        >>> dc1.updated
+        1
+        >>> rqst1.response.getHeader('location')
+        'test.html'
+        >>> rqst1.response.getStatus()
+        302
+           
+        >>> d = {'change_test':1}
+        >>> rqst2 = TestRequest(form = d)
+        >>> dc2 = V(rqst2)
+        >>> dc2.errors = ('errorname',1234)
+        >>> dc2.update()
+        'update returned'
+        >>> 'UPDATE_SUBMIT' in rqst2
+        True
+        >>> rqst2.response.getHeader('location')
+        
+        >>> rqst2.response.getStatus()
+        599
+
+        """
+        
+       
+        if 'change_test' in self.request:
+            self.request.form[Update] = ''
+            super(SQLScriptEdit, self).update()
+            if not self.errors:
+                url = 'test.html'
+                self.request.response.redirect(url)
+        return super(SQLScriptEdit, self).update()
+        
+              
+
+       
+        
+
     
     




More information about the Zope3-Checkins mailing list