22 """ |
22 """ |
23 |
23 |
24 |
24 |
25 from cubicweb import _ |
25 from cubicweb import _ |
26 |
26 |
27 import os |
27 from six import text_type |
28 |
|
29 from six import add_metaclass, text_type |
|
30 |
28 |
31 from logilab.mtconverter import xml_escape |
29 from logilab.mtconverter import xml_escape |
32 from logilab.common.deprecation import class_deprecated |
|
33 |
30 |
34 from cubicweb import Unauthorized |
31 from cubicweb import Unauthorized |
35 from cubicweb.predicates import (one_line_rset, |
32 from cubicweb.predicates import (one_line_rset, |
36 relation_possible, match_form_params, |
33 relation_possible, match_form_params, |
37 score_entity, is_instance, adaptable) |
34 score_entity, is_instance, adaptable) |
38 from cubicweb.view import EntityView |
35 from cubicweb.view import EntityView |
39 from cubicweb.web import stdmsgs, action, component, form |
36 from cubicweb.web import stdmsgs, action, component, form |
40 from cubicweb.web import formwidgets as fwdgs |
37 from cubicweb.web import formwidgets as fwdgs |
41 from cubicweb.web.views import TmpFileViewMixin |
|
42 from cubicweb.web.views import uicfg, forms, ibreadcrumbs |
38 from cubicweb.web.views import uicfg, forms, ibreadcrumbs |
43 from cubicweb.web.views.tabs import TabbedPrimaryView, PrimaryTab |
39 from cubicweb.web.views.tabs import TabbedPrimaryView, PrimaryTab |
44 from cubicweb.web.views.dotgraphview import DotGraphView, DotPropsHandler |
40 from cubicweb.web.views.dotgraphview import DotGraphView, DotPropsHandler |
45 |
41 |
46 _pvs = uicfg.primaryview_section |
42 _pvs = uicfg.primaryview_section |
442 def build_visitor(self, entity): |
438 def build_visitor(self, entity): |
443 return WorkflowVisitor(entity) |
439 return WorkflowVisitor(entity) |
444 |
440 |
445 def build_dotpropshandler(self): |
441 def build_dotpropshandler(self): |
446 return WorkflowDotPropsHandler(self._cw) |
442 return WorkflowDotPropsHandler(self._cw) |
447 |
|
448 |
|
449 @add_metaclass(class_deprecated) |
|
450 class TmpPngView(TmpFileViewMixin, EntityView): |
|
451 __deprecation_warning__ = '[3.18] %(cls)s is deprecated' |
|
452 __regid__ = 'tmppng' |
|
453 __select__ = match_form_params('tmpfile') |
|
454 content_type = 'image/png' |
|
455 binary = True |
|
456 |
|
457 def cell_call(self, row=0, col=0): |
|
458 key = self._cw.form['tmpfile'] |
|
459 if key not in self._cw.session.data: |
|
460 # the temp file is gone and there's nothing |
|
461 # we can do about it |
|
462 # we should probably write it to some well |
|
463 # behaved place and serve it |
|
464 return |
|
465 tmpfile = self._cw.session.data.pop(key) |
|
466 self.w(open(tmpfile, 'rb').read()) |
|
467 os.unlink(tmpfile) |
|