I tried to insert data using an zsql, insert fine How manage error with zsql. <br>Before <br><dtml-try><br> <dtml-call insert_data><br> Data inserted!!!<br><dtml-except><br> Error type:<dtml-var error_type><br>
Error type:<dtml-var error_value><br>
</dtml-try><br><br><br><br>Now (All files are ZPT)<br><br>[index_html]<br>...<br><form action="proyecto_alta.html"><br> <input type="text" name="field1" id="field1" /><br>
...<br> <input type="text" name="field2" id="field2" /><br></form><br><br><br>[proyecto_alta.html]<br><div tal:on-error="structure here/error_insertar"><br>
tal:condition="context/insert_data.zsql"<br> tal:content="string: Data inserted!!!"><br><div id=":1t3" class="ArwC7c ckChnd"> <br></div><br></div><br><br>[error_insertar]<br>error=_['error']<br>
if error.type==ZeroDivisionError:<br> return "<p>Can't divide by zero.</p>"<br>else:<br> return """<p>An error ocurred.</p><br> <p>Error type: %s</p><br>
<p>Error value: %s</p>""" % (error.type,<br> error.value)<br>
<br><br clear="all">But say<br><div id=":1t3" class="ArwC7c ckChnd"><font color="#888888"><br></font><table border="1"><tbody><tr><th>Tipo</th> <td>Unauthorized</td>
</tr>
<tr>
<th>Valor</th> <td>You are not allowed to access 'type' in this context</td>
</tr>
<tr>
<th>TraceBack</th> <td><p>Traceback (innermost last):
</p><ul><li> Module ZPublisher.Publish, line 119, in publish</li><li> Module ZPublisher.mapply, line 88, in mapply</li><li> Module ZPublisher.Publish, line 42, in call_object</li><li> Module Shared.DC.Scripts.Bindings, line 313, in __call__</li>
<li> Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec</li><li> Module Products.PageTemplates.ZopePageTemplate, line 330, in _exec</li><li> Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render</li>
<li> Module Products.PageTemplates.PageTemplate, line 96, in pt_render</li><li> Module zope.pagetemplate.pagetemplate, line 115, in pt_render</li><li> Module zope.tal.talinterpreter, line 271, in __call__</li><li> Module zope.tal.talinterpreter, line 346, in interpret</li>
<li> Module zope.tal.talinterpreter, line 981, in do_onError_tal</li><li> Module zope.tal.talinterpreter, line 346, in interpret</li><li> Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal</li><li> Module Products.PageTemplates.Expressions, line 199, in evaluateStructure</li>
<li> Module zope.tales.tales, line 696, in evaluate<br>
<b>URL: /ceed/finanza/proyecto/proyecto_alta.html</b><br>
<b>Line 1, Column 0</b><br>
<b>Expression: <PathExpr standard:u'here/error_insertar'></b><br>
<b>Names:</b><pre>{'container': <Folder at /ceed/finanza/proyecto>,<br> 'context': <Folder at /ceed/finanza/proyecto>,<br> 'default': <object object at 0x0075A528>,<br> 'here': <Folder at /ceed/finanza/proyecto>,<br>
'loop': {},<br> 'nothing': None,<br> 'options': {'args': ()},<br> 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x02382828>,<br> 'request': <HTTPRequest, URL=<a href="http://sic/finanza/proyecto/proyecto_alta.html">http://sic/finanza/proyecto/proyecto_alta.html</a>>,<br>
'root': <Application at >,<br> 'template': <ZopePageTemplate at /ceed/finanza/proyecto/proyecto_alta.html>,<br> 'traverse_subpath': [],<br> 'user': <User 'admin'>}</pre>
</li><li> Module zope.tales.expressions, line 217, in __call__</li><li> Module Products.PageTemplates.Expressions, line 139, in _eval</li><li> Module Products.PageTemplates.Expressions, line 91, in render</li><li> Module Products.PageTemplates.ZRPythonExpr, line 79, in call_with_ns</li>
<li> Module Shared.DC.Scripts.Bindings, line 327, in __render_with_namespace__</li><li> Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec</li><li> Module Products.PythonScripts.PythonScript, line 327, in _exec</li>
<li> Module None, line 2, in error_insertar<br>
<b><PythonScript at /ceed/finanza/proyecto/error_insertar></b><br>
<b>Line 2</b></li></ul>Unauthorized: You are not allowed to access 'type' in this context
</td></tr></tbody></table><br></div><br><a href="http://www.plope.com/Books/2_7Edition/AppendixC.stx#2-28" target="_blank">(Example taked from http://www.plope.com/Books/2_7Edition/AppendixC.stx#2-28</a>)<br>
<font color="#888888"><br></font><br>-- <br>________________________________________<br>Lo bueno de vivir un dia mas<br>es saber que nos queda un dia menos de vida<br>