[Zope3-dev] Need help with JobBoardEx

Guido van Rossum guido@python.org
Tue, 06 Aug 2002 22:31:35 -0400


> I looked into this a bit.  A few notes and thoughts.

Thanks!

> 1) the IFactory interface almost certainly should not have the
> getInterfaces method requirement.  This is cruft (that I think I added
> way back when) from the old factoryFromClass and Addables stuff, and
> probably should be removed.
> 
> 2) the IFactory interface apparently should not have the __call__ method
> requirement.  What we really want is an interface specifying that
> calling the factory will return a new object, whether the factory is a
> class or any other kind of object.  However, requiring __call__ does not
> accomplish this, and I can't think of anything that would, so removing
> it seems the right course.  This would leave the IFactory interface to
> be a marker interface, with no attributes or methods: is this even
> useful, or can we just remove any kind of error checking here?

Are you sure?  I think this is asserting the interface on the class
viewed as an object, not on the instances of its class.  Certainly any
object that wants to be a factor has to be callable, and __call__ is
the right way to ask for it.

I'm curious if the security proxies are confounding stuff.  Maybe the
Image factory is somehow wrapped in a security proxy and the JobList
class isn't, or the other way around.  (But how???)

> 3) Note this interesting interactive Python output:
> 
> >>> verifyObject(IFactory, Image)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/home/gposter/Zope3/lib/python/Interface/Verify.py", line 72, in
> verifyObject
>     return _verify(iface, candidate, tentative, vtype='o')
>   File "/home/gposter/Zope3/lib/python/Interface/Verify.py", line 44, in
> _verify    raise DoesNotImplement(iface)
> Interface.Exceptions.DoesNotImplement: An object does not implement
> interface <Interface Zope.ComponentArchitecture.IFactory.IFactory at
> 4022edac>
> 
> That is, Image in fact creates the same exception that JobList does. 
> This might imply that the built-in factories are not running through the
> full verification process to which JobList was (correctly) submitted.

No, this is *not* the same exception I get.  I get:

  BrokenImplementation: An object has failed to implement interface <Interface Zope.ComponentArchitecture.IFactory.IFactory at 404cb0cc>

	  The __call__ attribute was not provided.

> In any case, if I make IFactory into a simple "class
> IFactory(Interface): pass" statement, the JobList is on my add content
> list, which is as far as I went.  I believe this is in fact the correct
> resolution.  However, I'm not checking this in, because this is just my
> take on things.

That's not very different from my hack of commenting out the
verifyObject() call.  Once the JobList is on the add list,
everything's hunky dory (at least for me).

--Guido van Rossum (home page: http://www.python.org/~guido/)