InterviewSolution
| 1. |
What Causes "'stream' Object Has No Attribute 'tag'"? |
|
Answer» This is most probably caused by mixing Genshi and ToscaWidgets incorrectly. In the beginning, there was Kid and “traditional” widgets. Traditional widgets returned an ElementTree object, which the Kid engine converted into HTML. In Genshi, you can use traditional widgets, but you MUST use the "ET()" FUNCTION to explicitly convert them to HTML. (If you get "<script elementat ASDFASDF>" in your output, that is a sign that you are handing a traditional widget back to Genshi, and NOT wrapping it in ET().) ToscaWidgets, on the other hand, return HTML natively. If you wrap a ToscaWidget reference in ET(), you will get a stack trace saying "'Stream' objecthas no ATTRIBUTE 'tag'". Note that these issues do not exist any more in TurboGears 1.1 and 1.5, they do all the necessary wrapping and CONVERTING for you. TurboGears 1.5 even ALLOWS Genshi templates in TurboGears widgets and will convert between the Kid and Genshi templating systems under the hood. This is most probably caused by mixing Genshi and ToscaWidgets incorrectly. In the beginning, there was Kid and “traditional” widgets. Traditional widgets returned an ElementTree object, which the Kid engine converted into HTML. In Genshi, you can use traditional widgets, but you must use the "ET()" function to explicitly convert them to HTML. (If you get "<script elementat ASDFASDF>" in your output, that is a sign that you are handing a traditional widget back to Genshi, and NOT wrapping it in ET().) ToscaWidgets, on the other hand, return HTML natively. If you wrap a ToscaWidget reference in ET(), you will get a stack trace saying "'Stream' objecthas no attribute 'tag'". Note that these issues do not exist any more in TurboGears 1.1 and 1.5, they do all the necessary wrapping and converting for you. TurboGears 1.5 even allows Genshi templates in TurboGears widgets and will convert between the Kid and Genshi templating systems under the hood. |
|