On Fri, 25 Nov 2005 17:15:24 -0600, "Brad Allen" <[EMAIL PROTECTED]>
said:
> I'd prefer to allow content editors on my site to avoid having to 
> type HTML, and have heard that reST might be a good, wiki-like 
> choice. However, it's not clear to me how to get that working with 
> ZPT content insertions. Would I need to build a new content class for 
> this, or is there some easier way?

When a similar issue came up for me, all I did was add an additional
type field to the content object then created a "render" method in the
view, something like this for a 'description' field:

def renderdescription(self):
    # for rest, self.context.descriptiontype would be 'zope.source.rest'
    source = zapi.createObject(None,self.context.descriptiontype,
    self.context.description)
    textview = zapi.getView(source,'',self.request)
    html = view.render()
    return html

And then just used "view/renderdescription" in my templates.  

On grepping the zope codebase quickly, it looks like the more "modern"
way to do this would be to use getMultiAdapter like:

    source = zapi.createObject(type,text)
    renderer = zapi.getMultiAdapter((source, self.request))
    return renderer.render()

I have no idea why I have an extra 'None' argument in my code, above

See zope/app/preference/browser.py for an example



_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to