Hi, I've got a question regarding ZClasses and the building of Hierarchies using them. For example I have ZClass A and the ZClasses B and C "derived" from A What does Zope do if I create a new Instance of B using manage_addProduct['myproduct'].B_add(myparam). I know that the B_add Script I created is called, but is also the A_add Script called, or can I call it in the B_add script, or do I have to reimplement all necessary things from A_add in B_add? Andreas -- There is a fly on your nose.
Andreas Pakulat wrote at 2003-6-5 15:28 +0200:
I've got a question regarding ZClasses and the building of Hierarchies using them.
For example I have ZClass A and the ZClasses B and C "derived" from A
What does Zope do if I create a new Instance of B using manage_addProduct['myproduct'].B_add(myparam). I know that the B_add Script I created is called, but is also the A_add Script called,
No, it is not called.
or can I call it in the B_add script,
You can, but almost surely it will not do what you expect (it probably will create a *new* "A" instance, independent from your "B" instance). , or do I have to reimplement all necessary
things from A_add in B_add?
You "A_add" probably contains 2 parts: 1. create a new "A" instance 2. initialize the new instance Factor out part 2 (in a separate script inside your product). Call it in both "A_add" and "B_add". Note that when a ZClass "B" derives from a ZClass "A", then both should be in the same product. Otherwise, the relation between the two classes is lost during export or distribution. Dieter
On 05.Jun 2003 - 22:34:26, Dieter Maurer wrote:
Andreas Pakulat wrote at 2003-6-5 15:28 +0200: , or do I have to reimplement all necessary
things from A_add in B_add?
You "A_add" probably contains 2 parts:
1. create a new "A" instance
2. initialize the new instance
Factor out part 2 (in a separate script inside your product). Call it in both "A_add" and "B_add".
Hmm, I need the base class only to have some common properties and methods for several ZClasses. So the Base Class will never be used directly, so I onyl added a call to manage_editProperties from class A in the _add of B. Andreas -- If you sow your wild oats, hope for a crop failure.
On 06.Jun 2003 - 01:01:50, Andreas Pakulat wrote:
On 05.Jun 2003 - 22:34:26, Dieter Maurer wrote:
Andreas Pakulat wrote at 2003-6-5 15:28 +0200: , or do I have to reimplement all necessary
things from A_add in B_add?
You "A_add" probably contains 2 parts:
1. create a new "A" instance
2. initialize the new instance
Factor out part 2 (in a separate script inside your product). Call it in both "A_add" and "B_add".
Hmm, I need the base class only to have some common properties and methods for several ZClasses. So the Base Class will never be used directly, so I onyl added a call to manage_editProperties from class A in the _add of B.
Got another problem with these both classes. Class A (Base Class) has a Property character in the propertysheet Attributes which is a multiple selection. I have the lines-Property in /. If I add an instance of Class B I can edit this character Property, the html-code is created with this: <form action="B_add"> <select size="5" multiple> <option tal:repeat="item here/B_character" tal:content="item" tal:attributes="value repeat/item/index"> </select> </form> Now I have a View Prop, which connects to A/propertysheets/Attributes, but if I click on the Prop tab of my new instance I get the following error: exceptions.TypeError 'in ' requires character as left operandTraceback (innermost last): Module ZPublisher.Publish, line 150, in publish_module Module ZPublisher.Publish, line 114, in publish Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec Module App.special_dtml, line 174, in _exec Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_Util, line 201, in eval - __traceback_info__: getProperty Module , line 0, in ? TypeError: (see above) Which is not very useful to me :( I also tried to use tal:attributes="value item", but the result is the same. Andreas -- You too can wear a nose mitten.
Andreas Pakulat wrote at 2003-6-6 01:27 +0200:
.... Got another problem with these both classes. ... Now I have a View Prop, which connects to A/propertysheets/Attributes, but if I click on the Prop tab of my new instance I get the following error:
exceptions.TypeError
'in ' requires character as left operandTraceback (innermost last): Module ZPublisher.Publish, line 150, in publish_module Module ZPublisher.Publish, line 114, in publish Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec Module App.special_dtml, line 174, in _exec Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_Util, line 201, in eval - __traceback_info__: getProperty Module , line 0, in ? TypeError: (see above)
Which is not very useful to me :(
It's the same for us: Can you please tell your mail writer *not* to reflow the traceback. Beside the traceback, we need "Error type" and "Error value" to make up our mind. That said: Your request calls a "DTMLFile" object (the traceback unfortunately does not tell which one). It executes a "dtml-in" which contains a '... expr="...getProperty..."'. This "getProperty" is called with wrong parameters. Find the DTMLFile, find the "getProperty" and decide why it is called in the wrong way. Dieter
On 06.Jun 2003 - 20:49:25, Dieter Maurer wrote:
Andreas Pakulat wrote at 2003-6-6 01:27 +0200:
.... Got another problem with these both classes. ... Now I have a View Prop, which connects to A/propertysheets/Attributes, but if I click on the Prop tab of my new instance I get the following error:
exceptions.TypeError
'in ' requires character as left operandTraceback (innermost last): Module ZPublisher.Publish, line 150, in publish_module Module ZPublisher.Publish, line 114, in publish Module ZPublisher.Publish, line 98, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 252, in __call__ Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec Module App.special_dtml, line 174, in _exec Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_In, line 705, in renderwob Module DocumentTemplate.DT_Util, line 201, in eval - __traceback_info__: getProperty Module , line 0, in ? TypeError: (see above)
Which is not very useful to me :(
It's the same for us:
Can you please tell your mail writer *not* to reflow the traceback.
No I cannot :( but the whole text is displayed on 1 line in zope!
Beside the traceback, we need "Error type" and "Error value" to make up our mind.
It's both there: Excetion.TypeError and the value is "in requires character as left operand"
That said:
Your request calls a "DTMLFile" object (the traceback unfortunately does not tell which one). It executes a "dtml-in" which contains a '... expr="...getProperty..."'. This "getProperty" is called with wrong parameters.
That I already knew.
Find the DTMLFile, find the "getProperty" and decide why it is called in the wrong way.
And there's the problem. As said in the original Mail its a "Property" Tab of a ZClass, which I created in the "View" Tab of the ZClass using the ZClass/propertysheets/myproperties/manage. And I also said that it only comes up if I have the multiple selection property in the Propertysheet. So I told you everything I know and could find out without help. I don't know much about all the Python-Classes in the lib/python directory and I'm not able to find out which Method brings up the error. Andreas -- Beware of low-flying butterflies.
I've got a question regarding ZClasses and the building of Hierarchies using them.
For example I have ZClass A and the ZClasses B and C "derived" from A
What does Zope do if I create a new Instance of B using manage_addProduct['myproduct'].B_add(myparam). I know that the B_add Script I created is called, but is also the A_add Script called, or can I call it in the B_add script, or do I have to reimplement all necessary things from A_add in B_add?
I usually stay well away from ZClasses, but unless they're *really* strange, it should work like in Python products... The B_add function is explicitly used (and nothing else.) In that function you may call an appropriate function from a superclass like:: A.A_add(id, parameters) but be careful, because product add scripts like to create objects rather than initialize. You'll want to call an initialization method instead (like you should be using in A_add):: def B_add(self, id, parameters): obj = B(id, parameters) A.__init__(obj, id, parameters) # everything else, then add to 'obj' to 'self' In newer Python, you can use the super() call. --jcc
participants (3)
-
Andreas Pakulat -
Dieter Maurer -
J Cameron Cooper