RE: [Zope] Product inhetitance question (similar question)
Title: RE: [Zope] Product inhetitance question (similar question) And what happen if the Class A is in a package PA. Clabb B is in a package PB. How do you access the namespace of PA from PB ? When I have tried, the inherited methods from A where not visible from B, and I and to recreate a copie of the method. (which is ugly !!!). Any suggestion ? Thierry Nabeth Research Fellow INSEAD CALT (the Centre for Advanced Learning Technologies) http://www.insead.fr/CALT/ -- From: Andy McKay [EMAIL PROTECTED] To: Daniel Rusch [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: [Zope] Product inhetitance question Date: Thu, 17 Aug 2000 08:54:49 -0700 charset=iso-8859-1 Say I have a fully functional (and more importantly, working) Product will call A. I want to extend this Product's capabilities so I wish to derive another class from it, call it B. No problem, class B(A): . The question is, (I think the answer is no) is there a way to inherit (i.e. reuse common code and extend it) the manage_Add function and the dtml files from A??? Well by inheritance B has all the methods, properties etc you have in A. So the answer is yes, if A has the foobar method then B will have a foobar method. Or do I misunderstand your question? -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People --
RE: [Zope] Product inhetitance question (similar question)
NABETH Thierry writes: And what happen if the Class A is in a package PA. Clabb B is in a package PB. How do you access the namespace of PA from PB ? from PA import A, . whatever you need class B(A): When I have tried, the inherited methods from A where not visible from B, and I and to recreate a copie of the method. (which is ugly !!!). Almost unbelievable. Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Product inhetitance question
Hey all, Say I have a fully functional (and more importantly, working) Product will call A. I want to extend this Product's capabilities so I wish to derive another class from it, call it B. No problem, class B(A): . The question is, (I think the answer is no) is there a way to inherit (i.e. reuse common code and extend it) the manage_Add function and the dtml files from A??? Thanks, DR ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Product inhetitance question
Well by inheritance B has all the methods, properties etc you have in A. So the answer is yes, if A has the foobar method then B will have a foobar method. Or do I misunderstand your question? -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 8:42 AM Subject: [Zope] Product inhetitance question Hey all, Say I have a fully functional (and more importantly, working) Product will call A. I want to extend this Product's capabilities so I wish to derive another class from it, call it B. No problem, class B(A): . The question is, (I think the answer is no) is there a way to inherit (i.e. reuse common code and extend it) the manage_Add function and the dtml files from A??? Thanks, DR ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Product inhetitance question
- Original Message - From: "Andy McKay" [EMAIL PROTECTED] To: "Daniel Rusch" [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 11:21 AM Subject: Re: [Zope] Product inhetitance question Ah... ok sorry you are right, stuff outside the class doesnt get inherited. What I did for this was make a very generic manage_addProduct and specify in my _init_.py a class initialisation string or whatever it is called... context.registerClass(A.ObjB, permission='Add ObjB', constructors=(A.addForm, A.manage_addA) ) If that makes sense. The manage_AddObject form creates an the right object depending upon paramaters passed to it. -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: "Andy McKay" [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 9:10 AM Subject: Re: [Zope] Product inhetitance question Slightly, I understand that if A has foo() then so does B(). But in a Zope product the are some things that lie "outside" of the class definition. The manage_add function is one of them. addtionally, I am having troubles getting B to inherit A's _properties structure. Thanks for all your help. I have learned an unbelieveable amount this week. Everyone else is gone and we are in a slow period so I wanted to learn the more advanced techniques this week. Dan Andy McKay wrote: Well by inheritance B has all the methods, properties etc you have in A. So the answer is yes, if A has the foobar method then B will have a foobar method. Or do I misunderstand your question? -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 8:42 AM Subject: [Zope] Product inhetitance question Hey all, Say I have a fully functional (and more importantly, working) Product will call A. I want to extend this Product's capabilities so I wish to derive another class from it, call it B. No problem, class B(A): . The question is, (I think the answer is no) is there a way to inherit (i.e. reuse common code and extend it) the manage_Add function and the dtml files from A??? Thanks, DR ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Product inhetitance question
This worked for me, what a hack _ properties=[] for i in range(0,len(A._properties)): _properties.append(A._properties[i]) _properties.append({'id':'RenderStandardHeader', 'type':'int','mode':'w'}) tuple(_properties) Andy McKay wrote: Hmm i just tested it in Zope and it worked fine for me. -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: "Andy McKay" [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 11:36 AM Subject: Re: [Zope] Product inhetitance question Great minds think a like or fools never differ. I tried this to but I get an error: TypeError: bad operand type(s) for + Dan Andy McKay wrote: I just had the exact same problem and I solved this morning by: class A: _properties = ( {...} ) class B(A): _properties = ( { new stuff... } ) _properties = _properties + A._properties This is tested in a quick script, but not fully in the products yet. So this will make class B have a properties dict that includes all of A, so you shouldnt need to edit manage_edit... in theory! -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: "Andy McKay" [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 9:40 AM Subject: Re: [Zope] Product inhetitance question Sorry to keep bothering you, but I'm on the threshold of success my B class has an extra property, therefore B's manage_edit needs to address this. In C++ I could override the base class's manage_edit do the B stuff and then call the base class's manage_edit, can this be done in python??? Dan Andy McKay wrote: Well by inheritance B has all the methods, properties etc you have in A. So the answer is yes, if A has the foobar method then B will have a foobar method. Or do I misunderstand your question? -- Andy McKay, Developer, ActiveState http://www.ActiveState.com Programming for the People - Original Message - From: "Daniel Rusch" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 17, 2000 8:42 AM Subject: [Zope] Product inhetitance question Hey all, Say I have a fully functional (and more importantly, working) Product will call A. I want to extend this Product's capabilities so I wish to derive another class from it, call it B. No problem, class B(A): . The question is, (I think the answer is no) is there a way to inherit (i.e. reuse common code and extend it) the manage_Add function and the dtml files from A??? Thanks, DR ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )