This is the discussion place for DTMLCookbook = how to do simple tasks with DTML for a ZWiki :

This page is for the discussion of the development of the document: DTMLCookbook

PageMaintainers: FloK, DeanG

OpenQuestions? :

What's the difference betweeen:

  &dtml-last_editor;  and  &dtml.url_quote-last_editor


FlorianKonnertz, 2002/12/16 14:24 GMT (via web):
Necessary changes when using a DynamicDNS? redirect:

I did it for NooWiki:RecentChanges as far by now. See the modified code at

DeanGoodmanson, 2003/01/02 00:59 GMT (via web):
url_quote converts the string to URL friendly characters, just as html_quote does for HTML friendly chars...

Anyone know if there's an xml_quote ?

2003/01/03 07:01 GMT (via web):
I'd really like a version of th SearchPage? that worked in a NestedPage? (WikiInclusion?) This would essentially be a word search much like WikiBadges...

This would need to be formattable in no more than 1/3 hor/vert of a page. A similar example is AboutZwikiDiscussion, but extending the search to take an overridable text-box.

FlorianKonnertz, 2003/01/11 11:21 GMT (via web):
I want to provide a section in the header for SisterSite? links configurable via UserOptions?. My first start was with a dtml-var and cookie similar to the bookmarks, seperated with spaces. The user has to enter the RemoteWikiURL-s (later it would be great to get the URLs? from the RemoteWikiLink? pages) ie: ;

Now i need to split that string:

  <dtml-let ssl="_.string.split('hallo test checkthisout'),' '">
  <dtml-var "ssl[0][0]">
  <dtml-var "ssl[0][1]">

And then add the:

  <a href="http://<dtml-var ... > blabla 

to it. I'll post my progress later today. Do you see any problems or have better suggestions?

FlorianKonnertz, 2003/01/11 14:38 GMT (via web):
See AdditionalLinkPanel for a first solution.

FlorianKonnertz, 2003/01/11 15:00 GMT (via web):
How to display the raw code of a DtmlMethod? or DtmlDocument? by inclusion, ie the code of the current RecentChanges? on a RecentChangesCode? page?:

  <dtml-var recentchangesdtml>  ->  <dtml-var "recentchangesdtml".raw> (WRONG!) 

hmmm.... should be easy but i don't remember.

raw code :

 <dtml-var "recentchanges.src()"> ???

This doesn't work, ehmm...:

  <dtml-var "recentchangesdtml.src()">
  (Object: recentchangesdtml.src()) (Info: recentchangesdtml) File , line 2, in f AttributeError: __call__

Ideas, please ?! - FloK,01-13

DeanGoodmanson, 2003/01/12 15:37 GMT (via web):
Splitting text

The [OldZwikiFAQPage]? has a good example of using split with a find to determine the index of the start of the searchd for text within a text block (ideally a page).

FlorianKonnertz, 2003/01/13 13:06 GMT (via web):
Thanks Dean, i saw there's similar code used in the LittleBlog? code in NooWiki:DebugWiki. - Very good.

FlorianKonnertz, 2003/01/14 11:26 GMT (via web):
How to wikilink an acquired DTMLMethod, ie. recentchangesdtml or useroptionsdtml? My approach:

  <dtml-let dmethod="pageWithName(useroptionsdtml)">
  <dtml-var "wikilink(dmethod)">

does not work. Does pageWithName only accepts WikiPage?-s objects or is it the syntax [i guess :-( ]? or both?

That's also not the right thing:

  <dtml-let dmethod="(useroptionsdtml.raw)">

Now the dtml is not executed anymore. Is there a method to do this manually dtml(), similar to wikilink()?

Todo: How to handle these expressions:


FlorianKonnertz, 2003/01/17 07:50 GMT (via web):
copied from IncludeOrTransclude: src() is a method of what object? What is the difference with document_src()?

FlorianKonnertz, 2003/01/23 15:18 GMT (via web):
Showing code of standardwikiheader

I'd like to show dynamicall the code of all the SystemPages?. It works with all pages but not with header and footer, why?:

  <dtml-var "standard_wiki_header.document_src()" html_quote newline_to_br>

I get the following error:

  (Object: standard_wiki_header.document_src()) (Info: standard_wiki_header) File , line 2, in f RuntimeError: 
function attributes not accessible in restricted mode

DeanGoodmanson, 2003/01/23 21:18 GMT (via web):
What's up?

At first I questioned to necesity for tihs page until I saw how clean to DTMLCookbook became. I've modified the description portions of the pages.

It seems that the OpenQuestions? on that page vs. this page is going to be interesting to maintain. I suggest putting it on it's own page ZWikiCookbookOpenQuestions? and including it.

p.s. OT: I really hate the obscure & hard to remember term "transclude", although technicaly it fits. I like SubPage? but think that's a term other wiki's use for page heirarchies. (like SubWiki's) What do you think of EmbeddedPage ??

FlorianKonnertz, 2003/01/24 22:00 GMT (via web):
Cooking progress

Dean: Yes, the pages are both much clearer now - one for discussion, questions and collaborating on solutions and one for reference. - An own Open-Questions page included sounds like a good idea, imo PageInclusion? is used too little (all the possibilites in ZWiki and dtml in general are hard to remember). I'd give it a try.

FlorianKonnertz, 2003/01/26 22:41 GMT (via web):

Embedding dtml-containing pages in other pages by dtml: Sometimes it works, sometimes not. Further investigation needed. Example:

  <dtml-in "aq_parent.objectItems(spec='ZWiki TestPage')"> <dtml-if sequence-end> <b><dtml-var sequence-number> pages </b> </dtml-if> </dtml-in>

cannot be included. But the following one can:

  <dtml-in "debug.objectItems(spec='ZWiki TestPage')"><dtml-if sequence-end><dtml-var sequence-number> pages</dtml-if></dtml-in>

The aq_parent object makes problems apparently. - Why?

Simon Michael, 2003/01/29 21:59 GMT (via mail):

> The aq_parent object makes problems apparently. - Why?

When you have DTML pages nested like that, aq_parent is probably the outer page not the folder. Zwiki's folder() method is a way to avoid that issue.

FlorianKonnertz, 2003/01/31 15:30 GMT (via web):

Thanks,Simon. I did my first tests with folder() - seems to suit my needs.

FlorianKonnertz, 2003/01/31 15:35 GMT (via web):
dtml expr question

Why can i do:

  <dtml-var "getPropertyType(x_sequence_key)">

but not:

  <dtml-let ptype="getPropertyType(x_sequence_key)">

I get:

  File /usr/local/Zope-2.5.0-src/lib/python/DocumentTemplate/, line 695, in renderwob
    (Object: propertyItems)
  File /usr/local/Zope-2.5.0-src/lib/python/DocumentTemplate/, line 76, in render
    (Object: ptype=&quot;getPropertyType(x_sequence_key)&quot;)

I looked for similar examples and it looks always like < dtml-let variable="method(blah)" > - How can this be done?

SimonMichael, 2003/01/31 18:37 GMT (via web):
Something's not right there. Are your double quotes getting quoted ? Set up this code snippet on TestPage if you like and I'll play with it.

FlorianKonnertz, 2003/01/31 19:43 GMT (via web):
dtml expr question

Don't know yet what it could be... :-( I started a PropertyEditFormTest? page. - And then.... it works here. :-)

But i need your help in the "external method imports ZwikiPage? to access general properties" issue. At the moment i use an external method:

def getPropertyMode(idin): """Returns the mode of a given property """ import Products.ZWiki.ZWikiPage

### here some code is missing

for prop in p: id=prop['id'] mode=prop['mode'] if (idin == id): res = prop['mode']

return res

if __name__ == '__main__': import sys print getPropertyMode(sys.argv[1])

It's not working fine yet. I don't know yet how to access the _properties attribute of the ZwikiPage? class. How is this be done?

FlorianKonnertz, 2003/01/31 19:52 GMT (via web):
dtml expr question

BTW: Currently i've put it hardcoded in the ExternalMethod.... - IMO it's better to add a function getPropertyMode(id) in ZWikiPagePy? but as long NooWiki is on my friends server where i've no root permission (probably i move the next days, yep :-) i have to do it with an ExternalMethod. - Do you think i'm on the right path, Simon? - I hope so.

FlorianKonnertz, 2003/01/31 20:19 GMT (via web):

In the ZMI there already is a pretty property editform. Can't it be reused for our purpose? Even the Add new property could be used. It is almost exactly what i (we) want, but i came to my mind but now... :-O

Where is this stuff located in the zope src?

FlorianKonnertz, 2003/01/31 20:25 GMT (via web):

Ok, i got it.::

root@grooveway:/usr/local/zope/lib/python/OFS# vim PropertySheets?.py

Let's see if it can be used.

Discussion TestPage Auto-Creation --Ducker, 2003/02/19 10:50 GMT
I'm sure there are some better ways to do this, but I've upped the code for auto-creating discussion pages at DiscussionCreator

Discussion auto-creation --DeanGoodmanson, 2003/02/19 16:00 GMT
That's a great one, Ducker!

I'd suggest adding a "parameter" so that it can be put in a DTMLMethod and doc page authors can point the document a common discussion page. For instance, this link would be nice to add to all of the related recipe's, but most of those recipes can be discussed at this page.

If you feel like getting REALLLY fancy, the link would direct the person to that page with a variable for the optional subject http://site/ZwikiCookbookDiscussion#bottom?OptSubject=ReferrerPage (the footer would have to be modified to accept a that parameter to fill in the form field.)

(Note: The "if value else set to default" seems to be a bit of a pattern that should be noted on this page soon.)

AutomaticContributionManagement? --FlorianKonnertz, 2003/02/20 00:28 GMT
with a variable for the optional subject - Good idea, Dean. - An example of your idea would be: If you have, let's say a topic page with ten subtopic pages and most of them have minor discussion traffic you might want to direct the contributions to these pages to the main topic's discussion page (with the page title as subject) or to a misc

In a certain view it's kinda opposite of my Post this weblog entry also to the following wikipages approach (NooWiki:NooWikiWeblog). Sometimes it's useful to copy items to a few special topic pages and sometimes it's good to collect them on one page (or copies of it).

Another REALLY fancy :-) thing: Having a (user set) property for some important pages in one's wiki to post the entry also to a remote wiki's page (with same name or not). I do often ask the question: Should i write this idea first to my wiki or first here on zwikidotorg or both or...? - Also imagine an automatic added note "This comment is a copy from wiki so-and-so page xy" resp. "This comment was also posted to blahblahwiki:hereandnow". - RFC: Would you appreciate such a feature?

ZPT --DeanGoodmanson, 2003/02/20 01:37 GMT
FloK - Do you have any ZPT that sits in the text of a ZwikiPage? ?

I have only heard of ZPT in the context of header/footer support.

[ZPT]? --FlorianKonnertz, 2003/02/20 10:05 GMT
DeanG: No. I've done the header and footer up to now. What do you want to do? Anything special in mind? My first interest is of course the IsssueTracker? and the ZwikiWeblog? but i still wait for furhter comments/interest in creation of a new page type before just transforming these to ZPT.

ZPT --DeanGoodmanson, 2003/02/20 14:35 GMT
What do I want to do?

Make ZWiki more acceptable to the "dtml is bad" Zope crowd.

I'm interested in it as an alternative for the WebLogs? and Issue and Task tracker myself. (ZWikiRecordBook?)

ZPT version of IssueTracker --FlorianKonnertz, 2003/03/24 09:42 GMT
I'm coding a ZPT version of IssueTracker at the moment. Please tell me why i get an:

  AttributeError: page_url\n</p>', 'error_value': <exceptions.AttributeError instance at 0xb52aea4>

on this line:

  <a tal:attributes="href python:here.page_url() + '?statuses:list=' + status">

i got it --FlorianKonnertz, 2003/03/24 10:17 GMT
Ok, i got it! I was browsing the template directly instead of a wikipage embedding it via < dtml-var template > ... - Ooups!! ;-) I'm mortified. :-/

IssueTracker, ZPT, help needed --FlorianKonnertz, 2003/03/24 15:59 GMT
I need help with the loop over all the issues in IssueTracker, how to do it in ZPT. It seems as if one has to check for an request item in ZPT before asking for getattr, but i'm not sure.

IssueTracker, ZPT, help needed --SimonMichael, 2003/03/24 21:33 GMT
I'd guess something like:

 <li tal:repeat="item python:here.catalog(){isIssue=1}">
 <span tal:replace="item/status"></span>

etc. PageTemplate has some good docs links.

IssueTrackerZPT thanks --FlorianKonnertz, 2003/03/24 22:13 GMT
Thanks Simon, meanwhile i managed it. See IssueTrackerZPT. I kept the algorithm of the dmtl version (as far as possible). What do you think? BTW,When do you want to provide a ZPT version of ZWiki?

IssueTrackerZPT thanks --SimonMichael, 2003/03/25 01:08 GMT
I think it's nifty, and good to explore. It's weird to see my old crufty dtml code now in the pristine world of PageTemplates :). I find my wiki page version more useful though.

pathindex problem, Help needed urgently! --FlorianKonnertz, 2003/04/01 20:30 GMT
I need help with a ZCatalog problem: How to address the pathindex? (ZPT). It's for my IssueTrackerZPT version, i need to prevent querying the subwikis which a catalog normally does. Please see my mail in the zope list on 03-31: "Catalog: access index value in ZPT"

Why isn't it possible to do:

  <span tal:replace="python:item.path"></span>

(path is index and metadata)

PluginAPIDiscussion --DeanGoodmanson, 2003/04/02 00:41 GMT
Looking for enlightenment here, not so much direction.

I am in no position to start coding on that now, but I'd really like to know the background, thoughts and issues/gotcha's behind this potential development.

Is it possible to discuss development in a public arena without the expection of action? Although I've seen feature discussions turn out overwhelming and turned off projects, I'm willing to risk it, especially in this arena designed to capture knowlege. :-)

page creation / id question --FlorianKonnertz, 2003/04/18 08:20 GMT
I'd like to ask you why...

the creation of a new page with Id="ZWL20030418" (valid) is fine via ZPT:

  <span tal:define="pageid python:'ZWL20030418'" tal:replace="python: here.create(pageid, text='', REQUEST=request)"> </span>

but fails via DTML:

  <dtml-let  pageId="'ZWL20030418'">
  <dtml-call "create(pageId,text='',REQUEST=REQUEST)">

  Bad Request: The id "ZWL20030418" is invalid--it is already in use.

(In ZWiki-0.17 of course)

What's going on? --FlorianKonnertz, 2003/04/18 09:58 GMT
These things are really strange: brings up the page creation form (page not existing) but in ZMI i can see the page. Then i call the page with the ZPT, i get the BadRequest? error, but then the page exists and be called via RecentChanges?. Then i delete it via the page management button and call the page with DTML and i'm directed to the "page-does-not-exist.-create-it?"-Form. - What's going on?

page creation / id question --FlorianKonnertz, 2003/04/18 10:25 GMT
New trial with new page name:

The ZPT page directs me to the URL in the parent wiki

So tried it again with everything in the main wiki: ZPT redirects to the parent folder, outside the wiki. Why?

page creation / id question --2003/04/20 05:22 GMT
Hi Simon, here's what i found out further by a careful examination of the create page problem we debugged (dtml again). I did it on a new zope with only ZWiki installed and my Data.fs copied to it. - Both behave the same except for that the fresh install tells me on the NewIdTestPage? that creation succeeded, the old zope NOT. Both pages ARE created and can be seen in RC and ZMI as expected. So in fact there must be something wrong with my current zope. I don't know what to do now - I'll report again. Cheers,Flo

page creation / id question --2003/04/22 10:14 GMT
I have to know why pages are not listed on RecentChanges? even if they exist in ZMI. My testpage was created by create so it has no size in ZMI - but other testpages also have no size and they're also listed in ZMI. I will look in the source now, but if anyone has an idea of this, please tell me. - TIA, Flo

page creation / id question --2003/04/22 10:35 GMT
This is a SubWiki issue. In a main wiki the ZMI and RecentChanges? are consistent.

dtml to list a page's children --DeanGoodmanson, 2003/05/13 13:55 GMT
A dtml snippet which returns a list of a pages children would be useful. It has been noted on PeopleIndex and GeneralDiscussion.

AllPages may be some help. Psuedocode:

 childpages = []
 foreach page in pages:
   if page.parents contains (this pages)id:
 foreach page in childpages
   print wikilink('['+page+']') + seperator

There's my 2 minute attempt to help...

dtml to list a page's children --simon, 2003/05/13 16:12 GMT
Thanks Dean. Here's what I use:

    def offspring(self, REQUEST=None):
        """Return a presentation of all my offspring."""

    def offspringAsList(self, REQUEST=None):
        Return all my offspring's page names as a flat list.

   def offspringIdsAsList(self, REQUEST=None):
        Return all my offspring's page ids as a flat list.

    def ancestorsAsList(self, REQUEST=None):
        Return the names of all my ancestor pages as a flat list, eldest first.

        If there are multiple lines of ancestry, return only the first.

These are in

DTML focus ? --simon, 2003/05/13 16:16 GMT
By the way.. I like the cookbook approach. Any interest in renaming these pages to connote DTML somehow ? DTMLCookbook, DTMLDiscussion?, ... ?

list a pages children. --DeanGoodmanson, 2003/05/13 18:30 GMT
The dtml statement was my oversight. I'm glad to see there's support for this stuff in zwiki code, and easily callable via dtml: <dtml-var "offspringAsList()">

I'm having trouble trying to get a particular format, would you mind showing me why the sequence-item doesn't work here? :

 <dtml-in "offspringAsList()">
  <dtml-var "wikilink('['+sequence-item+']')"> |

DTML focus --DeanGoodmanson, 2003/05/13 18:34 GMT
The dtml statement was knee-jerk reaction. For me in-page=in dtml. I'm OK to spin off dtml items into those pages, especially now that ZwikiModifications are becoming more prevelant. :-) I'll refactor these pages soon with the names you suggested. I didn't write up how I added a field to the tracker, and perhaps seperating out the DTML stuff would make this kind of thing more inviting, and less annoying to the dtml !*@&s! crowds out there. Any thoughts regardng my last submission to PluginAPIDiscussion as a better way to seperate logic from content [than DTML]?

... --simon, 2003/05/13 19:08 GMT
I don't know that + notation. How about:

 <dtml-in offspringAsList prefix=x>
   [<dtml-var x_sequence_item>]

... --simon, 2003/05/13 19:14 GMT
Interesting.. a wikiname in brackets isn't getting linked right. Also those offspring methods return all children, grandchildren etc. so aren't the answer. I did this in dtml once, using the method you posted I think.

... --simon, 2003/05/13 19:17 GMT
No thoughts on PluginAPIDiscussion right now.

... --simon, 2003/05/13 19:20 GMT
Try this:

 <dtml-let thispage=name>
 <dtml-in pages prefix=x>
   <dtml-if "thispage in x_sequence_item.parents">
   <dtml-var "wikilink(">

... --simon, 2003/05/13 19:38 GMT
Oops, link the name, not the entire page text. So this works, but of course it's expensive in a large wiki. stores parents and calculates children, so children are harder to work out. Using catalog would be one way to optimize. Here's another approach, I don't know if it makes a difference:

 <dtml-let thispage=name>
 <dtml-in offspringAsList prefix=x>
   <dtml-if "thispage in pageWithName(x_sequence_item).parents">
   <dtml-var "wikilink(x_sequence_item)">

How do I get last 3 discussions from all wiki pages ended with "discussion"? --2003/05/19 04:07 GMT
As title, which is similar to this site's FrontPage that get last three GeneralDiscussion comments.

How do I get last 3 discussions from all wiki pages ended with "discussion"? --SimonMichael, 2003/05/19 05:37 GMT
I'm not sure, but I'd like to have something similar for FrontPage (show last three comments made anywhere in the wiki). Getting the last three modified pages is easy enough, at least with a catalog. I don't think we can be sure whether the page was commented or edited last, without adding a special flag for this.


Zwiki in frames URL helper --DeanGoodmanson, 2003/07/30 04:22 GMT reply
I'm addicted to the FuzzyLinks? and end up browsing via URL/Address bar much more than I expected after using the wiki within a frame and losing that control.

Here's the snippet I put together to add a URL address bar to teh wiki header.


 <form method="GET" action="redir" >
   <input name="new_url" size="40" value="<dtml-var URL>"><input type="submit" value="Go">

Supporting DTML method:

 <dtml-if new_url>
  <dtml-call "RESPONSE.redirect(new_url)">
  <dtml-if HTTP_REFERER>
   <dtml-call "RESPONSE.redirect(HTTP_REFERER)">
    <dtml-call "RESPONSE.redirect(URL1)">


There's plenty of room for polish here, including url_quote, removing and re-adding domain name and protocol, etc.

I consider this a crude variation on the SearchPage?'s Jump functionality, which may be a better integratoin (a checkbox next to search form for something like google's "I'm feeling lucky" functionality, or a preceding left square bracket meaning "jump to page", or search . "Abc" = Search wiki for abc, where "[ABC" = Search wiki for abc page and jump ... not sure the implications of regex thinking at this moment, and there might be some "title only" vs. "title AND content" confusion.

How does one include the Sitemap on a page?

Including some different page like on DTMLCookbook works, but how do I include something like this:

   <dtml-var "SELF/map(bare=1)">

if i "hard code" it, e.g. putting:

   <dtml-var "FrontPage/map(bare=1)">

on Frontpage, it does not work (croaks on saving). Sure, putting a page include to "Self" on the page does croak, it creates a loop. But why does the /map go wrong?


sitemap on front page --DeanGoodmanson, Mon, 22 Sep 2003 11:53:05 -0700 reply
does something like this work?:

  <dtml-var map>

how do i include the map on a page? --Simon Michael, Tue, 23 Sep 2003 00:20:58 -0700 reply
Thomas - what are you trying to do ? If you want to quote and display the dtml code, you must use a STX quoted paragraph (::) as Dean says. Or html-quote the angle brackets, or put a space after the left bracket.

sitemap on front page --ThomasSprinzing, Tue, 23 Sep 2003 02:17:46 -0700 reply

 < dtml-var map>

 works, but it includes the whole map page. So i get the page Header and logo on the result. Isnt`t there a way to get just the map?
Simon: Sorry `bout that - sometimes the company proxy does strange things and delivers old unupdated pages to me. So editing is not at all straightforward...

sitemap on front page --Simon Michael, Wed, 24 Sep 2003 09:30:30 -0700 reply
Like on NavigationAids ? Yes. There's also dtml-var offspring and dtml-var subtopics (new), but these will only look under a single page (the current, or one you specify).

REQUEST, RESPONSE --DeanGoodmanson, Mon, 17 Nov 2003 11:11:38 -0800 reply
Remember: When adding a <dmtl-var REQUEST> and RESPONSE debug information to a page the redirect may no longer work.

Are there any forums about Zope and ZWiki? -- Wed, 29 Dec 2004 20:39:06 -0800 reply
Just wanting to know if Zope and ZWiki have a forum in which to join and interact with questions and answers using both. ''--JohnNaughton''

... --Bob McElrath?, Wed, 29 Dec 2004 20:46:40 -0800 reply
Yes, see AboutZwikiDiscussion