[Bug] refresh does not work for products initialized in the old style
Recently, someone complaint about being unable to refresh his product. After the first refresh, he was unable create new instances of his product. He got an unintelligent error message: "AttributeError: None object does not have attribute _setObject" I just found out why this happens: Products using old style initializations install their constructors as methods of "Folder.Folder". When the product is reinstalled during a refresh, then in "OFS.Application.install_product" it is checked whether "Folder.Folder" already has the method. It has! The old method from the time before the refresh. Therefore, the old constructors remain installed. I do not yet understand, why a "self" that should be a folder is passed as None, but I am convinced it has to do with the outdated constructor in "Folder.Folder". Upgrading to new style initialization works around the problem. Dieter
Hello Dieter.
Recently, someone complaint about being unable to refresh his product. Yes, it was me. I posted it on Mon, 4 Feb 2002 00:55:27, and the subject was: Zope-Error: Object of type "None" is not callable
After the first refresh, he was unable create new instances of his product. He got an unintelligent error message: "AttributeError: None object does not have attribute _setObject" Actually it was: 'Object of type "None" is not callable'
I just found out why this happens:
Products using old style initializations install their constructors as methods of "Folder.Folder".
When the product is reinstalled during a refresh, then in "OFS.Application.install_product" it is checked whether "Folder.Folder" already has the method. It has! The old method from the time before the refresh. Therefore, the old constructors remain installed. This would explain why ope didn't recognize any changes in my addFunction. The traceback of "Object of type 'None' is not callable" told me, that the error is in my addFunction in the line: handle=GMSBericht() (GMSBericht is the class of my product) If I changed the line to something like: handle=qwertz(GMSBericht(asdf())) (which is syntactically correct nonsense) and did a refresh, the traceback after trying to create a new instance of my product was exactly the same(!). As I posted earlier, the refresh worked well in 2.4.0, but not since 2.4.1.
I do not yet understand, why a "self" that should be a folder is passed as None, but I am convinced it has to do with the outdated constructor in "Folder.Folder".
Upgrading to new style initialization works around the problem. Well, I don't think I understood your explanation. What is the difference between "old style" and "new style initialization"?
Thanks a lot for your posting! Greetings Sven Rudolph
Sven Rudolph writes:
....
Upgrading to new style initialization works around the problem. Well, I don't think I understood your explanation. What is the difference between "old style" and "new style initialization"?
That's old style product initialization (in "__init__.py"): import sys, string import DA import SQLRelay classes=DA.classes meta_types=DA.meta_types methods=DA.folder_methods misc_=DA.misc_ __ac_permissions__=DA.__ac_permissions__ That's the same in new style: import sys, string import DA import SQLRelay misc_=DA.misc_ def initialize(context): context.registerClass( DA.classes[0], meta_type=DA.meta_types[0]['name'], constructors= (DA.folder_methods['manage_addZSQLRelayConnectionForm'], DA.folder_methods['manage_addZSQLRelayConnection'],), permission= DA.__ac_permissions__[0][0], ) Remark: When the product is designed for new style initialization, the initialization will look a bit clearer than in the above example where old style was forced into new style. Dieter
Hello Dieter.
What is the difference between "old style" and "new style initialization"?
That's old style product initialization (in "__init__.py"): ...
That's the same in new style: ... Ah. Now I know what you mean. Unfortunately I have tried this already, and it didn't work at all. I still got the same error message.
Greetings Sven Rudolph
Sven Rudolph writes:
What is the difference between "old style" and "new style initialization"?
That's old style product initialization (in "__init__.py"): ...
That's the same in new style: ... Ah. Now I know what you mean. Unfortunately I have tried this already, and it didn't work at all. I still got the same error message. The "methods" had gone? That's the essential part...
Dieter
participants (2)
-
Dieter Maurer -
Sven Rudolph