OFS.SimpleItem initialization problem: infinite loop
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Invalid
|
Low
|
Unassigned |
Bug Description
This is a Zope core bug discovered while doing a custom CMF content type.
I have a class that subclasses Product.
This class overloads __init__ with a dumb 2 line one.
When migrating from 2.6.3 to 2.7, the said CMF content type can't be viewed, showing the error:
>Zope Error
>Zope has encountered an error while publishing this resource.
>
>Error Type: RuntimeError
>Error Value: maximum recursion depth exceeded
> ...
>Module ZPublisher.Publish, line 94, in publish
>Module Zope.App.startup, line 257, in recordMetaData
>Module OFS.SimpleItem, line 333, in getPhysicalPath
>Module OFS.SimpleItem, line 76, in
>Module OFS.SimpleItem, line 310, in getId
>Module OFS.SimpleItem, line 76, in
>Module OFS.SimpleItem, line 310, in getId
>Module OFS.SimpleItem, line 76, in
>Module OFS.SimpleItem, line 310, in getId
> ...
An infinite loop !!
From Dieter:
>This is a bug in "OFS.SimpleItem
>
> In its base class, "__name__" is defined as
> "ComputedAttrib
> and it defines "getId()" to return "self.__name__".
> Apparently, this is an infinite recursion.
>
>Please file a bug report to "http://
>
>You can fix this problem by giving "Item_w__name__" a default
>class level attribute or "__name__ = ''".
>
>You can work around the bug by assigning an "id" for your
>object with its "_setId" method (this overrides "__name__").
In my case, after tracking this down, I decided that I really shouldn't have overloaded the __init__ since I didn't need to (I tend to do it out of habbit), so I removed it from my class, and re-created the instances (I only had a few).
Thanks,
J.F.
This breaks FileSystemStorage, so a fix for this seems to be important
Replacing:
self.__name__
with:
self.id
seems to fix it