equal
deleted
inserted
replaced
58 output = 'text/html' |
58 output = 'text/html' |
59 output_encoding = 'utf-8' |
59 output_encoding = 'utf-8' |
60 def _convert(self, trdata): |
60 def _convert(self, trdata): |
61 context = CubicWebContext() |
61 context = CubicWebContext() |
62 appobject = trdata.appobject |
62 appobject = trdata.appobject |
63 context.update({'self': appobject, 'rset': appobject.rset, |
63 context.update({'self': appobject, 'rset': appobject.cw_rset, |
64 'req': appobject.req, |
64 'req': appobject._cw, |
65 '_' : appobject.req._, |
65 '_' : appobject._cw._, |
66 'user': appobject.req.user}) |
66 'user': appobject._cw.user}) |
67 output = UStringIO() |
67 output = UStringIO() |
68 template = compile_template(trdata.encode(self.output_encoding)) |
68 template = compile_template(trdata.encode(self.output_encoding)) |
69 template.expand(context, output) |
69 template.expand(context, output) |
70 return output.getvalue() |
70 return output.getvalue() |
71 |
71 |
86 register_pygments_transforms(ENGINE, verb=False) |
86 register_pygments_transforms(ENGINE, verb=False) |
87 |
87 |
88 def patch_convert(cls): |
88 def patch_convert(cls): |
89 def _convert(self, trdata, origconvert=cls._convert): |
89 def _convert(self, trdata, origconvert=cls._convert): |
90 try: |
90 try: |
91 trdata.appobject.req.add_css('pygments.css') |
91 trdata.appobject._cw.add_css('pygments.css') |
92 except AttributeError: # session has no add_css, only http request |
92 except AttributeError: # session has no add_css, only http request |
93 pass |
93 pass |
94 return origconvert(self, trdata) |
94 return origconvert(self, trdata) |
95 cls._convert = _convert |
95 cls._convert = _convert |
96 patch_convert(pygmentstransforms.PygmentsHTMLTransform) |
96 patch_convert(pygmentstransforms.PygmentsHTMLTransform) |