RE: [Zope] Will the inheritance relationship will be preserved af ter export/import?
Hello Iap,
The interitance relationship seems broken after export/import between different ZODB.
Following is the message I have posted about this bug in January. I have mentioned already this bug several time, but until now I seemed to be the only one that care about this bug. (which makes me ask question about how much or how little the Zope community is using object orientation and inheritance with the Dtml language). I have personally stopped all design on the Zope platform (which I find some concept very interesting), and am concentrating my effort on Java/servlets because of this bug. I hope you find some way to solve your problems. Bye, Thierry -----Original Message----- From: Thierry Nabeth [mailto:Thierry.Nabeth@insead.fr] Sent: Saturday, January 06, 2001 10:46 PM To: zope@zope.org Cc: Thierry Nabeth Subject: Serious BUG in Export. ==> pb of lost inheritance if export / reimport. Hello, I would like to mention a very serious bug (for me), that prevent to use inheritance between two classes defined in two different package, if you have to export and reimport those packages. In a previous mail I mentionned a problem of Inheritance lost between packages. I spent a lot of time investigating the problem, and in particular looking in the export file (xml version). First here is the test: Phase 1: create the products and the classes. Create a product PA Create a class A in the product PA. Create a method "test" in class A. (this method display "before"). Create a product PB Create a class B in the product PB which inherits from A. Create an instance a of A. Create an instance b of B. Phase 2: test the inheritance. ==> everything works fine Executing the method "test" on those two instances return. a.test ==> "before" b.test ==> "before" The result is correct. Phase 3: export / reimport product PB, and modify methode "test". Export the product PB. (PB.zexp is generated) Delete the product PB and restart zope. Import the product PB (PB.zexp) and restart zope. Modify the method "test" in class A.. (this method display "after"). Phase 4: test the inheritance. ==> B does not work correctly. Executing the method "test" on those two instances return. a.test ==> "after" b.test ==> "before" ####### this is incorect. !!!!!! I spent a lot of time investing this problem, in particular looking in the xml export file. The problem is that when you export PB, the exported file also contain the definition of class A. When you re-import PB, B inherits from a class A that is different from the class A that is in the product PA. You have a kind of Zombie class A. (note: reimporting class A doesn't solve the problem). If someone has some idea how to fix this bug which almost forbid the use of inheritance between products in zope (unless you have a master server that never import anything) ?! Thierry Nabeth Research Fellow, INSEAD CALT (The Centre for Advanced Learning Technologies) http://www.insead.edu/CALT/ Thierry.Nabeth@insead.fr
Are you using zclasses or python products? I have not seen this behavior with python products. If you are using zclasses then you should expect this kind of thing. Zclasses are not robust solutions they mostly seem designed for trivial solutions by largely non programmers. On Thu, 10 May 2001, NABETH Thierry wrote:
Hello Iap,
The interitance relationship seems broken after export/import between different ZODB.
Following is the message I have posted about this bug in January. I have mentioned already this bug several time, but until now I seemed to be the only one that care about this bug. (which makes me ask question about how much or how little the Zope community is using object orientation and inheritance with the Dtml language).
I have personally stopped all design on the Zope platform (which I find some concept very interesting), and am concentrating my effort on Java/servlets because of this bug.
I hope you find some way to solve your problems.
Bye,
Thierry
-----Original Message----- From: Thierry Nabeth [mailto:Thierry.Nabeth@insead.fr] Sent: Saturday, January 06, 2001 10:46 PM To: zope@zope.org Cc: Thierry Nabeth Subject: Serious BUG in Export. ==> pb of lost inheritance if export / reimport.
Hello,
I would like to mention a very serious bug (for me), that prevent to use inheritance between two classes defined in two different package, if you have to export and reimport those packages.
In a previous mail I mentionned a problem of Inheritance lost between packages.
I spent a lot of time investigating the problem, and in particular looking in the export file (xml version).
First here is the test:
Phase 1: create the products and the classes.
Create a product PA Create a class A in the product PA. Create a method "test" in class A. (this method display "before").
Create a product PB Create a class B in the product PB which inherits from A.
Create an instance a of A. Create an instance b of B.
Phase 2: test the inheritance. ==> everything works fine
Executing the method "test" on those two instances return. a.test ==> "before" b.test ==> "before" The result is correct.
Phase 3: export / reimport product PB, and modify methode "test".
Export the product PB. (PB.zexp is generated) Delete the product PB and restart zope. Import the product PB (PB.zexp) and restart zope.
Modify the method "test" in class A.. (this method display "after").
Phase 4: test the inheritance. ==> B does not work correctly.
Executing the method "test" on those two instances return. a.test ==> "after" b.test ==> "before" ####### this is incorect. !!!!!!
I spent a lot of time investing this problem, in particular looking in the xml export file. The problem is that when you export PB, the exported file also contain the definition of class A. When you re-import PB, B inherits from a class A that is different from the class A that is in the product PA. You have a kind of Zombie class A. (note: reimporting class A doesn't solve the problem).
If someone has some idea how to fix this bug which almost forbid the use of inheritance between products in zope (unless you have a master server that never import anything) ?!
Thierry Nabeth Research Fellow, INSEAD CALT (The Centre for Advanced Learning Technologies) http://www.insead.edu/CALT/ Thierry.Nabeth@insead.fr
RE: [Zope] Will the inheritance relationship will be preserved after export/import?By stealing some codes from AlexR's helpful how-to "Changing Base Classes for a ZClass". I wrote an external method to be a quick-and-dirty work around. (see the attachment) This external method helps a zclass to change the old reference of its base class (an instance of ZClass) to the new one in "new" ZODB. Just install this external method(with t,t,t as parameters) and request it by a browser. It will response a form for you to fill in your product/class name pair. "Source Product/Class" is for the base class. "Destination Product/Class" is for the class which lost its reference to the base class. The value of class accepts nested class which means ClassA/ClassB/ClassC.... is valid for this field. In my own case, I have a nested class up to 5 level. The "replace" field is for inputing the index of the old reference of base class which is going to be replaced. (starts from 0) Since the base classes is an array which is a mixup of serveral products. The "copy" checkbox is for doing a full-replacement of base classes from source zclass to destination zclass exactly as what AlexR's script does. The "Test Run" button won't do the real task. It just gives the information of what is going to happen. Use this to dump out the array of base classes of your source zclass and destination zclass. The "Real Run" button will do the real task to replace or to copy. Hope that you won't be regret after hit this button. Hitting "Test Run" is strongly recommended before hitting "Real Run". If the path of source zclass or destination zclass is wrong which means there is no such zclass existed, this external method will response "None" for your attention. Make sure the zclasses you want to operate to are really existed in your ZODB. Most important of all: use it in your own risk. Remember to export your product for backing up before any actions. It works for me not necessary work for you. But I do hope it helps. kosh@aesaeion.com is right. This problem won't be happened in a product which is implemented in pure python scripts. That is quite trivial after dumping the base classes of a ZClasses-based product. Zope is great! Well, I agree with what kosh said "Zclasses are not robust solutions they mostly seem designed for trivial solutions by largely non programmers." Regards, Iap, Singuan
participants (3)
-
iap_y2fun.com -
kosh@aesaeion.com -
NABETH Thierry