[Zope3-Users] correct display of Text field in a view

FB fbo2 at gmx.net
Fri Mar 9 04:36:17 EST 2007


Hi,

On Fri, Mar 09, 2007 at 10:06:26AM +0100, Ivan Horvath wrote:
> Dear All,
> 
> in my learning application there is a description property
> this is declared as Text field in the schema
> of course an enter (newline) can be entered in this field, but on the view page i can see only raw 
> text
> the viewpage class is inherited from DisplayForm
> 
> i've tried already some things:
> - modify the description widget data with PlainTextToHTMLRenderer.render(), but then in the 
> browser i can see only encoded chars instead of <br>
> - i've tried to create a new widget (following Zope3 Developer's Book 15. chapter), then i 
> received a textarea html element in the view as well - of course i could modify the value, of 
> course i cannot save
> 
> the best would be on the view page a simple html (just texts) taking into cosideration the new 
> line chars.
> 
> any idea?

how about that:

from xml.sax.saxutils import escape
class MyView(BrowserView):
   def __call__(self):
      self.description=escape(self.context.description).replace("\n","<br />")


<p tal:content="structure view/description" />

Regards,

Frank


More information about the Zope3-users mailing list