[Zope] strange 'print' behavior in Python Scripts

zbir@urbanape.com zbir@urbanape.com
Fri, 29 Jun 2001 15:44:04 -0400


> I suppose this has to do with the way PythonScripts are interpreted. As
> you may have noticed, Zope prepends a function definition line like "def
> your_id(args...):" to the text of your PythonScript before evaluating it
> (that is why errors in PythonScripts are reported with the line count
> off by one). 
> 
> In order to make the whole block syntatically valid, the body of the
> function must be indented relative to the function definition. So before
> evaluating your function, Zope must prepend a space in each line. It
> should be smart enough to treat triple-quotes differently, but it isn't.
> 
> Now, I think the need to use triple-quoted strings can imply a design
> problem: it means you are embedding the template in your code, which is
> often a bad idea. Without knowing what you are doing, I would try and
> separate the embedded template from the Python logic.

Just started getting into the nitty and gritty of Python Scripts ( I've 
been using 2.2.5 for a while previously ), I was wondering if we couldn't
just put the whole def: statement in the data box. It would make porting
that much easier, if I could just stick a whole python script in there,
def statement and all. and if it was all already indented, so much the
better.

me = { 'name' : 'Zachery Bir', 'email' : 'zbir@urbanape.com',
       'voice' : '(804) 353-3742', 'url' : 'http://www.urbanape.com/' }