Commit 31df31cb authored by Yusei Tahara's avatar Yusei Tahara

Add a patch of DCWorkflowGraph.

This is needed, because graph was not drawn.
parent 8ed6f61e
......@@ -28,6 +28,7 @@ from Products.ERP5Type.patches import PropertyManager
from Products.ERP5Type.patches import TM
from Products.ERP5Type.patches import DA
from Products.ERP5Type.patches import DCWorkflow
from Products.ERP5Type.patches import DCWorkflowGraph
from Products.ERP5Type.patches import Worklists
from Products.ERP5Type.patches import BTreeFolder2
from Products.ERP5Type.patches import WorkflowTool
......
#########################################################################
# This code is taken from Products.DCWorkflowGraph-0.4-py2.6.egg
# http://pypi.python.org/pypi/Products.DCWorkflowGraph
# Author: panjunyong (panjy at zopen.cn, from ZOpen) <panjy at zopen cn>
# License: ZPL
# The license term should be this one: http://www.zope.org/Resources/ZPL
#########################################################################
try:
from Products.DCWorkflowGraph import DCWorkflowGraph
from Products.DCWorkflowGraph.DCWorkflowGraph import (
getPOT, mktemp, os, bin_search, DOT_EXE)
except ImportError:
DCWorkflowGraph = None
if DCWorkflowGraph is not None:
def getGraph(self, wf_id="", format="gif", REQUEST=None):
"""show a workflow as a graph, copy from:
"OpenFlowEditor":http://www.openflow.it/wwwopenflow/Download/OpenFlowEditor_0_4.tgz
"""
pot = getPOT(self, wf_id, REQUEST)
encoding = 'utf-8' #### PATCHED
pot = pot.encode(encoding)
infile = mktemp('.dot')
f = open(infile, 'w')
f.write(pot)
f.close()
if REQUEST is None:
REQUEST = self.REQUEST
response = REQUEST.RESPONSE
if format != 'dot':
outfile = mktemp('.%s' % format)
os.system('%s -T%s -o %s %s' % (bin_search(DOT_EXE), format, outfile, infile))
out = open(outfile, 'rb')
result = out.read()
out.close()
os.remove(outfile)
response.setHeader('Content-Type', 'image/%s' % format)
else:
result = open(infile, 'r').read()
filename = wf_id or self.getId()
response.setHeader('Content-Type', 'text/x-graphviz')
response.setHeader('Content-Disposition',
'attachment; filename=%s.dot' % filename)
os.remove(infile)
return result
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
DCWorkflowDefinition.getGraph = getGraph
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment