[Zope] Re: Parameters for external methods and page templates

Andreas Tille tillea@rki.de
Mon, 16 Sep 2002 14:02:47 +0200 (CEST)


On Thu, 12 Sep 2002, Dieter Maurer wrote:

> Andreas Tille writes:
>  >       def MakeThumbHi2(self, image="bland.gif", width, height):
>  >                        ^^^^
> This is invalid Python. You must not have arguments without default
> after one with a default value.
Thanks.  This was the solution.  Beeing not very familiar with python
I've thought that self is an exception from this rule because this
would mean that I can not have any default arguments if there is a
self argument.  Or can I use self even at the end of the parameter list?

Once one problem is solved - I'm facing the next (as usual :) ).

The Python Method I'm using is rendering a PNG image and returns it
as string (right es it is done in http://www.zopelabs.com/cookbook/1010702887).

I can use it in dtml as

    <img src="inzidenz?argument=1" alt="Comment" />

and the page is rendered as expected.  But I found no working way to use
any kind of Python-like syntax.  I tried several things with page templates
and dtml.  The only thing happened when I tried Python like syntax was
that the rendered string was put inplace and I've got something like

    <img src="<binary PNG image inserted here>" alt="Comment" />

which is bviousely not what I want.

Moreover I have real trouble in debugging the correctness of the
parameter values.  I tried something like

          fp = open('/tmp/my_debug.log', 'a')
          print >>fp, "argument = " + argument
	  fp.close()

in the External Python method.  I have no clue why this file is not
created or appended at all.

Kind regards

          Andreas.