[Zope3-Users] using tal to insert zwiki content

Jeff Shell eucci.group at gmail.com
Wed Jan 4 15:47:10 EST 2006


On 1/3/06, Brad Allen <brad at allendev.com> wrote:
> At 11:52 PM -0700 1/2/06, Jeff Shell wrote:
> >There are a lot of ways one can go from there. In Zope 3.2, a good
> >solution for pages made of parts where the content of the parts comes
> >from ZWiki pages, you could probably use viewlets.
>
> I haven't seen the term "viewlet" defined thus far. In this case, would
> that be a view that I would create somewhere outside the zwiki
> package? I'd rather
> not make changes to the zwiki source code itself, because that would
> be difficult to merge with future releases.

Viewlets are a new feature in Zope 3.2. They're kindof "views for
views". There's documentation in the 'zope.viewlet' package in the 3.2
beta releases. They're a bit more of an advanced feature than regular
views, and not something that you necessarily need to concern yourself
with right now - especially if you're still new to the Zope 3 system.

One of the promises of Zope 3 is that you should be able to make
additional views and adapters for other objects without having to
touch their code. In the case of zwiki for Zope 3, you can probably
declare a new view using the ViewWikiPage class and have it use the
'render()' method, which is what draws the source code. In your own
package, you can have:

<configure xmlns="http://namespaces.zope.org/browser">
  <page for="zwiki.interfaces.IWikiPage" name="render_inline"
       class="zwiki.browser.wikipage.ViewWikiPage"
       attribute="render"
       permission="zwiki.ViewWikiPage"
       />
</configure>

This just creates a new view that calls the 'render' method of a
ViewWikiPage instance. That method is what renders the wiki page's
source. Then you can use

``tal:content="structure context/wiki/About_Downwinders/@@render_inline"``

Although, after looking at the ZWiki code quickly, the wiki links that
it renders may not be relative to the page they're being viewed from.
But you could also subclass zwiki.browser.wikipage.ViewWikiPage and
make your own view based on that, overriding the methods it defines
for rendering Wiki links.

You can do all of this in your own code. It doesn't impact ZWiki - it
shouldn't know or care about any custom views you define.


More information about the Zope3-users mailing list