[Zope] Calling a python product with paramaters PLEASE HELP

Sean K getmejazzed@yahoo.com
Fri, 22 Nov 2002 23:04:50 -0800 (PST)


--0-815922956-1038035090=:38729
Content-Type: text/plain; charset=us-ascii


Hi all,

Here is the index_html of a product with the index_html embeded in the module source-

    def index_html(self,width=100, height=200,RESPONSE=None,REQUEST=None):
        "This is the index_html method"
        im=PIL.Image.new('RGB', (width,height))
        draw = PIL.ImageDraw.Draw(im)
        draw.rectangle([0,0,0,0], fill =(0,0,0))
        RESPONSE.setHeader("Content-type", "image/gif")
        outFile = cStringIO.StringIO()
        im.save(outFile, 'gif')
        RESPONSE.write(outFile.getvalue())
        return ''
    

If I call an instance of the product from a dtml method with <dtml-var bar> I get my picture.

If I call an instance of the product from a dtml method with <dtml-var bar(100,100)">, I get-

Error Type: AttributeError
Error Value: __call__


Traceback (innermost last):  File C:\Zope\lib\python\ZPublisher\Publish.py, line 150, in publish_module  File C:\Zope\lib\python\ZPublisher\Publish.py, line 114, in publish  File C:\Zope\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook    (Object: Zope)  File C:\Zope\lib\python\ZPublisher\Publish.py, line 98, in publish  File C:\Zope\lib\python\ZPublisher\mapply.py, line 88, in mapply    (Object: barcall)  File C:\Zope\lib\python\ZPublisher\Publish.py, line 39, in call_object    (Object: barcall)  File C:\Zope\lib\python\OFS\DTMLMethod.py, line 127, in __call__    (Object: barcall)  File C:\Zope\lib\python\DocumentTemplate\DT_String.py, line 473, in __call__    (Object: barcall)  File C:\Zope\lib\python\DocumentTemplate\DT_Util.py, line 159, in eval    (Object: bar(100,100))    (Info: bar)  File <string>, line 2, in fAttributeError: (see above)I have nearly got this product working the way I want it to, so any help you can give will be greatly appreciated.

Regards

Sean Kemplay



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
--0-815922956-1038035090=:38729
Content-Type: text/html; charset=us-ascii

<P>Hi all,</P>
<P>Here is the index_html of a product with the index_html embeded in the module source-</P>
<P>&nbsp;&nbsp;&nbsp; def index_html(self,width=100, height=200,RESPONSE=None,REQUEST=None):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "This is the&nbsp;index_html method"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; im=PIL.Image.new('RGB', (width,height))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw = PIL.ImageDraw.Draw(im)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw.rectangle([0,0,0,0], fill =(0,0,0))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RESPONSE.setHeader("Content-type", "image/gif")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; outFile = cStringIO.StringIO()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; im.save(outFile, 'gif')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RESPONSE.write(outFile.getvalue())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ''<BR>&nbsp;&nbsp;&nbsp; </P>
<P>If I call an instance of the product from a dtml method with &lt;dtml-var bar&gt; I get my picture.</P>
<P>If I call an instance of the product from a dtml method with &lt;dtml-var bar(100,100)"&gt;, I get-</P>
<P><STRONG>Error Type: AttributeError</STRONG><BR><STRONG>Error Value: __call__</STRONG><BR></P><PRE>Traceback (innermost last):
  File C:\Zope\lib\python\ZPublisher\Publish.py, line 150, in publish_module
  File C:\Zope\lib\python\ZPublisher\Publish.py, line 114, in publish
  File C:\Zope\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook
    (Object: Zope)
  File C:\Zope\lib\python\ZPublisher\Publish.py, line 98, in publish
  File C:\Zope\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: barcall)
  File C:\Zope\lib\python\ZPublisher\Publish.py, line 39, in call_object
    (Object: barcall)
  File C:\Zope\lib\python\OFS\DTMLMethod.py, line 127, in __call__
    (Object: barcall)
  File C:\Zope\lib\python\DocumentTemplate\DT_String.py, line 473, in __call__
    (Object: barcall)
  File C:\Zope\lib\python\DocumentTemplate\DT_Util.py, line 159, in eval
    (Object: bar(100,100))
    (Info: bar)
  File &lt;string&gt;, line 2, in f
AttributeError: (see above)

I have nearly got this product working the way I want it to, so any help you can give will be greatly appreciated.</PRE><PRE>Regards</PRE><PRE>Sean Kemplay</PRE><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Yahoo! Mail Plus</a> - Powerful. Affordable. <a href="http://rd.yahoo.com/mail/mailsig/*http://mailplus.yahoo.com">Sign up now</a>
--0-815922956-1038035090=:38729--