Senseful "OFS.SimpleItem.Item_w__name__.id" definition #906
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Override
id
inOFS.SimpleItem.Item_w__name__
to avoid bugs by use of deprecated directid
access (--> #903 ).In ancient days, all Zope objects had an
id
attribute. With the advent of Zope 3 technologies,__name__
seemed a better name for the name/id of a Zope object: directid
access was deprecated in favor ofgetId()
andgetId
was defined to switch betweenid
and__name__
, as necessary. For backward compatibility__name__
was defined as alias forid
, overridable on the instance level. This allowed for a graceful migration from the oldid
to the new__name__
use in the context of existing Zope object without__name__
but withid
. However, newly createdItem_w__name__
instances had a wrongid
: for them, the deprecated direct access toid
led to bugs (e.g. #903 ).This PR defines
Item_w__name__.id
as follows:id
, it is used (this handles the case of an old Zope object still usingid
in place of__name__
)__name__
, itsgetId()
it called; the precondition is necessary to avoid an infinite recursion (as__name__
is otherwise defined referring toid
)""
is used asid
This definition is not perfect: it fails for example,
__name__
not via an instance attributeid
and__name__
; for themobj.id
could be different fromobj.getId()
. Such a case could result from the copying or renaming of an old Zope object (withid
, without__name__
).However, if seems considerable better then the current state.
This PR would fix #903; however, it is not the best fix possible. This PR tries to avoid problems with the deprecated direct
id
access in general, not particularly for #903.