<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style>.EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }</style>
</head>
<body>
<font face="Courier New, monospace" size="2">
<div>Hi,</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>First of all, thank you Grok and ZOPE developers for a wonderfull web framework.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>I am finishing my first web project with Grok.</div>
<div>But i have one problem with customized exception views.</div>
<div>I created a custom view “Unauthorized” for exception “IUnauthorized”:</div>
<div> </div>
<div>class Unauthorized(grok.View):</div>
<div> grok.context(IUnauthorized)</div>
<div> grok.name('index.html')</div>
<div> </div>
<div> def update(self):</div>
<div> …</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>For that view I created template, in that template I use something like that (please note “${view/application_url}”): </div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div> <a i18n:translate="" tal:attributes="href string:${view/application_url}/offers?offertype=sale&realtytype=apartment">sale</a></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>When I try to browse grok administrator at url <a href="http://localhost:8080"><font color="#0000FF"><u>http://localhost:8080</u></font></a> to create application instance, the following page is rendered in browser:</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>>>></div>
<div style="margin-top: 5pt; margin-bottom: 5pt; "><font face="Times New Roman, serif" size="5"><b><class 'zope.security.interfaces.Unauthorized'></b></font></div>
<div><font face="Times New Roman, serif" size="3">A server error occurred.</font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><<<</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>And following exception is thrown, (copy-paste from console output):</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>>>></div>
<div> 2008-03-31T14:11:39 ERROR SiteError Exception while rendering view on exception</div>
<div> ...</div>
<div> <FILES IN STACK TRACE></div>
<div> ...</div>
<div> File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\tales.py", line 696, in evaluate</div>
<div> return expression(self)</div>
<div> - d:\src\klucsiteenv\klucsite\src\klucsite\app_templates\unauthorized.pt</div>
<div> - Line 20, Column 6</div>
<div> - Expression: <StringExpr u'${view/application_url}/offers?offertype=sale&realtytype=apartment'></div>
<div> - Names:</div>
<div> {'args': (),</div>
<div> 'context': <zope.app.folder.folder.Folder object at 0x0208C2F0>,</div>
<div> 'default': <object object at 0x00A705E8>,</div>
<div> 'loop': {},</div>
<div> 'nothing': None,</div>
<div> 'options': {},</div>
<div> 'repeat': {},</div>
<div> 'request': <zc.resourcelibrary.publication.Request instance URL=http://localhost:8080/favicon.ico>,</div>
<div> 'static': <grok.components.DirectoryResource object at 0x02F8D4B0>,</div>
<div> 'template': <grok.components.TrustedFilePageTemplate object at 0x02E7D310>,</div>
<div> 'view': <klucsite.app.NotFound object at 0x02F8D3F0>}</div>
<div> File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 261, in __call__</div>
<div> v = var(econtext)</div>
<div> File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 217, in __call__</div>
<div> return self._eval(econtext)</div>
<div> File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 211, in _eval</div>
<div> return ob()</div>
<div> File "d:\src\klucsiteenv\klucsite\buildout-eggs\grok-0.11.1-py2.5.egg\grok\components.py", line 186, in application_url</div>
<div> raise ValueError("No application found.")</div>
<div>ValueError: No application found.</div>
<div><<<</div>
<div> </div>
<div>As I understand, the exception of type “IUnauthorized” is thrown. Then my custom view for that exception is evaluated and failed on path expression: ${view/application_url}/offers?offertype=sale&realtytype=apartment. I discovered that exception with value
“ValueError: No application found.” is rased in function application_url(). I understand that there is no application created, but I can not create one, if I can not login to Grok administrator. I understand that this is because my custom exception view somehow
replaced default view that popups login form.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>Please can someone tell me how to properly use custom exception views ?</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>Thank in advance for any help,</div>
<div>Roman Lacko</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
</body>
</html>