I tried to insert data using an zsql, insert fine How manage error with zsql.
Before
<dtml-try>
   <dtml-call insert_data>
   Data inserted!!!
<dtml-except>
   Error type:<dtml-var error_type>
   Error type:<dtml-var error_value>
</dtml-try>



Now (All files are ZPT)

[index_html]
...
<form action="proyecto_alta.html">
    <input type="text" name="field1" id="field1" />
    ...
    <input type="text" name="field2" id="field2" />
</form>


[proyecto_alta.html]
<div tal:on-error="structure here/error_insertar">
       tal:condition="context/insert_data.zsql"
       tal:content="string: Data inserted!!!">

</div>


[error_insertar]
error=_['error']
if error.type==ZeroDivisionError:
    return "<p>Can't divide by zero.</p>"
else:
    return """<p>An error ocurred.</p>
              <p>Error type: %s</p>
              <p>Error value: %s</p>""" % (error.type,
                                           error.value)


But say

Tipo Unauthorized
Valor You are not allowed to access 'type' in this context
TraceBack

Traceback (innermost last):

  • Module ZPublisher.Publish, line 119, in publish
  • Module ZPublisher.mapply, line 88, in mapply
  • Module ZPublisher.Publish, line 42, in call_object
  • Module Shared.DC.Scripts.Bindings, line 313, in __call__
  • Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  • Module Products.PageTemplates.ZopePageTemplate, line 330, in _exec
  • Module Products.PageTemplates.ZopePageTemplate, line 427, in pt_render
  • Module Products.PageTemplates.PageTemplate, line 96, in pt_render
  • Module zope.pagetemplate.pagetemplate, line 115, in pt_render
  • Module zope.tal.talinterpreter, line 271, in __call__
  • Module zope.tal.talinterpreter, line 346, in interpret
  • Module zope.tal.talinterpreter, line 981, in do_onError_tal
  • Module zope.tal.talinterpreter, line 346, in interpret
  • Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal
  • Module Products.PageTemplates.Expressions, line 199, in evaluateStructure
  • Module zope.tales.tales, line 696, in evaluate
    URL: /ceed/finanza/proyecto/proyecto_alta.html
    Line 1, Column 0
    Expression: <PathExpr standard:u'here/error_insertar'>
    Names:
    {'container': <Folder at /ceed/finanza/proyecto>,
    'context': <Folder at /ceed/finanza/proyecto>,
    'default': <object object at 0x0075A528>,
    'here': <Folder at /ceed/finanza/proyecto>,
    'loop': {},
    'nothing': None,
    'options': {'args': ()},
    'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x02382828>,
    'request': <HTTPRequest, URL=http://sic/finanza/proyecto/proyecto_alta.html>,
    'root': <Application at >,
    'template': <ZopePageTemplate at /ceed/finanza/proyecto/proyecto_alta.html>,
    'traverse_subpath': [],
    'user': <User 'admin'>}
  • Module zope.tales.expressions, line 217, in __call__
  • Module Products.PageTemplates.Expressions, line 139, in _eval
  • Module Products.PageTemplates.Expressions, line 91, in render
  • Module Products.PageTemplates.ZRPythonExpr, line 79, in call_with_ns
  • Module Shared.DC.Scripts.Bindings, line 327, in __render_with_namespace__
  • Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  • Module Products.PythonScripts.PythonScript, line 327, in _exec
  • Module None, line 2, in error_insertar
    <PythonScript at /ceed/finanza/proyecto/error_insertar>
    Line 2
Unauthorized: You are not allowed to access 'type' in this context


(Example taked from http://www.plope.com/Books/2_7Edition/AppendixC.stx#2-28)


--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida