Commit 167496f9 authored by Hanno Schlichting's avatar Hanno Schlichting

Turned deprecation warnings for manage_afterAdd, manage_beforeDelete and...

Turned deprecation warnings for manage_afterAdd, manage_beforeDelete and manage_afterClone methods into discouraged warnings.
parent 1e7c17f8
...@@ -9,6 +9,11 @@ Zope Changes ...@@ -9,6 +9,11 @@ Zope Changes
Restructuring Restructuring
- Turned deprecation warnings for manage_afterAdd, manage_beforeDelete
and manage_afterClone methods into discouraged warnings. These methods
will not be removed in Zope 2.11, but stay for the foreseeable future.
Using events is still highly encouraged.
- Moved two implements declarations from Five into the proper classes. - Moved two implements declarations from Five into the proper classes.
- Document.sequence: replaced by zope.sequencesort - Document.sequence: replaced by zope.sequencesort
......
...@@ -272,24 +272,21 @@ class CopyContainer(ExtensionClass.Base): ...@@ -272,24 +272,21 @@ class CopyContainer(ExtensionClass.Base):
try: try:
orig_container._delObject(orig_id, suppress_events=True) orig_container._delObject(orig_id, suppress_events=True)
except TypeError: except TypeError:
# BBB: removed in Zope 2.11
orig_container._delObject(orig_id) orig_container._delObject(orig_id)
warnings.warn( warnings.warn(
"%s._delObject without suppress_events is deprecated " "%s._delObject without suppress_events is discouraged."
"and will be removed in Zope 2.11." % % orig_container.__class__.__name__,
orig_container.__class__.__name__, DeprecationWarning) DeprecationWarning)
ob = aq_base(ob) ob = aq_base(ob)
ob._setId(id) ob._setId(id)
try: try:
self._setObject(id, ob, set_owner=0, suppress_events=True) self._setObject(id, ob, set_owner=0, suppress_events=True)
except TypeError: except TypeError:
# BBB: removed in Zope 2.11
self._setObject(id, ob, set_owner=0) self._setObject(id, ob, set_owner=0)
warnings.warn( warnings.warn(
"%s._setObject without suppress_events is deprecated " "%s._setObject without suppress_events is discouraged."
"and will be removed in Zope 2.11." % % self.__class__.__name__, DeprecationWarning)
self.__class__.__name__, DeprecationWarning)
ob = self._getOb(id) ob = self._getOb(id)
notify(ObjectMovedEvent(ob, orig_container, orig_id, self, id)) notify(ObjectMovedEvent(ob, orig_container, orig_id, self, id))
...@@ -362,11 +359,9 @@ class CopyContainer(ExtensionClass.Base): ...@@ -362,11 +359,9 @@ class CopyContainer(ExtensionClass.Base):
try: try:
self._delObject(id, suppress_events=True) self._delObject(id, suppress_events=True)
except TypeError: except TypeError:
# BBB: removed in Zope 2.11
self._delObject(id) self._delObject(id)
warnings.warn( warnings.warn(
"%s._delObject without suppress_events is deprecated " "%s._delObject without suppress_events is discouraged." %
"and will be removed in Zope 2.11." %
self.__class__.__name__, DeprecationWarning) self.__class__.__name__, DeprecationWarning)
ob = aq_base(ob) ob = aq_base(ob)
ob._setId(new_id) ob._setId(new_id)
...@@ -376,11 +371,9 @@ class CopyContainer(ExtensionClass.Base): ...@@ -376,11 +371,9 @@ class CopyContainer(ExtensionClass.Base):
try: try:
self._setObject(new_id, ob, set_owner=0, suppress_events=True) self._setObject(new_id, ob, set_owner=0, suppress_events=True)
except TypeError: except TypeError:
# BBB: removed in Zope 2.11
self._setObject(new_id, ob, set_owner=0) self._setObject(new_id, ob, set_owner=0)
warnings.warn( warnings.warn(
"%s._setObject without suppress_events is deprecated " "%s._setObject without suppress_events is discouraged." %
"and will be removed in Zope 2.11." %
self.__class__.__name__, DeprecationWarning) self.__class__.__name__, DeprecationWarning)
ob = self._getOb(new_id) ob = self._getOb(new_id)
......
...@@ -68,10 +68,8 @@ def maybeWarnDeprecated(ob, method_name): ...@@ -68,10 +68,8 @@ def maybeWarnDeprecated(ob, method_name):
return return
class_ = ob.__class__ class_ = ob.__class__
warnings.warn( warnings.warn(
"%s.%s.%s is deprecated and will be removed in Zope 2.11, " "%s.%s.%s is discouraged. You should use event subscribers instead." %
"you should use event subscribers instead, and meanwhile " (class_.__module__, class_.__name__, method_name),
"mark the class with <five:deprecatedManageAddDelete/>"
% (class_.__module__, class_.__name__, method_name),
DeprecationWarning) DeprecationWarning)
################################################## ##################################################
......
<configure xmlns="http://namespaces.zope.org/zope" <configure xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"> xmlns:five="http://namespaces.zope.org/five">
<!-- deprecated in core Zope, should be fixed there in Zope 2.9 --> <!-- deprecated in core Zope, should be fixed there -->
<five:deprecatedManageAddDelete <five:deprecatedManageAddDelete
class="AccessControl.User.BasicUserFolder"/> class="AccessControl.User.BasicUserFolder"/>
......
...@@ -10,7 +10,7 @@ happening to objects without have to subclass ``manage_afterAdd``, ...@@ -10,7 +10,7 @@ happening to objects without have to subclass ``manage_afterAdd``,
to register a subscriber for the appropriate event, for instance to register a subscriber for the appropriate event, for instance
IObjectAddedEvent, and make it do the work. IObjectAddedEvent, and make it do the work.
Indeed, the old methods like ``manage_afterAdd`` are now deprecated, you Indeed, the old methods like ``manage_afterAdd`` are now discouraged, you
shouldn't use them anymore. shouldn't use them anymore.
Let's see how to migrate your products. Let's see how to migrate your products.
...@@ -47,8 +47,7 @@ If you run this code in Zope 2.9, you will get deprecation warnings, ...@@ -47,8 +47,7 @@ If you run this code in Zope 2.9, you will get deprecation warnings,
telling you that:: telling you that::
Calling Products.CoolProduct.CoolDocument.CoolDocument.manage_afterAdd Calling Products.CoolProduct.CoolDocument.CoolDocument.manage_afterAdd
is deprecated when using Five, instead use event subscribers or mark is discouraged. You should use event subscribers instead.
the class with <five:deprecatedManageAddDelete/>
Using five:deprecatedManageAddDelete Using five:deprecatedManageAddDelete
------------------------------------ ------------------------------------
...@@ -78,8 +77,8 @@ work of the super class will be done trough events, you must not redo it ...@@ -78,8 +77,8 @@ work of the super class will be done trough events, you must not redo it
by hand. If you call the super class, you will get a warning, saying for by hand. If you call the super class, you will get a warning, saying for
instance:: instance::
CoolDocument.manage_afterAdd is deprecated and will be removed in CoolDocument.manage_afterAdd is discouraged. You
Zope 2.11, you should use an IObjectAddedEvent subscriber instead. should use an IObjectAddedEvent subscriber instead.
The fact that you must "just do your work" is especially important for The fact that you must "just do your work" is especially important for
the rare cases where people subclass the ``manage_afterAdd`` of object the rare cases where people subclass the ``manage_afterAdd`` of object
......
...@@ -23,7 +23,7 @@ from OFS.subscribers import deprecatedManageAddDeleteClasses ...@@ -23,7 +23,7 @@ from OFS.subscribers import deprecatedManageAddDeleteClasses
def setContainerEvents(): def setContainerEvents():
warnings.warn("Using <five:containerEvents/> is deprecated (it is now " warnings.warn("Using <five:containerEvents/> is deprecated (it is now "
"the default), it will be removed in Zope 2.11", "the default).",
DeprecationWarning) DeprecationWarning)
def setDeprecatedManageAddDelete(class_): def setDeprecatedManageAddDelete(class_):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment