1. fanstatic
  2. fanstatic
  3. fanstatic
  4. Issues
Issue #33 resolved

NeededResources and error handling

Jan-Jaap Driessen
created an issue

In grok (and potentially other frameworks working with fanstatic), if an error occurs during the handling of a request, the current NeededResources is not reset.

As a result, the NeededResources are injected in the error page which is generated by grok.

One way to fix this is to look for an event to hook into, like we do in zope.fanstatic for setting the base_url at the end of the request, but unfortunately there is no //i-am-now-going-to-render-an-error-view// event defined nor fired by the publication process.

One option I see is to reset the NeededResources at the beginning of rendering the error page. This should be the responsibility of the zope.fanstatic, megrok.fanstatic package or integrated into grok. Doing this would introduce a hard dependency on fanstatic in grok, but this discussion is not part of the fanstatic package.

Another option would be to move exception handling out of grok into a WSGI component. I personally wouldn't like that, as in my applications we share code between regular views and exception views.

Should fanstatic supply infrastructure for resetting the NeededResources? We could add a //clear// method to the NeededResources class.

What do you think? Do you see another option of resetting the NeededResources on handling errors during a request cycle?

Comments (3)

  1. faassen

    I think a clear option is one option and low-hanging fruit we should add right away.

    Another option would be to reinitialize the resources entirely, but that would require reinitializing the NeededResources object with its configuration, so that looks more complicated unless we can come up with a clean way to do it.

  2. Log in to comment