Usually, you can set the title and id of a zope object to whatever you want. But not so in the Zwiki world; when you create or rename or even view a zwiki page, you'll see that it chooses the id for you. This is a bit unexpected. What is the reason for it ?

Why Zwiki pages choose their own id

Zope objects effectively have two names:

Having two names for a page creates confusion, especially in the fast moving world of wiki content. When you want to remember a page, you'll remember the title. But the url is also important, so you'll need to remember the id. Are they the same ? Sometimes yes, other times no. If you remember one, is there any way to figure out the other ? No. If title is changed, will the page's id change also ? Not necessarily, it might stay the same and now be unrelated to the page's latest content. Worse, there may be a new page to which it is much more related.

Zwiki thinks that users should only have to think about one name for a page, to avoid confusions like the above, and on general principles of simplicity. We resolve things as follows:

In other words,

"User chooses the title, Zwiki chooses the id."

How Zwiki chooses the id

Zwiki generates a "canonical" id from the title. This means that any title you throw at it will be boiled down to one unique and predictable id. The procedure is easy to understand:

**"Id is title converted to the nearest WikiName, or almost-WikiName, by capitalizing words and dropping punctuation and whitespace."**

This is not the only possible algorithm, but it's one that works quite well. It has the property that if you stick to WikiName, title and id are always the same, and if not, id is similar and guessable. Here's a more detailed description.:

    def canonicalIdFrom(self,name):
        Convert a free-form page name to a canonical url- and zope-safe id.

        Constraints for zwiki page ids:
        - it must be a legal zope object id
        - it should be legal in urls
        - it should be unique for a given name (ignoring whitespace)
        - we'd like it to be as similar to the name and as simple to read
          and work with as possible
        - we'd like to encourage serendipitous linking between free-form
          and wikiname links & pages
        - it must avoid certain zope-significant names, to avoid breakage

        So, we
        - discard non-word-separating punctuation (')
        - convert remaining punctuation to spaces
        - capitalize and join whitespace-separated words into a wikiname
        - convert any non-zope-and-url-safe characters and _ to _hexvalue
        - if this results in an id that begins with _ (illegal), prepend X
        - or if we have a legal id but it's one of the delicate IDS_TO_AVOID
          (REQUEST, RESPONSE, epoz, URL, outline, recycle_bin, etc), we append X
          Note these last break the uniqueness property. Better ideas welcome.


Some zwiki page titles and their ids:

Other things which help

FuzzyUrls allow you to type the title in your browser, so no need to remember id at all...

Placeholder pages when renaming keep incoming links working (but are not used by default)...

What this means for ZMI and CMF/Plone

Zwiki's own page management interface (the edit form, the page management form) preserves the title-id relationship. But other interfaces like the ZMI, the CMF/Plone content management interface, ftp/webdav etc, allow you to break the rule and set the page's id to anything. This does no serious harm, but causes things like: (a) wiki links to that page not working, until (b) zwiki changes the id next time the page is viewed; (c) contents view being out of sync, until you visit PAGE/updatecontents; and (d) confusion for the user. So to avoid the latter, it's best to use Zwiki's own interface for managing wiki pages.



Work needed