[Zope3-checkins] CVS: Products3/NewsSite - sitesetup.py:1.3

Ulrich Eck ueck@net-labs.de
Thu, 27 Mar 2003 10:32:14 -0500


Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv29829

Modified Files:
	sitesetup.py 
Log Message:
site-setup now create ProcessDefinition and registers it under name "default"
and workflow.xml is loaded into that definition.

site-setup basically is now complete


=== Products3/NewsSite/sitesetup.py 1.2 => 1.3 ===
--- Products3/NewsSite/sitesetup.py:1.2	Thu Mar 27 09:01:59 2003
+++ Products3/NewsSite/sitesetup.py	Thu Mar 27 10:32:14 2003
@@ -17,6 +17,7 @@
 """
 __metaclass__ = type
 
+import os, sys
 
 from zope.app.traversing import traverse, getPath
 from zope.app.services.service import ServiceManager
@@ -25,12 +26,35 @@
 from zope.app.services.servicenames \
      import Workflows, Authentication
 
+from zope.component import getUtility
+
 from zope.app.services.auth import AuthenticationService
 from zope.app.workflow.service import WorkflowService
 
 from zope.app.workflow.stateful.contentworkflow \
      import ContentWorkflowsUtility
 
+from zope.app.workflow.service import ProcessDefinitionConfiguration
+from zope.app.workflow.stateful.definition \
+     import StatefulProcessDefinition
+
+
+from zope.app.interfaces.workflow import IProcessDefinitionImportExport
+
+
+
+def load_file(filename, _prefix=None, mode='r'):
+    if isinstance(_prefix, str):
+        path = _prefix
+    else:
+        if _prefix is None:
+            _prefix = sys._getframe(2).f_globals
+        path = os.path.dirname(_prefix["__file__"])
+    filename = os.path.join(path, filename)
+    return open(filename, mode)
+
+
+
 def setupSite(site, data):
     print "setup site"
     
@@ -66,6 +90,15 @@
     workflowsutility.subscribe()
 
     # Create Default Processdefinition
+    pd_name = 'PublishReviewWorkflow-1'
+    default.setObject(pd_name, StatefulProcessDefinition())
+    pd = traverse(default, pd_name)
+    pd_path = "%s/%s" % (getPath(default), pd_name)
+    configuration = ProcessDefinitionConfiguration('default', pd_path)
+    cm.setObject('', configuration)
+    traverse(cm, '3').status = Active
 
+    # Import Default ProcessReview Workflow
     
-    
+    import_util = getUtility(default, IProcessDefinitionImportExport)
+    import_util.importProcessDefinition(pd, load_file('workflow.xml', mode='r'))