backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 07 Jun 2010 18:16:16 +0200
changeset 5685 17883ced01f8
parent 5680 3a46fd84acc4 (current diff)
parent 5684 015755f67e46 (diff)
child 5686 bbb89ba88b69
backport stable
hooks/workflow.py
web/request.py
web/views/workflow.py
--- a/hooks/workflow.py	Mon Jun 07 13:31:46 2010 +0200
+++ b/hooks/workflow.py	Mon Jun 07 18:16:16 2010 +0200
@@ -148,7 +148,7 @@
 
 class WorkflowHook(hook.Hook):
     __abstract__ = True
-    category = 'worfklow'
+    category = 'workflow'
 
 
 class SetInitialStateHook(WorkflowHook):
--- a/web/request.py	Mon Jun 07 13:31:46 2010 +0200
+++ b/web/request.py	Mon Jun 07 18:16:16 2010 +0200
@@ -735,7 +735,7 @@
     # page data management ####################################################
 
     def get_page_data(self, key, default=None):
-        """return value associated to `key` in curernt page data"""
+        """return value associated to `key` in current page data"""
         page_data = self.session.data.get(self.pageid)
         if page_data is None:
             return default
--- a/web/views/workflow.py	Mon Jun 07 13:31:46 2010 +0200
+++ b/web/views/workflow.py	Mon Jun 07 18:16:16 2010 +0200
@@ -19,7 +19,6 @@
 
 * IWorkflowable views and forms
 * workflow entities views (State, Transition, TrInfo)
-
 """
 __docformat__ = "restructuredtext en"
 _ = unicode
@@ -34,6 +33,7 @@
 from cubicweb.selectors import (implements, has_related_entities, one_line_rset,
                                 relation_possible, match_form_params,
                                 implements, score_entity, adaptable)
+from cubicweb.utils import make_uid
 from cubicweb.view import EntityView
 from cubicweb.schema import display_name
 from cubicweb.web import uicfg, stdmsgs, action, component, form, action
@@ -439,8 +439,10 @@
         fd, tmpfile = tempfile.mkstemp('.png')
         os.close(fd)
         generator.generate(visitor, prophdlr, tmpfile, mapfile)
+        filekeyid = make_uid()
+        self._cw.session.data[filekeyid] = tmpfile
         self.w(u'<img src="%s" alt="%s" usemap="#%s" />' % (
-            xml_escape(entity.absolute_url(vid='wfimage', tmpfile=tmpfile)),
+            xml_escape(entity.absolute_url(vid='tmppng', tmpfile=filekeyid)),
             xml_escape(self._cw._('graphical workflow for %s') % entity.name),
             wfname))
         stream = open(mapfile, 'r').read()
@@ -448,12 +450,14 @@
         self.w(stream)
         os.unlink(mapfile)
 
-class WorkflowImageView(TmpFileViewMixin, view.EntityView):
-    __regid__ = 'wfimage'
-    __select__ = implements('Workflow')
+
+class TmpPngView(TmpFileViewMixin, view.EntityView):
+    __regid__ = 'tmppng'
+    __select__ = match_form_params('tmpfile')
     content_type = 'image/png'
+    binary = True
 
     def cell_call(self, row=0, col=0):
-        tmpfile = self._cw.form.get('tmpfile', None)
+        tmpfile = self._cw.session.data[self._cw.form['tmpfile']]
         self.w(open(tmpfile, 'rb').read())
         os.unlink(tmpfile)