[Zope3-checkins] CVS: Zope3/src/zope/app/browser/content - configure.zcml:1.42 sql.py:1.12

Mohan Chandra mchandra at zeomega.com
Tue Dec 16 10:42:30 EST 2003


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

Modified Files:
	configure.zcml sql.py 
Log Message:
Included self.contentName in adding.py
Included addform and addMenuItem directives to browser/content/configure.zcml
Provided a customized add view for SQLScript
Defined a new slot extra_buttons in add.pt
Changed view/renderAddButton to context/renderAddButton





=== Zope3/src/zope/app/browser/content/configure.zcml 1.41 => 1.42 ===
--- Zope3/src/zope/app/browser/content/configure.zcml:1.41	Sun Dec  7 05:04:47 2003
+++ Zope3/src/zope/app/browser/content/configure.zcml	Tue Dec 16 10:41:59 2003
@@ -289,6 +289,28 @@
 
   <!-- SQL Script View Directives -->
 
+  
+  <addform
+      schema="zope.app.interfaces.content.sql.ISQLScript"
+      label="Add a SQL Script"
+      content_factory="zope.app.content.sql.SQLScript"
+      keyword_arguments="connectionName source arguments"
+      name="zope.app.content.sql"
+      permission="zope.ManageContent"
+      template="sqladd.pt"
+      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"
@@ -307,6 +329,7 @@
 
   </pages>
 
+  <!-- XXXX
   <menuItem
       menu="add_content"
       for="zope.app.interfaces.container.IAdding"
@@ -314,7 +337,14 @@
       action="SQLScript"
       description="A content object getting its data from a RDB."
       permission="zope.ManageContent"
-      />
+      /> 
+   -->
+  
+  <addMenuItem
+      title="SQLScript"
+      class="zope.app.content.sql.SQLScript"
+      permission="zope.ManageContent"   
+      view="zope.app.content.sql" /> 
 
 <!-- DTML Page View Directives -->
 


=== Zope3/src/zope/app/browser/content/sql.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/browser/content/sql.py:1.11	Sun Sep 21 13:30:31 2003
+++ Zope3/src/zope/app/browser/content/sql.py	Tue Dec 16 10:41:59 2003
@@ -15,8 +15,14 @@
 
 $Id$
 """
+
+from zope.app.browser.form.add import AddView
+from zope.app.browser.form.submit import Update
 from zope.app.interfaces.content.sql import ISQLScript
 from zope.app.interfaces.rdb import DatabaseException
+from zope.app.interfaces.container import IAdding
+from zope.app.content.sql import SQLScript
+from zope.app import zapi
 
 class SQLScriptTest:
     """Test the SQL inside the SQL Script"""
@@ -50,3 +56,91 @@
 
     def getRenderedSQL(self):
         return self.context.getTemplate()(**self.getArguments())
+
+
+
+class SQLScriptAdd(object):
+    """Provide interface to add SQL Script """
+     
+        
+    def update(self):
+        """ Set the Update variable for Add and Test
+        >>> from zope.publisher.browser import TestRequest
+        
+        >>> rqst = TestRequest()
+        >>> class Base(object):
+        ...     def __init__(self, request):
+        ...         self.request = request
+        ...     def update(self):
+        ...         self.updated = 1
+         
+        >>> class V(SQLScriptAdd, Base):
+        ...     pass
+        
+        >>> dc = V(rqst)
+        >>> res = 0
+        >>> dc.update()
+        >>> dc.updated
+        1
+        >>> 'UPDATE_SUBMIT' in rqst
+        False
+        >>> d = {'add_test':1}
+        >>> rqst1 = TestRequest(form = d)
+        >>> dc1 = V(rqst1)
+        >>> dc1.update()
+        >>> 'UPDATE_SUBMIT' in rqst1
+        True
+        """
+        if 'add_test' in self.request:
+            self.request.form[Update] = ''
+            
+        return super(SQLScriptAdd, self).update()
+        
+              
+    def nextURL(self):
+        """
+        >>> from zope.publisher.browser import TestRequest
+        >>> from zope.app.tests.placelesssetup import setUp, tearDown
+        >>> setUp()
+        >>> rqst = TestRequest()
+        >>> class Base(object):
+        ...     def __init__(self, request):
+        ...         self.request = request
+        ...         self.context = self
+        ...         self.contentName = 'new srcipt'
+        ...     def __getitem__(self, key):
+        ...         return None
+        ...     def nextURL(self):
+        ...         return "www.zeomega.com"
+        
+        >>> class V(SQLScriptAdd, Base):
+        ...     pass
+        >>> 
+        >>> rqst = TestRequest()
+        >>> dc = V(rqst)
+        >>> dc.nextURL()
+        'www.zeomega.com'
+        >>> d = {'add_test':1}
+        >>> rqst1 = TestRequest(form = d)
+        >>> dc1 = V(rqst1)
+        >>> dc1.nextURL()
+        'http://127.0.0.1/test.html'
+
+        """
+
+
+        if 'add_test' in self.request:
+            name = self.context.contentName
+            container = self.context.context
+            obj = container[name]
+            url = zapi.getView(obj, 'absolute_url', self.request)()
+            url = '%s/test.html' % url
+            return url
+        else:
+            return super(SQLScriptAdd, self).nextURL()
+       
+        
+        
+
+    
+    




More information about the Zope3-Checkins mailing list