[Zope-dev] Re: error adding specialist

Phillip J. Eby pje@telecommunity.com
Tue, 11 Jul 2000 09:13:48 -0500


I found this one on Saturday.  The problem is that Zope recently changed
the way constructors bind to their factory objects, and the "self" that
ZPatterns is providing to the constructors is no longer needed.  I've
changed ZPatterns to fix this (still maintaining 2.1.x compatibility in the
process) and a few other reported and unreported bugs, but haven't had time
to issue a new release just yet.  I'm up to my neck in "regular job" work
for the next few days.  Hopefully I'll have a release out before the
ZPatterns chat Friday, though.

At 01:36 PM 7/11/00 +0100, Steve Alexander wrote:
>I've come across an error on trying to add a Specialist.
>
>Zope 2.2b4, ZPatterns latest release (ZPatterns-0-4-0a1).
>
>Go to the zope management pages, as a Manager.
>Choose to add a Specialist.
>Leave the "Create Default Rack of type" drop-down set to "Rack".
>Put in an appropiate id, such as "test".
>Press "Add".
>
>We get a Zope error:
>
>  Error Type: TypeError
>  Error Value: keyword parameter redefined
>
>
>Traceback (innermost last):
>  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
>222, in publish_module
>  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
>187, in publish
>  File /usr/local/zope/SiteBox/lib/python/Zope/__init__.py, line 221, in
>zpublisher_exception_hook
>  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
>171, in publish
>  File /usr/local/zope/SiteBox/lib/python/ZPublisher/mapply.py, line
>160, in mapply
>    (Object: manage_addSpecialist)
>  File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line
>112, in call_object
>    (Object: manage_addSpecialist)
>  File
>/usr/local/zope/SiteBox/lib/python/Products/ZPatterns/Specialists.py,
>line 71, in manage_addSpecialist
>  File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/PlugIns.py,
>line 436, in _constructPlugIn
>TypeError: (see above)
>
>
>
>The error occurs because the _constructPlugIn() method of PlugIns.py
>attempts to give "id" to manage_addRack as a keyword argument, whereas
>it has already been given the id as a positional argument. Actually, I
>think what it is being given as an id is wrong too :-)
>
>The offending line is 436:
>  
>  return apply(getattr(product, method), (product,)+args, kwargs)
>
>
>
>The rest of this is mainly for my benefit, and will be obvious to anyone
>familiar with the code :-)
>
>
>"getattr(product, method)" evaluates to the python method
>manage_addRack, and it appears to be a bound method.
>
>"product" is a __FactoryDispatcher__ instance.
>
>"args" is None, or ().
>
>"kwargs" is {'id': 'defaultRack'}.
>
>The signature of manage_addRack() is:
>
>  def manage_addRack(self, id, title='', REQUEST=None):
>
>and is effectively getting called as:
>
>  instance.manage_addRack(some __FactoryDispatcher__, id='defaultRack')
>
>I'm not sure whether the method intended to get an unbound method rather
>than a bound one, or whether "id" needs special handling here.
>
>--
>Steve Alexander
>Software Engineer
>Cat-Box limited
>http://www.cat-box.net
>