[Grok-dev] Custom Exception Views and application_url
Lacko Roman
rlacko at gratex.com
Mon Mar 31 08:32:25 EDT 2008
Hi,
First of all, thank you Grok and ZOPE developers for a wonderfull web framework.
I am finishing my first web project with Grok.
But i have one problem with customized exception views.
I created a custom view "Unauthorized" for exception "IUnauthorized":
class Unauthorized(grok.View):
grok.context(IUnauthorized)
grok.name('index.html')
def update(self):
...
For that view I created template, in that template I use something like that (please note "${view/application_url}"):
<a i18n:translate="" tal:attributes="href string:${view/application_url}/offers?offertype=sale&realtytype=apartment">sale</a>
When I try to browse grok administrator at url http://localhost:8080 to create application instance, the following page is rendered in browser:
>>>
<class 'zope.security.interfaces.Unauthorized'>
A server error occurred.
<<<
And following exception is thrown, (copy-paste from console output):
>>>
2008-03-31T14:11:39 ERROR SiteError Exception while rendering view on exception
...
<FILES IN STACK TRACE>
...
File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\tales.py", line 696, in evaluate
return expression(self)
- d:\src\klucsiteenv\klucsite\src\klucsite\app_templates\unauthorized.pt
- Line 20, Column 6
- Expression: <StringExpr u'${view/application_url}/offers?offertype=sale&realtytype=apartment'>
- Names:
{'args': (),
'context': <zope.app.folder.folder.Folder object at 0x0208C2F0>,
'default': <object object at 0x00A705E8>,
'loop': {},
'nothing': None,
'options': {},
'repeat': {},
'request': <zc.resourcelibrary.publication.Request instance URL=http://localhost:8080/favicon.ico>,
'static': <grok.components.DirectoryResource object at 0x02F8D4B0>,
'template': <grok.components.TrustedFilePageTemplate object at 0x02E7D310>,
'view': <klucsite.app.NotFound object at 0x02F8D3F0>}
File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 261, in __call__
v = var(econtext)
File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 217, in __call__
return self._eval(econtext)
File "d:\src\klucsiteenv\klucsite\buildout-eggs\zope.tales-3.4.0a1-py2.5.egg\zope\tales\expressions.py", line 211, in _eval
return ob()
File "d:\src\klucsiteenv\klucsite\buildout-eggs\grok-0.11.1-py2.5.egg\grok\components.py", line 186, in application_url
raise ValueError("No application found.")
ValueError: No application found.
<<<
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.
Please can someone tell me how to properly use custom exception views ?
Thank in advance for any help,
Roman Lacko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20080331/20cea5ea/attachment.htm
More information about the Grok-dev
mailing list