[Zope3-checkins] CVS: Packages3/workflow/browser/stateful - configure.zcml:1.11 definition.py:1.5 instance.py:1.3 instance_manage.pt:1.2

Ulrich Eck ueck@net-labs.de
Thu, 10 Apr 2003 14:40:29 -0400


Update of /cvs-repository/Packages3/workflow/browser/stateful
In directory cvs.zope.org:/tmp/cvs-serv6632/stateful

Modified Files:
	configure.zcml definition.py instance.py instance_manage.pt 
Log Message:
minor cleanup in view-classes and bugfixes
added a temporary fix for addform that it is not displayed if there
are no fields defined (could be useful in general)


=== Packages3/workflow/browser/stateful/configure.zcml 1.10 => 1.11 ===
--- Packages3/workflow/browser/stateful/configure.zcml:1.10	Mon Apr  7 13:33:49 2003
+++ Packages3/workflow/browser/stateful/configure.zcml	Thu Apr 10 14:40:28 2003
@@ -65,6 +65,7 @@
 
 
 <!-- State -->
+<!-- nothing to edit yet
 <browser:editform
   schema="zope.app.interfaces.workflow.stateful.IState"
   name="edit.html"
@@ -72,11 +73,13 @@
   label="Edit a State"
   permission="zope.workflow.ManageProcessDefinitions"
   />
+-->
 
 <browser:addform
   name="AddState"
   menu="add_stateful_states" title="Stateful State"
   schema="zope.app.interfaces.workflow.stateful.IState"
+  class=".definition.StateAddFormHelper"
   permission="zope.workflow.ManageProcessDefinitions"
   content_factory="zope.app.workflow.stateful.definition.State"
   arguments=""
@@ -179,6 +182,9 @@
   <browser:page name="published_content.html" attribute="published_content" />
 </browser:pages>
 
+
+<!-- uhm .. this seems to be to generic in its definition
+     and not really nice as well .. -->
 <adapter
     factory=".filteradapter.FilterAdapter"
     provides=".interfaces.IContentFilterAdapter"


=== Packages3/workflow/browser/stateful/definition.py 1.4 => 1.5 ===
--- Packages3/workflow/browser/stateful/definition.py:1.4	Wed Mar 26 12:43:37 2003
+++ Packages3/workflow/browser/stateful/definition.py	Thu Apr 10 14:40:28 2003
@@ -17,7 +17,6 @@
 """
 __metaclass__ = type
 
-from zope.proxy.context import getWrapperContainer
 from zope.proxy.introspection import removeAllProxies
 from zope.component import getServiceManager
 from zope.publisher.browser import BrowserView
@@ -27,7 +26,7 @@
 
 from zope.app.workflow.stateful.definition import State, Transition
 
-
+from zope.app.browser.form.submit import Update
 
 
 class StatesContainerAdding(Adding):
@@ -42,7 +41,18 @@
     menu_id = "add_stateful_transitions"
 
     def getProcessDefinition(self):
-        return getWrapperContainer(self).getProcessDefinition()
+        return self.context.getProcessDefinition()
+
+
+# XXX Temporary ...
+class StateAddFormHelper:
+
+    # XXX Hack to prevent from displaying an empty addform
+    def __call__(self, template_usage=u'', *args, **kw):
+        if not len(self.fieldNames):
+            self.request.form[Update] = 'submitted'
+            return self.update()
+        return super(StateAddFormHelper, self).__call__(template_usage, *args, **kw)
 
 
 


=== Packages3/workflow/browser/stateful/instance.py 1.2 => 1.3 ===
--- Packages3/workflow/browser/stateful/instance.py:1.2	Wed Mar 26 14:24:05 2003
+++ Packages3/workflow/browser/stateful/instance.py	Thu Apr 10 14:40:28 2003
@@ -37,7 +37,7 @@
     def _extractContentInfo(self, item):
         id, processInstance = item
         info = {}
-        info['id']  =id
+        info['id']  = id
         info['name']=self._getTitle(self._getProcessDefinition(processInstance))
         return info
 
@@ -45,9 +45,6 @@
         return map(self._extractContentInfo,
                    getAdapter(self.context, IProcessInstanceContainer).items())
 
-    def _getTitle(self, obj):
-        return getAdapter(obj, IZopeDublinCore).Title() or getWrapperData(obj)['name']
- 
     contents = ViewPageTemplateFile('instance_manage.pt')
     contentsMacros = contents
 
@@ -58,26 +55,6 @@
         
         return self._getTitle(self._getProcessDefinition(pi))
 
-    def _getSelWorkflow(self):
-        reqWorkflow = self.request.get('workflow', u'')
-        pi_container = getAdapter(self.context, IProcessInstanceContainer)
-        if reqWorkflow is u'':
-            available_instances = pi_container.keys()
-            if len(available_instances) > 0:
-                pi = pi_container[available_instances[0]]
-            else:
-                pi = None
-        else:
-            pi = pi_container[reqWorkflow]
-        
-        return pi
-
-
-    def _getProcessDefinition(self, processInstance):
-        ws = getService(self.context, Workflows)
-        return ws.getProcessDefinition(processInstance.processDefinitionName)
-
-
     def getTransitions(self):
         info = {}
         pi   = self._getSelWorkflow()
@@ -90,7 +67,7 @@
 
         current_state = clean_pd.getState(pi.status)
         adapter = getAdapter(current_state, IZopeDublinCore)
-        info['status'] = adapter.Title() or pi.status
+        info['status'] = adapter.title or pi.status
 
         transition_names = pi.getOutgoingTransitions()
         trans_info = []
@@ -98,7 +75,7 @@
             transition = clean_pd.getTransition(name)
             adapter = getAdapter(transition, IZopeDublinCore)
             trans_info.append({'name':name,
-                               'title': adapter.Title() or name})
+                               'title': adapter.title or name})
         info['transitions'] = trans_info
         return info
 
@@ -111,3 +88,29 @@
         self.request.response.redirect('@@workflows.html?workflow=%s' % pi.processDefinitionName)
         if pi and trans:
             pi.fireTransition(trans)
+
+
+    def _getTitle(self, obj):
+        return getAdapter(obj, IZopeDublinCore).title or getWrapperData(obj)['name']
+
+ 
+    def _getSelWorkflow(self):
+        reqWorkflow = self.request.get('workflow', u'')
+        pi_container = getAdapter(self.context, IProcessInstanceContainer)
+        if reqWorkflow is u'':
+            available_instances = pi_container.keys()
+            if len(available_instances) > 0:
+                pi = pi_container[available_instances[0]]
+            else:
+                pi = None
+        else:
+            pi = pi_container[reqWorkflow]
+        
+        return pi
+
+
+    def _getProcessDefinition(self, processInstance):
+        ws = getService(self.context, Workflows)
+        return ws.getProcessDefinition(processInstance.processDefinitionName)
+
+


=== Packages3/workflow/browser/stateful/instance_manage.pt 1.1 => 1.2 ===
--- Packages3/workflow/browser/stateful/instance_manage.pt:1.1	Wed Mar 26 14:41:02 2003
+++ Packages3/workflow/browser/stateful/instance_manage.pt	Thu Apr 10 14:40:28 2003
@@ -30,9 +30,10 @@
         </div>
         <br/>
         <div metal:define-macro="contents_transitions"
-             tal:define="info view/getTransitions">
+             tal:define="info view/getTransitions"
+             tal:condition="info">
             Current Status: <div tal:replace="info/status"/>
-          <br/>
+            <br/>
             Possible State Changes:
             <form action="@@fireTransition.html" method="get">
             <input type="hidden" name="workflow" tal:attributes="value request/workflow | nothing">