Hi all My use case: Create content type 'Portlet' that could have TAL as its content and when watched in browser TAL should be redered. My code is below.
class PortletView: def renderText(self): portlet = IPortlet(self.context) format = portlet.format if format in ('HTML', 'Plain'): return portlet.getText() elif format == 'Structured': struct = structurize(portlet.getText()) doc = DocumentWithImages()(struct) output = HTMLWithImages()(doc, level=1) return output elif format == 'Page Template': page_template = PageTemplate() page_template.write(portlet.getText()) output = page_template() return output But there is a problem. When I define a variable in template and call it its ok. But I cannot call 'context' variable (for example <div tal:content="context/title"/>). This is my traceback. Traceback (most recent call last): File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\publisher\publish.py", line 138, in publish result = publication.callObject(request, object) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\app\publication\zopepublication.py" , line 164, in callObject return mapply(ob, request.getPositionalArguments(), request) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\publisher\publish.py", line 113, in mapply return debug_call(object, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\publisher\publish.py", line 119, in debug_call return object(*args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\app\pagetemplate\simpleviewclass.py ", line 44, in __call__ return self.index(*args, **kw) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\app\pagetemplate\viewpagetemplatefi le.py", line 83, in __cal l__ return self.im_func(im_self, *args, **kw) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\app\pagetemplate\viewpagetemplatefi le.py", line 51, in __cal l__ sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0), File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\pagetemplate\pagetemplate.py", line 117, in pt_render strictinsert=0, sourceAnnotations=sourceAnnotations)() File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 270, in __call__ self.interpret(self.program) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 897, in do_useMacro self.interpret(macro) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 531, in do_optTag_tal self.do_optTag(stuff) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 516, in do_optTag return self.no_tag(start, program) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 511, in no_tag self.interpret(program) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 867, in do_defineMacro self.interpret(macro) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 965, in do_defineSlot self.interpret(block) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 955, in do_defineSlot self.interpret(slot) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 758, in do_insertStructure_tal structure = self.engine.evaluateStructure(expr) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\tales.py", line 698, in evaluate return expression(self) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\expressions.py", line 204, in __call__ return self._eval(econtext) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\expressions.py", line 198, in _eval return ob() File "c:\Program Files\Python2.4.2\zope-instances\instance-8080\lib\python\acc\swordfish\basi c\portlet.py", line 72, i n renderText output = page_template(content=object,temp="TEMP") File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\pagetemplate\pagetemplate.py", line 96, in __call__ return self.pt_render(self.pt_getContext(args, kwargs)) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\pagetemplate\pagetemplate.py", line 117, in pt_render strictinsert=0, sourceAnnotations=sourceAnnotations)() File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 270, in __call__ self.interpret(self.program) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 345, in interpret handlers[opcode](self, args) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tal\talinterpreter.py", line 618, in do_insertText_tal text = self.engine.evaluateText(stuff[0]) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\tales.py", line 706, in evaluateText text = self.evaluate(expr) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\tales.py", line 698, in evaluate return expression(self) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\expressions.py", line 204, in __call__ return self._eval(econtext) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\expressions.py", line 191, in _eval ob = self._subexprs[-1](econtext) File "C:\Program Files\Python2.4.2\Lib\site-packages\zope\tales\expressions.py", line 117, in _eval ob = vars[base] KeyError: 'context' Lukasz Lakomy _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users