RFC: product initialization cleanup and improvements
Hi! Working on the five:registerClass directive for Five 1.2 and Zope 2.9 I had a closer look at the product initialization code. I propose the following modifications for the dicts in Products.meta_types (set by registerClass): 1.) 'action' key: ----------------- I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI. The five:registerClass directive allows to set empty 'action' values. This would resolve http://www.zope.org/Collectors/Zope/1885 . Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2. 2.) 'interfaces' key: --------------------- Does currently only contain oldstyle interfaces. The code in OFS.ObjectManager that uses that key works also with z3 interfaces. I'd like to add z3 interfaces to the value of that key. That would e.g. allow to set only new style interfaces on catalog index classes. 3.) 'product' key: ------------------ AFAICS it isn't used in Zope itself. I'd like to add a note that it might be removed in a future version. 4.) related cleanup: -------------------- Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9. This isn't much work, it can all be done in time for the Zope 2.9 beta. Any feedback is welcome. If there are no objections, I'll make the changes as proposed. Cheers, Yuppie
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 yuppie wrote:
Working on the five:registerClass directive for Five 1.2 and Zope 2.9 I had a closer look at the product initialization code.
I propose the following modifications for the dicts in Products.meta_types (set by registerClass):
1.) 'action' key: -----------------
I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI.
The five:registerClass directive allows to set empty 'action' values.
This would resolve http://www.zope.org/Collectors/Zope/1885 .
Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2.
+1.
2.) 'interfaces' key: ---------------------
Does currently only contain oldstyle interfaces. The code in OFS.ObjectManager that uses that key works also with z3 interfaces. I'd like to add z3 interfaces to the value of that key. That would e.g. allow to set only new style interfaces on catalog index classes.
I'd just as soon rip old-style interfaces out by the roots. +1 for allowing new-style ones in 2.8.x; -1 for continuing to support old-style ones on the trunk (anybody clever enough to use the old ones "back in the day" is clever enough, and should be motivated enough, to convert).
3.) 'product' key: ------------------
AFAICS it isn't used in Zope itself. I'd like to add a note that it might be removed in a future version.
+1.
4.) related cleanup: --------------------
Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9.
+1.
This isn't much work, it can all be done in time for the Zope 2.9 beta.
Any feedback is welcome. If there are no objections, I'll make the changes as proposed.
Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDYPhi+gerLs4ltQ4RAjqAAKCa3BqERqXAC/uYPQp5n9Y8ZZL33QCeJ65o rKUDm17Qy3x+iNa1+5HxYnU= =e0ZF -----END PGP SIGNATURE-----
Hi Tres! Tres Seaver wrote:
yuppie wrote:
1.) 'action' key: -----------------
I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI.
The five:registerClass directive allows to set empty 'action' values.
This would resolve http://www.zope.org/Collectors/Zope/1885 .
Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2.
+1.
Ouch! I thought everything is in place for that feature, but an important piece of the puzzle is missing: The fix for checkPermission. http://www.zope.org/Collectors/Zope/1774 _verifyObjectPaste uses a hack to work around that checkPermission issue, making 'action' required. Tres: You did have a look at issue #1774 a while ago. What do you think: How much work would it be to resolve this issue? I'm not a C programmer so I can't do it myself...
2.) 'interfaces' key: ---------------------
Does currently only contain oldstyle interfaces. The code in OFS.ObjectManager that uses that key works also with z3 interfaces. I'd like to add z3 interfaces to the value of that key. That would e.g. allow to set only new style interfaces on catalog index classes.
I'd just as soon rip old-style interfaces out by the roots. +1 for allowing new-style ones in 2.8.x; -1 for continuing to support old-style ones on the trunk (anybody clever enough to use the old ones "back in the day" is clever enough, and should be motivated enough, to convert).
My goal is to make it possible to run products on Zope 2.9 without implementing any old-style interfaces. I think that's doable. But I can't see a need to break all products that use old-style interfaces. Cheers, Yuppie
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 yuppie wrote:
Ouch! I thought everything is in place for that feature, but an important piece of the puzzle is missing: The fix for checkPermission.
http://www.zope.org/Collectors/Zope/1774
_verifyObjectPaste uses a hack to work around that checkPermission issue, making 'action' required.
Tres: You did have a look at issue #1774 a while ago. What do you think: How much work would it be to resolve this issue? I'm not a C programmer so I can't do it myself...
I have uploaded a patch, with tests, to the collector issue: http://www.zope.org/Collectors/Zope/1774/collector_1774.patch/view I could use another pair of eyeballs on the C part of the code -- the refcount idioms in that code are pretty nasty, and I finally rewrote them using 'goto' and Py_XDECREF. The patch (against the 2.8 branch) applies cleanly to the 2.9 branch and the trunk, and all tests pass. Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDjR2h+gerLs4ltQ4RAuuNAJ9NW7onXtqWahhbpAGg3zsJl3dC/QCghz9c WfFBTxOeDLDyS/Gp1AN8KxY= =bz/Y -----END PGP SIGNATURE-----
yuppie wrote at 2005-10-27 14:45 +0200:
... 1.) 'action' key: -----------------
I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI.
The five:registerClass directive allows to set empty 'action' values.
This would resolve http://www.zope.org/Collectors/Zope/1885 .
Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2.
We already have the "visibility" key. Why do we need another (much obscurer) way to achieve the same thing?
... 4.) related cleanup: --------------------
Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9.
I hate that: While you might have the feeling that it were deprecated, 'ZSQLMethods' still use part of the old style initialization (they have an "initialize" but still use "methods", "__ac_permissions__" and "__module_aliases__"). And I occationally recommend these old style facilities. Having a warning period of 5 days (post on Oct 27; code freeze Nov 1) seems very short. What about removing the code for Zope 2.10? -- Dieter
Hi Dieter! Dieter Maurer wrote:
yuppie wrote at 2005-10-27 14:45 +0200:
... 1.) 'action' key: -----------------
I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI.
The five:registerClass directive allows to set empty 'action' values.
This would resolve http://www.zope.org/Collectors/Zope/1885 .
Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2.
We already have the "visibility" key. Why do we need another (much obscurer) way to achieve the same thing?
Because it doesn't do the same thing. 'visibility' doesn't primarily change the visibility. It controls if the meta_type is globally available (visibility='Global') or only in containers that specify one of its interfaces (visibility=None).
... 4.) related cleanup: --------------------
Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9.
I hate that:
While you might have the feeling that it were deprecated, 'ZSQLMethods' still use part of the old style initialization (they have an "initialize" but still use "methods", "__ac_permissions__" and "__module_aliases__").
Well. I think the comments in Application.install_product are very clear. 'initialize' was meant to replace the old way, not to provide a second way. I fixed ZGadflyDA and ZSQLMethods.
And I occationally recommend these old style facilities.
Having a warning period of 5 days (post on Oct 27; code freeze Nov 1) seems very short.
What about removing the code for Zope 2.10?
If the change breaks too many existing products I'm fine with leaving the code including deprecation warnings in Zope 2.9. Cheers, Yuppie
Dieter Maurer wrote:
yuppie wrote at 2005-10-27 14:45 +0200:
4.) related cleanup: --------------------
Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9.
I hate that:
While you might have the feeling that it were deprecated, 'ZSQLMethods' still use part of the old style initialization (they have an "initialize" but still use "methods", "__ac_permissions__" and "__module_aliases__").
__module_aliases__ are not affected by that change. They are not initialized by Application.install_product. Cheers, Yuppie
Hi! Some things turned out a bit different than proposed, so I want to report back:
1.) 'action' key: -----------------
I'd like to give empty 'action' values a special meaning: The meta_type is not visible in the add drop down in the ZMI.
The five:registerClass directive allows to set empty 'action' values.
This would resolve http://www.zope.org/Collectors/Zope/1885 .
Filtering out meta_types with empty 'action' values is a two line change in main.dtml. I'd like to make that change also on the 2.8 branch to enable that feature for 2.8.5 with Five 1.2.
I wasn't able to finish this because it depends on http://www.zope.org/Collectors/Zope/1774 . See my comment in http://www.zope.org/Collectors/Zope/1885 for details.
2.) 'interfaces' key: ---------------------
Does currently only contain oldstyle interfaces. The code in OFS.ObjectManager that uses that key works also with z3 interfaces. I'd like to add z3 interfaces to the value of that key. That would e.g. allow to set only new style interfaces on catalog index classes.
Done.
3.) 'product' key: ------------------
AFAICS it isn't used in Zope itself. I'd like to add a note that it might be removed in a future version.
That key is not required, but I found two places in Zope where it is used if it exists: In ProductRegistry for TTW products and in OFS.Application for refreshing products.
4.) related cleanup: --------------------
Application.install_product has some backwards compatibility code for products that have initialization code outside the 'initialize' method of their __init__.py. This is deprecated at least for 5 years. I'd like to add explicit deprecation warnings on the 2.8 branch and to remove that code for Zope 2.9.
Done. Made sure ZGadflyDA and ZSQLMethods don't use the deprecated code. Given the fact that 2 Zope core products still used that code and given the feedback on this list I didn't remove the code in Zope 2.9. This should be done in Zope 2.10 instead. Cheers, Yuppie
participants (3)
-
Dieter Maurer -
Tres Seaver -
yuppie