[Zope-CMF] Problem after invokeFactory
boydrobh at yahoo.com
Wed Feb 2 14:18:14 EST 2005
--- Chris Withers <chris at simplistix.co.uk> wrote:
> Rob Boyd wrote:
> > # From foo_add_control.py
> > try:
> > context.invokeFactory('Foo', id, context.REQUEST.RESPONSE)
> > # It no longer gets to here, but it used to!
> You'r passing the response object, maybe a redirect is being raised
> as a
> result? try NOT passing the response object and see what happens...
Nope, wasn't it.
> > # Tested with: raise "Just added a new foo" but no exception
> it wouldn't, 'cos you swallow it further down, d'oh!
> > except:
> > return context.setStatus(False, 'Could not add Foo %s' % id )
> why why why do people feel the need to wrap things in global
> try/excepts?! All this does is mask errors that you want to know
> and might even cause ZODB corruption if you're really unlucky...
> (google for try except and conflict error)
Thank you, this is exactly was was happening - masking an error. My
form creates an object, then edits it, all within the try/except. And
the edit method had recently been modified (and broken). Why the
try/except? I was modeling my form scripts on the CMF 1.5 style of
control scripts, but not as savvy. After switching to:
except ResourceLockedError, errmsg:
return context.setStatus(False, errmsg)
The edit error percolated up, instead of being hidden. Thanks again!
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
More information about the Zope-CMF