Re: [Zope] help with customizing error messages, Zope 2.9
Dennis Allison wrote at 2007-9-20 09:37 -0700: > ... >standard_error_message should be acquired. It should be possible for >there to be multiple copies with the particular one to be used selected by >acquisition. This does not appear to be the case for some errors in my >configuration, but I am not sure why. You are right -- and I can explain why. >There appears to be nothing in the Zope 2.9 zope.conf file that has to do >with catching error messages. Is there some configuration that is >missing to enable full custom error messages. > >Looking at the code: > >ZPublisher/HTTPResponse.py seems to have a complete set of error >responses hard-wired with outputs that mimic those of the default >standard_error_message. > >OFS/SimpleItem.py includes a method called raise_standardErrorMessage >which first acquires and then publishes the standard_error_message. > >Zope2/App/startup.py has a method, zpublisher_exception_hook which >uses raise_standardErrorMessage and is referenced in ZPublisher/Publish.py >where it is used to set error_hook, but error_hook does not appear to be >used. > >It would be helpful to me if someone who understands how this particular >code works could provide some hints as to what's needed to fully customize >the error message responses. We start with ZPublisher. It is this component that catches the exception and activate error handling. ZPublisher was designed as a general publication component -- to be used not only for "Zope". Therefore, it has neither error handling nor transaction handling nor a few other things hard coded. Instead, it gets a module name and determines the relevant pieces by a call to "ZPublisher.Publish.get_module_info(module_name)". When "ZPublisher" is used for Zope, then "module_name" is "Zope2". "Zope2" defines "Zope2.zpublisher_exception_hook" as its exception hook (which does the error handling). The true "zpublisher_exception_hook" is defined (as you found out) in "Zope2.App.startup" and copied to "Zope2" by the "_startup" call. When ZPublisher catches an exception, it calls the error hook with "parents[0]" (the last or second to last object traversed to), the request and the error information. "zpublisher_exception_hook" then looks in the acquisition context of "parents[0]" for 'raise_standardErrorMessage' and 'standard_error_message'. If either of them is not found, the exception is raised -- and handled by the response object in a standard (minimal) way. Otherwise, 'raise_standardErrorMessage(standard_error_message, ...)' is called. The problem which sometimes causes surprises with respect to the used 'standard_error_message' lies in "parents[0]": When the exception happens during traversal, then "parents[0]" is not the object you may expect -- but lies above the expected object. The problem is especially bad when the exception is raised by "request.processInputs". In this case, the traversal did not even start and "parents[0]" is the root object. Consequently, for these exceptions, you will always get the "standard_error_message" from your root folder -- even when the request was targeted to some object deep inside your site. "processInputs" may raise exceptions when you use e.g. ZPublisher type conversions, e.g. ":int" or ":float" and the provided value cannot be converted. If you do not like this, you should not use ZPublisher type conversions. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Re: How to know what are zope doing now?
I supposed that but any ZopeProfiler objects appears on my Control_Panel Any suggestion? Thanks! 2007/9/21, Dieter Maurer <[EMAIL PROTECTED]>: > > Garito wrote at 2007-9-20 20:51 +0200: > >I would like to try it but I put it on my instance's Products, restart > zope > >and... nothing > > > >I have Ubuntu Fesity + Zope 2.9.6 (the apt-get version) > > > >What is supposed I could find about it in my ZMI? > > "ZopeProfiler" installs itself in "Control_Panel". > > It is a singleton. No need and no sense to install it anywhere else. > Therefore, it does not add itself to the "Add list". > > > > -- > Dieter > -- Mis Cosas http://blogs.sistes.net/Garito ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler:does its installation have a performance impact?
robert rottermann wrote at 2007-9-21 09:11 +0200: >does the installation of ZopeProfiler have a noticable performance >impact when it is disabled? No. "ZopeProfiler" monkey patches "ZPublisher.publish_module" with the following function: def _profilePublishModule( module_name, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, environ=environ, debug=0, request=None, response=None ): lock= _lock # to facilitate refreshing psrc= request or environ; path= psrc.get('PATH_INFO') if _enabled and _doProfile(path): ... code only executed when the profiler is enabled ... else: result= publish_module( module_name, stdin=stdin, stdout=stdout, stderr=stderr, environ=environ, debug=debug, request=request, response=response) return result As you can see: The overhead when "ZopeProfiler" is disabled is * an extra function call * 3 assignments * a request lookup * a boolean check In total: negligable compared to what the ZPublisher (not speaking about Zope at all) is doing otherwise. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Re: How to know what are zope doing now?
Garito wrote at 2007-9-20 20:51 +0200: >I would like to try it but I put it on my instance's Products, restart zope >and... nothing > >I have Ubuntu Fesity + Zope 2.9.6 (the apt-get version) > >What is supposed I could find about it in my ZMI? "ZopeProfiler" installs itself in "Control_Panel". It is a singleton. No need and no sense to install it anywhere else. Therefore, it does not add itself to the "Add list". -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] ZopeProfiler:does its installation have a performance impact?
--On 21. September 2007 09:11:11 +0200 robert rottermann <[EMAIL PROTECTED]> wrote: Hi there, does the installation of ZopeProfiler have a noticable performance impact when it is disabled? No -aj pgp8PEoL3qUyk.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] ZopeProfiler:does its installation have a performance impact?
Hi there, does the installation of ZopeProfiler have a noticable performance impact when it is disabled? thanks robert begin:vcard fn:Robert Rottermann n: Rottermann;Robert email;internet:[EMAIL PROTECTED] tel;work:++41 31 333 10 20 tel;fax:++41 31 333 10 23 tel;home:++41 31 333 36 03 x-mozilla-html:FALSE version:2.1 end:vcard ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )