Introspector tab fails on utility

Bug #97894 reported by Guido van Rossum
2
Affects Status Importance Assigned to Milestone
Zope 3
Fix Released
Medium
Steve Alexander

Bug Description

This is a bit complicated to set up. Using a clean Data.fs:

- In products.zcml, add this line:
  <include package="zopeproducts.demo.utility" />

- In the site manager, add and activate a
  Utility Service.

- In the default package, add a
  Demo Utility. Name it e.g. "hello"

- Now on the resulting screen (with the URL
  /++etc++site/default/hello/@@useConfiguration.html)
  click the Introspector tab.

This gets a ForbiddenAttribute error.

All I can figure out is that it is trying to get
the __name__ attribute of a classic class;
I don't know which class.

Tags: bug core
Revision history for this message
Steve Alexander (stevea) wrote :

I expect the problem concerns the DemoUtility class, which is a classic class.

Revision history for this message
Steve Alexander (stevea) wrote :

I've reproduced this.

The checker being selected for the DemoUtility class is the same checker that is used for a DemoUtility instance.

The only name allowed is 'greet', from IDemoUtility.

Revision history for this message
Guido van Rossum (gvanrossum) wrote :

So now what do we do about this?

Revision history for this message
Steve Alexander (stevea) wrote :

I'm working out why it is happening.

Revision history for this message
Steve Alexander (stevea) wrote :

Status: Pending => Resolved

I'm about to check in a fix to this.

For some reason, ClassType class objects were being checked using the _classChecker function to create a checker. This function does not seem to be used elsewhere, and appears to be inappropriate for checking classic classes.

I've changed it so that we use the _typeChecker for classic classes. This is the same checker that is used for type objects.

Perhaps there was a reason the _classChecker was used instead. There is some odd code in _classChecker that leaves Exception class objects unwrapped. Why is this needed? Only exception instances need to remain unwrapped.

Revision history for this message
Guido van Rossum (gvanrossum) wrote :

Um, I think exception class objects need to remain unwrapped because
otherwise code like this:

  try: ...something...
  except <exceptionclass>: ...handler...

won't work; if the exception class is a proxy the except clause
will be ignored.

Revision history for this message
Steve Alexander (stevea) wrote :

Ok, I'll fix this first thing tomorrow.

Revision history for this message
Steve Alexander (stevea) wrote :

Status: Resolved => Pending

I'm reverting my checkin for now. I'll produce a better fix and test tomorrow.

Revision history for this message
Steve Alexander (stevea) wrote :

Status: Pending => Accepted

 Supporters added: stevea

Thinking about this more, if exception instances are never wrapped, it doesn't matter whether exception classes are wrapped by policy or not, as they'll be used inline in the code in except: clauses.

Are there any other times when exception classes are used, where they might get wrapped with some kind of wrapper?

Revision history for this message
Guido van Rossum (gvanrossum) wrote :

I don't know enough about when things get wrapped to answer that.
When restricted code (maybe TTW code) imports a Zope exception,
are we sure those exceptions never get wrapped?

Revision history for this message
Steve Alexander (stevea) wrote :

Status: Accepted => Resolved

Fixed.

All classic classes other than Exception subclasses now use _typeChecker.

I'm convinced that the lookup of a checker for the class was a mistake.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.