Re: [Zope] calling product ZClass add method
-----Original Message----- From: Chris Walter <walter@budoe.bu.edu> To: Kevin Dangoor <kid@kendermedia.com> Cc: zope@zope.org <zope@zope.org> Date: Monday, August 23, 1999 2:14 PM Subject: Re: [Zope] calling product ZClass add method
Thanks, this is definitely closer. In the product directory photoCD I have ZClasses multiRes and photoCD. I'm in an instance of a photoCD class(which inherits from Folder) somewhere in my site and I am trying to add an instance of a multiRes. So I added this to my method in photoCD.
Hmm... if "multiRes" objects can only appear within "photoCD" objects, it would probably be good to recreate the multiRes ZClass within the photoCD ZClass. This is good for two reasons: 1) multiRes will only show up as an option within photoCDs, 2) calling multiRes_add is really straightforward.
<dtml-with "manage_addProduct['photoCD']"> <dtml-call "multiRes_add(_.None, _, NoRedir=1)"> </dtml-with>
since I want something in the photoCD product directory and what I want is a multiRes ZClass right? So If I do this I get the following odd error message:
Error Type: AttributeError Error Value: _u
Here is part of the traceback: File /usr/local/Zope-2.0.0b3-linux2-x86/lib/python/App/FactoryDispatcher.py, line 126, in DestinationURL AttributeError: (see above)
Hmm... it's talking about "DestinationURL". It shouldn't be hitting DestinationURL, because of the NoRedir flag. Did you modify the multiRes_add method (as mentioned in the first part of the howto)? Kevin
On Mon, 23 Aug 1999, Kevin Dangoor wrote:
AttributeError: (see above)
Hmm... it's talking about "DestinationURL". It shouldn't be hitting DestinationURL, because of the NoRedir flag. Did you modify the multiRes_add method (as mentioned in the first part of the howto)?
That's what I get for not blindly following instructions! I thought since in my first little test case I was only adding one instance it was harmless to re-direct the output. It looks like I was wrong. I went ahead and modified multiRes_add and it worked great. Now I can loop through a tinytable and produce multiRes objects just like I wanted to. BTW as far as I am concerned you are a genius for figuring out the line: <dtml-with "manage_addProduct['YourProduct']"> by looking at the HTML source. I don't really know python yet. What is the meaning of the "[]" as opposed to the "()"? Array instead of function? In the HOWTO it might be nice to point out that _ is a special variable that contains the namespace and people should look in the DTML users's guide for more info.
Hmm... if "multiRes" objects can only appear within "photoCD" objects, it would probably be good to recreate the multiRes ZClass within the photoCD ZClass. This is good for two reasons: 1) multiRes will only show up as an option within photoCDs, 2) calling multiRes_add is really straightforward.
I thought about this but decided against it. multiRes is a ZClass for displaying multiple resolutions of images stored on a disk. It can display a small image as a link to a larger image. I thought it was useful enough outside of photoCD directories that I might make it available to others sometime who might have other uses for it. Thanks again! -Chris
On Mon, 23 Aug 1999, Chris Walter wrote:
BTW as far as I am concerned you are a genius for figuring out the line:
<dtml-with "manage_addProduct['YourProduct']">
by looking at the HTML source. I don't really know python yet. What is the meaning of the "[]" as opposed to the "()"? Array instead of function? Well, () is function call. [] is index lookup (be it numeric in an array, or any type for a dictionary).
Put differently, in the python object model, () translates to the method __call__ and [] translates to the methods __getitem__/__setitem__/__delitem__ Example: class A: def __getitem__(self,k): print "GET",k def __setitem__(self,k,v): print "SET",k,"=",v def __delitem__(self,k): print "DEL",k def __call__(self,*args): print "CALL",args # create an instance a of our demonstration class. a=A() # now do some accesses: x=a[5] a[6]="ABC" del a[1,2] x=a(1,2,3,4)
In the HOWTO it might be nice to point out that _ is a special variable that contains the namespace and people should look in the DTML users's guide for more info. <rant:mode> Well, the DTML user's guide does point it out. :( People seem to assume that they can start to develop ZOPE applications just as easy writing some HTML pages with FP :(
Remember: ZOPE is easy. But this is relative to it's power. ZOPE is extremly powerful. And it's the most powerful development philosophy I've seen. Because of this ZOPE is just a bit complex. Don't expect to start using ZOPE and become proficient developers in 1 week. </rant:mode> Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
On Mon, 23 Aug 1999, Andreas Kostyrka wrote:
Well, () is function call. [] is index lookup (be it numeric in an array, or any type for a dictionary).
Thanks for the explanation...
In the HOWTO it might be nice to point out that _ is a special variable that contains the namespace and people should look in the DTML users's guide for more info. <rant:mode> Well, the DTML user's guide does point it out. :( People seem to assume that they can start to develop ZOPE applications just as easy writing some HTML pages with FP :(
Remember: ZOPE is easy. But this is relative to it's power. ZOPE is extremly powerful. And it's the most powerful development philosophy I've seen. Because of this ZOPE is just a bit complex. Don't expect to start using ZOPE and become proficient developers in 1 week. </rant:mode>
Well right. I agree of course. My point is just if you are writing a HOWTO and you write something that it occurs to you might not be obvious to everyone it is nice to give a pointer as to where to get more info. I don't know how many times I have read the DTML users guide and it took me a little while to remember that I had read about _ there earlier. I suppose for those of us who aren't really web designers (I'm a physicist for example) this is probably more helpful than for those of you who are living and breathing this stuff all day. Thanks again for the info, -Chris walter@budoe.bu.edu
On Mon, 23 Aug 1999, Chris Walter wrote:
I suppose for those of us who aren't really web designers (I'm a physicist for example) this is probably more helpful than for those of you who are living and breathing this stuff all day. Well, I wouldn't say so ;) ZOPE is alien enough to classical web development, that ``normal'' web developers have enough problems.
_ is a bit more natural to me perhaps because I'm an old pythoneer myself ;) (No, _ is not a standard python thing. But the concept of name spaces etc. is.) Andreas -- Andreas Kostyrka | andreas@mtg.co.at phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H. | fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA
participants (3)
-
Andreas Kostyrka -
Chris Walter -
Kevin Dangoor