[Zope-dev] PlugIns.py bug.... (was incorrectly ZPatterns: transaction bug)
Steve Spicklemire
steve@spvi.com
Tue, 5 Sep 2000 08:46:13 -0500 (EST)
OK I think I found the actual intent of aq_base() in _checkId of PlugIns.py:
if hasattr(aq_base(self), id):
# The object is located in this ObjectManager.
if not flags & REPLACEABLE:
raise 'Bad Request', ('The id "%s" is invalid - ' \
'it is already in use.' % id)
# else the object is replaceable even if the UNIQUE
# flag is set.
elif flags & UNIQUE:
raise 'Bad Request', \
('The id "%s" is reserved.' % id)
it comes from the ObjectManager _checkId which has basically the same
code execpt it ObjectManager.py also has the needed:
from Acquisition import aq_base
which PlugIns.py does not.. so looking at Acquisition.c it appears
that there is no real difference between
hasattr(aq_base(self), id)
which calls
if (WRAPPER(self)->obj)
{
r=WRAPPER(self)->obj;
while (isWrapper(r) && WRAPPER(r)->obj) r=WRAPPER(r)->obj;
}
else r=Py_None;
Py_INCREF(r);
return r;
and hasattr( self.aq_base, id) which calls
case 'b':
if (strcmp(name,"base")==0)
{
if (self->obj)
{
r=self->obj;
while (isWrapper(r) && WRAPPER(r)->obj) r=WRAPPER(r)->obj;
}
else r=Py_None;
Py_INCREF(r);
return r;
}
break;
Anyway.. it looks like either fix is OK... I guess!
-steve
>>>>> "Steve" == Steve Spicklemire <steve@spvi.com> writes:
Steve> ZPatterns 0.4.2a1 PlugIns.py bug?
Steve> I get a 'Name Error' aq_base when I hit the following code
Steve> while trying to update the index_html method of one of my
Steve> Specialists from CVSMixin.. I think that this would get hit
Steve> anytime you add an object whose id is already in the
Steve> acquisition path....
Steve> -steve
Steve> diff -c -r1.1.1.2 PlugIns.py *** PlugIns.py 2000/09/04
Steve> 14:17:29 1.1.1.2 --- PlugIns.py 2000/09/04 18:53:17
Steve> *************** *** 265,271 **** # An object by the given
Steve> id exists either in this # ObjectManager or in the
Steve> acquisition path. flags = getattr(obj, '__replaceable__',
Steve> NOT_REPLACEABLE) ! if hasattr(aq_base(self), id): # The
Steve> object is located in this ObjectManager. if not flags &
Steve> REPLACEABLE: raise 'Bad Request', ('The id "%s" is invalid
Steve> - ' \ --- 265,271 ---- # An object by the given id exists
Steve> either in this # ObjectManager or in the acquisition path.
Steve> flags = getattr(obj, '__replaceable__', NOT_REPLACEABLE) !
Steve> if hasattr(self.aq_base, id): # The object is located in
Steve> this ObjectManager. if not flags & REPLACEABLE: raise 'Bad
Steve> Request', ('The id "%s" is invalid - ' \
Steve> _______________________________________________ Zope-Dev
Steve> maillist - Zope-Dev@zope.org
Steve> http://lists.zope.org/mailman/listinfo/zope-dev ** No cross
Steve> posts or HTML encoding! ** (Related lists -
Steve> http://lists.zope.org/mailman/listinfo/zope-announce
Steve> http://lists.zope.org/mailman/listinfo/zope )