[Checkins] SVN: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/ initial checkin

Adam Groszer adamg at fw.hu
Sun Sep 10 09:49:24 EDT 2006


Log message for revision 70096:
  initial checkin

Changed:
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/README.txt
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/__init__.py
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/__init__.py
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/configure.zcml
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/view.pt
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/configure.zcml
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/interfaces.py
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/process.py
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/registry.py
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/todo.txt
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/wfmcpersistent-configure.zcml
  A   z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/xpdl.py

-=-
Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/README.txt
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/README.txt	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/README.txt	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,31 @@
+=============================================
+Workflow-Management Coalition Workflow Engine
+=============================================
+
+This package has exactly the same functionality as the zope.wfmc,
+but all classes are redefined as persistent to be able to store
+the complete workflow process definition in the ZODB.
+
+Differences
+===========
+
+Class names are not changed to make switching to the persistent version easy.
+
+A utility is added to work as a workflow process definition registry.
+
+Requirements
+============
+
+:zope.wfmc: at the moment comes with the Zope 3 release
+
+See: http://svn.zope.org/Zope3/trunk/src/zope/wfmc/
+
+Installation
+============
+
+Drop the `z3c.wfmcpersistent` folder somewhere on the PYTHONPATH.
+Copy the `wfmcpersistent-configure.zcml` to your instace's etc folder.
+
+TODO
+====
+see todo.txt


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/__init__.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/__init__.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/__init__.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1 @@
+#


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/__init__.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/__init__.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/__init__.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1 @@
+#


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/configure.zcml
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/configure.zcml	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/configure.zcml	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    >
+
+  <browser:page
+      name="index.html"
+      for="..interfaces.IProcessDefinitionRegistry"
+      permission="zope.ManageSite"
+      menu="zmi_views" title="View"
+      template="view.pt"
+      >
+  </browser:page>
+  
+  <browser:defaultView
+      name="index.html"
+      for="..interfaces.IProcessDefinitionRegistry"
+      />
+  
+</configure>


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/view.pt
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/view.pt	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/view.pt	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,40 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:tal="http://xml.zope.org/namespaces/tal"
+      xmlns:metal="http://xml.zope.org/namespaces/metal"
+      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+      metal:use-macro="context/@@standard_macros/view">
+<body>
+
+<div metal:fill-slot="body">
+
+  <form action="." method="post" tal:attributes="action request/URL"
+        enctype="multipart/form-data">
+
+    <h3 i18n:translate="">
+      Registered process definitions
+    </h3>
+
+    <table class="listing">
+		<thead>
+		<tr>
+			<th>process ID</th>
+		</tr>
+		</thead>
+		<tbody>
+		<tal:block tal:repeat="data context/getProcessDefinitionIDs">
+		<tr class="even" 
+				tal:define="oddrow repeat/data/odd"
+				tal:attributes="class python:oddrow and 'even' or 'odd'">
+			<td>
+			  <div class="label" tal:content="data">
+			  </div>
+			</td>
+		</tr>
+		</tal:block>
+		</tbody>
+	  </table>
+  </form>
+
+</div>
+</body>
+</html> 
\ No newline at end of file


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/browser/view.pt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/configure.zcml
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/configure.zcml	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/configure.zcml	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,29 @@
+<configure 
+    xmlns="http://namespaces.zope.org/zope">
+
+  <!-- global GlobalWPRegistry -->
+  <class class=".registry.GlobalProcessDefinitionRegistry">
+    <require
+        permission="zope.ManageSite"
+        interface=".interfaces.IProcessDefinitionRegistry"
+        />
+  </class>
+
+  <utility
+      provides=".interfaces.IProcessDefinitionRegistry"
+      component=".registry.globalProcessDefinitionRegistry"
+      />
+
+  <!-- optional local WPRegistry -->
+  <localUtility class=".registry.LocalProcessDefinitionRegistry">
+    <factory
+        id="wfmcp.registry.LocalProcessDefinitionRegistry"
+        />
+    <require
+        permission="zope.ManageSite"
+        interface=".interfaces.IProcessDefinitionRegistry"
+        />
+  </localUtility>
+
+  <include package=".browser" />
+</configure>


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/interfaces.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/interfaces.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/interfaces.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# 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.
+#
+##############################################################################
+"""Workflow-integration interfaces
+
+$Id: interfaces.py 30893 2005-06-22 22:03:13Z srichter $
+"""
+__docformat__ = "reStructuredText"
+
+from zope import interface
+
+class IProcessDefinitionRegistry(interface.Interface):
+	"""Process definition registry."""
+
+	def addProcessDefinition(processDefinition):
+		"""Add a new process definition.
+		the ID will be the processDefinition.id"""
+
+	def getProcessDefinition(id):
+		"""Returns a definition given its ID.
+		
+		Raise a KeyError if no process definition is available.
+		"""
+
+	def getProcessDefinitions():
+		"""Returns all process definitions."""
+
+	def getProcessDefinitionIDs():
+		"""Returns all process definition IDs."""
+		
+	def delProcessDefinition(id):
+		"""Del a process definition given its ID."""
+	
+


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/interfaces.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/process.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/process.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/process.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,88 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# 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.
+#
+##############################################################################
+"""Processes
+
+$Id: process.py 38356 2005-09-07 19:34:16Z srichter $
+"""
+
+from persistent import Persistent
+from persistent.list import PersistentList
+from persistent.dict import PersistentDict
+
+import zope.component
+
+import z3c.wfmcpersistent.interfaces
+import zope.wfmc.process
+
+class TransitionDefinition(zope.wfmc.process.TransitionDefinition, Persistent):
+    
+    name = u''
+
+    def __repr__(self):
+        return "TransitionDefinitionPersistent(from=%r, to=%r)" %(self.from_, self.to)
+
+
+class ProcessDefinition(zope.wfmc.process.ProcessDefinition, Persistent):
+    
+    TransitionDefinitionFactory = TransitionDefinition
+    
+    def __init__(self, id, integration=None):
+        super(ProcessDefinition, self).__init__(id, integration)
+        
+        self.activities = PersistentDict()
+        self.transitions = PersistentList()
+        self.applications = PersistentDict()
+        self.participants = PersistentDict()
+    
+    def __call__(self, context=None):
+        return Process(self, self._start, context)
+
+    def __repr__(self):
+        return "ProcessDefinitionPersistent(%r)" % self.id
+
+class ActivityDefinition(zope.wfmc.process.ActivityDefinition, Persistent):
+
+    def __repr__(self):
+        return "<ActivityDefinitionPersistent %r>" %self.__name__
+
+
+class Process(zope.wfmc.process.Process):
+
+    def definition(self):
+        pdregistry = zope.component.getUtility(
+            z3c.wfmcpersistent.interfaces.IProcessDefinitionRegistry,
+            context=self.context,
+            )
+        return pdregistry.getProcessDefinition(
+            self.process_definition_identifier)
+    
+    definition = property(definition)
+
+    def __repr__(self):
+        return "ProcessPersistent(%r)" % self.process_definition_identifier
+
+class Application(zope.wfmc.process.Application, Persistent):
+
+    def __repr__(self):
+        input = u', '.join([param.__name__ for param in self.parameters
+                           if param.input == True])
+        output = u', '.join([param.__name__ for param in self.parameters
+                           if param.output == True])        
+        return "<ApplicationPersistent %r: (%s) --> (%s)>" %(self.__name__, input, output)
+        
+
+class Participant(zope.wfmc.process.Participant, Persistent):
+
+    def __repr__(self):
+        return "ParticipantPersistent(%r)" %self.__name__


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/process.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/registry.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/registry.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/registry.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,58 @@
+# -*- coding: UTF-8 -*-
+
+from BTrees.OOBTree import OOBTree
+
+from persistent import Persistent
+from zope.app.container.contained import Contained
+
+from zope.interface import implements
+
+from z3c.wfmcpersistent.interfaces import IProcessDefinitionRegistry
+
+
+class ProcessDefinitionRegistry(object):
+	"""ProcessDefinitionRegistry implementations."""
+
+	implements(IProcessDefinitionRegistry)
+
+	def __init__(self):
+		"""ProcessDefinitionRegistry constructor."""
+		super(ProcessDefinitionRegistry, self).__init__()
+
+		self._processdefs = OOBTree()
+
+	def addProcessDefinition(self, processDefinition):
+		"""Add a new process definition.
+		the ID will be the processDefinition.id"""
+		self._processdefs[processDefinition.id]=processDefinition
+
+	def getProcessDefinition(self, id):
+		"""Returns a definition given its id.
+		
+		Raise a KeyError if no process definition is available.
+		"""
+		return self._processdefs[id]
+
+	def getProcessDefinitions(self):
+		"""Returns all process definitions."""
+		return list(self._processdefs.values())
+	
+	def getProcessDefinitionIDs(self):
+		"""Returns all process definition IDs."""
+		return list(self._processdefs.keys())
+
+	def delProcessDefinition(self, id):
+		"""Del a process definition given its ID."""
+		del self._processdefs[id]
+
+
+class GlobalProcessDefinitionRegistry(ProcessDefinitionRegistry):
+	"""Global IWorkflowUtility implementation."""
+
+globalProcessDefinitionRegistry = GlobalProcessDefinitionRegistry()
+
+
+class LocalProcessDefinitionRegistry(ProcessDefinitionRegistry, Contained,
+									 Persistent):
+	"""Local ProcessDefinitionRegistry utility implementation."""
+	


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/registry.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/todo.txt
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/todo.txt	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/todo.txt	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,10 @@
+=======
+ TODOs
+=======
+
+Unittests
+====================
+
+The utility must be registered to get the stuff working,
+that's not an issue with a running Z3 server, but I don't know (yet)
+how to do that in a unittest


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/todo.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/wfmcpersistent-configure.zcml
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/wfmcpersistent-configure.zcml	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/wfmcpersistent-configure.zcml	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1 @@
+<include package="z3c.wfmcpersistent"/>


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/wfmcpersistent-configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/xpdl.py
===================================================================
--- z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/xpdl.py	2006-09-10 13:46:17 UTC (rev 70095)
+++ z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/xpdl.py	2006-09-10 13:49:21 UTC (rev 70096)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""XPDL reader for persistent process definitions
+
+$Id: xpdl.py 38178 2005-08-30 21:50:19Z mj $
+"""
+
+import xml.sax
+import xml.sax.xmlreader
+import xml.sax.handler
+
+import zope.wfmc.xpdl
+
+import z3c.wfmcpersistent.process
+
+class XPDLHandler(zope.wfmc.xpdl.XPDLHandler):
+
+    ProcessDefinitionFactory = z3c.wfmcpersistent.process.ProcessDefinition
+    ParticipantFactory = z3c.wfmcpersistent.process.Participant
+    ApplicationFactory = z3c.wfmcpersistent.process.Application
+    ActivityDefinitionFactory = z3c.wfmcpersistent.process.ActivityDefinition
+    TransitionDefinitionFactory = z3c.wfmcpersistent.process.TransitionDefinition
+    
+def read(file):
+    src = xml.sax.xmlreader.InputSource(getattr(file, 'name', '<string>'))
+    src.setByteStream(file)
+    parser = xml.sax.make_parser()
+    package = zope.wfmc.xpdl.Package()
+    parser.setContentHandler(XPDLHandler(package))
+    parser.setFeature(xml.sax.handler.feature_namespaces, True)
+    parser.parse(src)
+    
+    return package
\ No newline at end of file


Property changes on: z3c.wfmcpersistent/trunk/src/z3c/wfmcpersistent/xpdl.py
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list