Re: [Zope-dev] bare exceptions
Leonardo Rochael Almeida wrote: > I'm testing a fix for the TALES case along the lines of what Casey > sugested and will report back with results. Leo, This is a good thing to work on but you really should work on the trunk. The TALES exception handling was redone after Zope 2.5. Exceptions don't get transformed into TALESErrors any more. The line and column number appear in custom-formatted tracebacks. The _nocatch mechanism is brittle, but maybe it's all we can get for now. This problem of catching all errors, including ConflictErrors, is quite deep, since even untrusted Python scripts are allowed to do this. Here's an idea: if a conflict (read or write) occurs in a connection, that connection turns read-only until the next transaction boundary. If the application tries to write using it, ZODB raises another ConflictError. I wonder if that policy would work. Shane ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] bare exceptions
On Fri, 2002-10-04 at 17:58, Leonardo Rochael Almeida wrote: > On Fri, 2002-10-04 at 16:37, Leonardo Rochael Almeida wrote: > > > > I'm testing a fix for the TALES case along the lines of what Casey > > sugested and will report back with results. > > > > And here it is. [...] > BTW, the _nocatch that I patched had literal string 'Redirect' in it. Now considering that exception catching is done by the 'is' operator (or by isinstance(), in case of object instances) isn't it possible, or even likely that the 'except self._nocatch:' in PageTemplates/TALES.py wouldn't be able to catch other 'Redirect's? > --- lib/python/Products/PageTemplates/Expressions.py-orig 2002-10-04 >17:26:31.0 + > +++ lib/python/Products/PageTemplates/Expressions.py2002-10-04 >17:26:38.0 + > @@ -24,6 +24,7 @@ > TALESError, Undefined, Default, _parse_expr > from string import strip, split, join, replace, lstrip > from Acquisition import aq_base, aq_inner, aq_parent > +from ZODB.POSException import ConflictError > > > _engine = None > @@ -33,7 +34,7 @@ > from PathIterator import Iterator > _engine = Engine(Iterator) > installHandlers(_engine) > -_engine._nocatch = (TALESError, 'Redirect') > +_engine._nocatch = (TALESError, 'Redirect', ConflictError) > return _engine > > def installHandlers(engine): -- Ideas don't stay in some minds very long because they don't like solitary confinement. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] bare exceptions
On Fri, 2002-10-04 at 16:37, Leonardo Rochael Almeida wrote: > > I'm testing a fix for the TALES case along the lines of what Casey > sugested and will report back with results. > And here it is. TALES actually had a slot for my change, go figure :-) as for PluginIndex/common/UnIndex.py, I'd like to propose the following rule, before I attempt a fix: No bare 'except:' shall silently ingore it's exception and proceed. Outside of ZPublisher, any bare 'except:' MUST raise either the original exception or another one. Inside of ZPublisher it's too dark to read. What do you think? Cheers, Leo PS: in PageTemplates/TALES.py there's another bare 'except:' in the Iterator class, I suggest it be changed to include a self._nocatch mechanism just like the Context class in that same file. What do you think? -- Ideas don't stay in some minds very long because they don't like solitary confinement. --- lib/python/Products/PageTemplates/Expressions.py-orig 2002-10-04 17:26:31.0 + +++ lib/python/Products/PageTemplates/Expressions.py2002-10-04 17:26:38.0 ++ @@ -24,6 +24,7 @@ TALESError, Undefined, Default, _parse_expr from string import strip, split, join, replace, lstrip from Acquisition import aq_base, aq_inner, aq_parent +from ZODB.POSException import ConflictError _engine = None @@ -33,7 +34,7 @@ from PathIterator import Iterator _engine = Engine(Iterator) installHandlers(_engine) -_engine._nocatch = (TALESError, 'Redirect') +_engine._nocatch = (TALESError, 'Redirect', ConflictError) return _engine def installHandlers(engine):