[Zope3-dev] Re: Inline code

Paul Winkler pw_lists at slinkp.com
Tue Feb 10 11:39:46 EST 2004


On Tue, Feb 10, 2004 at 10:27:37AM -0500, Shane Hathaway wrote:
> On Mon, 9 Feb 2004, Shane Hathaway wrote:
> 
> > Further, one way to make inline code portable is to treat inline code as a
> > module, rather than as a collection of anonymous code blocks.  For
> > example:
> > 
> > <html>
> > <head><title>Shane's Example</title>
> > <script type="text/server-python">
> > import time
> > def showtime():
> >     return time.asctime()
> > </script>
> > </head>
> > <body>
> > Date and time: <span tal:content="code/showtime">(time)</span>.
> > </body>
> > </html>
> 
> I'm surprised I received no response on this.  I'll help you guys start
> debating. :-)

OK fine, I can't resist ... debate ensues :-)
 
> Pros:
> 
> - You can write code inline.  It would replace the need for complex
> expressions.

*shrug*  give me TTW libraries and I'd never need this.
i guess some people would like it.
 
> - Unlike the current script tag, moving the inline code to a separate
> module is always straightforward. 

Ah, my favorite horse to flog. This is *really* important.
If we're determined to give people mess-enabling tools,
we must take steps to ease the burden on the guy who gets
to clean it up later!

This means that you should never have to learn one way
of doing something in inline python, another way in
Script (Python), yet another way in modules.
Zope 2 accumulated a number of these inconsistencies
and they are very trying for a newcomer.

We all know this, otherwise nobody would have cared to
replace "here" with "context". Let's apply that principle
everywhere. Therefore, no print statements, please.

> Once it's in a separate module, you get
> all the manageability of Python modules.
 
> - Unlike the current script tag, we don't have to manipulate print
> statements.  In fact, for the whole story to work, we might not allow
> print statements (except perhaps as a debugging tool.)

> Cons:
> 
> - It's not like Javascript; there is no "document.write()" equivalent.

What does document.write() allow that tal/content and tal/replace does
not? I have done very little javascript.


-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's THE WHIZZING SKULL!
(random hero from isometric.spaceninja.com)



More information about the Zope3-dev mailing list