Consider this class class CImageObject(Photo.Photo): def tag(self, REQUEST=None, display=None, pdcookie=None, height=None, width=None, alt=None, **args): print "proof that CImageObject is the class used" [...my magic on top of Photo...] # the below line is line 48 Photo.Photo.tag(self,REQUEST, display,pdcookie, height,width,alt,args) The Photo class is the Photo product. The tag function looks like this: def __call__(self, REQUEST=None, display=None, pdcookie=None, height=None, width=None, alt=None, **args): " bla bla bla " tag = __call__ My class is called from DTML like this <dtml-var "an_image.tag(border=1,alt='',width=9)"> That's when I get the strange error: Error Type: TypeError Error Value: too many arguments; expected 7, got 8 (Object: tag) File C:\Program Files\zope\lib\python\Products\n4a\medialibrary_zb\medialibrarydata.py, line 48, in tag (Object: 200110.jpeg) TypeError: (see above) If you count them, they match like they should. Our class used to subclass the Image product before, in which's tag() method also has 8 arguments. Does anybody know what's going on? Cheers, Peter
# the below line is line 48 Photo.Photo.tag(self,REQUEST, display,pdcookie, height,width,alt,args) [...] Error Type: TypeError Error Value: too many arguments; expected 7, got 8
Use: Photo.Photo.tag(REQUEST, display,pdcookie,height,width,alt,args) self is implicitly passed when you use the member notation (Photo.tag). Florent Guillaume Nuxeo
# the below line is line 48 Photo.Photo.tag(self,REQUEST, display,pdcookie, height,width,alt,args) [...] Error Type: TypeError Error Value: too many arguments; expected 7, got 8
Use: Photo.Photo.tag(REQUEST, display,pdcookie,height,width,alt,args)
self is implicitly passed when you use the member notation (Photo.tag).
When I do that I get Error Type: TypeError Error Value: unbound Python method must be called with Photo 1st argument I think that the self I'm passing here is the "zope-self" (I.e. the Whole zope instance class). Not the Python "class-classic-self". Photo.Photo.tag == afile.aclass.amethod Still have to solve this one. Getting desperate :( Peter
Florent Guillaume Nuxeo
_______________________________________________ Zope maillist - Zope@zope.org 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 )
On 22 Aug 2001 17:12:14 +0200, Peter Bengtsson wrote:
self is implicitly passed when you use the member notation (Photo.tag).
When I do that I get
Error Type: TypeError Error Value: unbound Python method must be called with Photo 1st argument
<snip>
Still have to solve this one. Getting desperate :(
Well, this seems unlikely, but desperation demands you give it a go: When I've been developing products, and I'm using the Refresh service to reload them, I've sometimes got the 'unbound Python method' error too. The way to get rid of it is to restart Zope. I think it may be a Refresh bug. But I expect you've tried that already... seb
Still have to solve this one. Getting desperate :(
Well, this seems unlikely, but desperation demands you give it a go:
When I've been developing products, and I'm using the Refresh service to reload them, I've sometimes got the 'unbound Python method' error too. The way to get rid of it is to restart Zope. I think it may be a Refresh bug. But I expect you've tried that already...
I restart the whole zope between each codechange, so it can't be that.
On 22 Aug 2001 17:12:14 +0200, Peter Bengtsson wrote:
# the below line is line 48 Photo.Photo.tag(self,REQUEST, display,pdcookie, height,width,alt,args) [...] Error Type: TypeError Error Value: too many arguments; expected 7, got 8
Use: Photo.Photo.tag(REQUEST, display,pdcookie,height,width,alt,args)
self is implicitly passed when you use the member notation (Photo.tag).
When I do that I get
Error Type: TypeError Error Value: unbound Python method must be called with Photo 1st argument
I think that the self I'm passing here is the "zope-self" (I.e. the Whole zope instance class). Not the Python "class-classic-self". Photo.Photo.tag == afile.aclass.amethod
Still have to solve this one. Getting desperate :( Peter
Florent Guillaume Nuxeo
_______________________________________________ Zope maillist - Zope@zope.org 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 - Zope@zope.org 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 ) --
[] j a m k i t seb bacon T: 020 7749 7218 F: 020 7739 8683 M: 07968 301 336 W: www.jamkit.com
When I do that I get
Error Type: TypeError Error Value: unbound Python method must be called with Photo 1st argument
Okay, I see, it can't work like I said. You should do: class CImageObject(Photo.Photo): _old_tag = Photo.Photo.inheritedAttribute('tag') def tag(self, REQUEST=None, display=None, pdcookie=None, height=None, width=None, alt=None, **args): # ... self._old_tag(REQUEST,display,pdcookie,height,width,alt,args) Cheers, Florent Guillaume Nuxeo
Peter Bengtsson writes:
Photo.Photo.tag(self,REQUEST, display,pdcookie, height,width,alt,args) ... TypeError, too many arguments
def __call__(self, REQUEST=None, display=None, pdcookie=None, height=None, width=None, alt=None, **args): " bla bla bla " tag = __call__
The "**args" mean "arbitrary keyword arguments". You must not pass a positional argument for them (as you do). Use: apply(Photo.Photo.tag, (self,REQUEST,display,pdcookie,height,width,alt,), args) Dieter
participants (4)
-
Dieter Maurer -
Florent Guillaume -
Peter Bengtsson -
seb bacon