a featureful wiki engine based on Zope 2 (http://zwiki.org/DarcsRepos)

root / content / basic / standard_error_message.dtml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<dtml-if "error_type=='NotFound'">
<dtml-comment>
A custom error handler for 404 NotFound errors (only). Redirects to a
similarly-named existing page if possible, otherwise offers create/search
buttons.  

Assumes at least one zwiki page exists. It doesn't matter which one we
work from, except created pages will go under it. picks SandBox if
available, to reduce mail noise from test pages.
</dtml-comment>
<dtml-let 
 here="objectValues(spec='ZWiki Page')[0]"
 here="here.defaultPage()
       #here.pageWithName('SandBox') or here.defaultPage()
       #created pages will go under this working page
       #if you want less mail from pages created this way, pick SandBox"
 path="URL[_.len(SERVER_URL):]"
 searchexpr="_.string.split(path,'/')[-1]"
 targetpage="here.pageWithFuzzyName(searchexpr,url_quoted=1,
                                    allow_partial=1,ignore_case=1) or
             here.pageWithId(searchexpr,ignore_case=1)"
 targeturl="(targetpage and targetpage.pageUrl()) or None"
 >
<dtml-if targeturl>
  <dtml-call "RESPONSE.redirect(targeturl,lock=1)">

<dtml-else>
<html>
  <head><meta name="robots" content="noindex,nofollow"></head>
  <body>
    <p>
      I could not find any likely page matching "<b><dtml-var
      "here.urlunquote(searchexpr)" html_quote></b>"
    </p>
    <p>
      Click here to 
      <form action="<dtml-var "here.pageUrl()">/createform"
            method="GET" enctype="multipart/form-data">
        <input type="hidden" name="page" value="&dtml-searchexpr;">
        <input type="submit" value="create this page">
      </form>
      <form action="<dtml-var "here.searchUrl()">"
            method="GET" enctype="multipart/form-data">
        <input type="hidden" name="expr" value="&dtml-searchexpr;">
        <input type="submit" value="search for it">
      </form>
      or visit the <a href="&dtml-URL1;">front page</a>.
    </p>
  </body>
</html>
</dtml-if>
</dtml-let>
<dtml-else>
<dtml-if "_.hasattr(aq_parent,'standard_error_message')">
<dtml-with aq_parent><dtml-var standard_error_message></dtml-with>
</dtml-if>
</dtml-if>