Work around Products.CMFCore
and Products.CMFPlone
design bug
#1205
+229
−6
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.
Work around for #1202.
Products.CMFCore
andProducts.CMFPlone
register non callable constructors withApp.ProductContext.ProductContext.registerClass
(even though the method's docstring clearly states that constructors must be callable).Formerly, this was not a problem. But with the introduction of explicit zpublishable decoration, constructors are now required to be callable braking
Products.CMFCore
andProducts.CMFPlone
.The PR introduces the new parameter
resources
ofregisterClass
which should be used instead ofconstructors
to register non callable objects. It uses work around code to avoid brakingProducts.CMFCore
andProducts.CMFPlone
(and maybe other packages) when they abuse theconstructors
parameter for non callable objects; aDeprecationWarning
is issued in this case.In addition, the PR cleans up
registerClass
's docstring a bit: in the old days, when the product registry could still be persistent (controlled via a parameter), the constructors were required to be picklable. The feature was abandoned long ago (because of many problems) and consequently, constructors need no longer be picklable (indeed, the constructors generated for zpublishable decoration are not picklable). The PR removes the corresponding requirement from the docstring..Finally, the PR removes the mention from the docstring that the
instance_class
parameter were not used (which is obviously wrong). But, I am not sure whether this removal is optimal. It is possible that the author wanted to express thatinstance_class
is not used directly (to construct instances) but only to provide useful defaults for other parameters. Feedback welcome.I would like to stress that this is a work around for bugs in other packages. They should get fixed there and the work around code here eventually removed.