[Zope3-dev] Inline code
Shane Hathaway
shane at zope.com
Tue Feb 10 10:27:37 EST 2004
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. :-)
Pros:
- You can write code inline. It would replace the need for complex
expressions.
- Unlike the current script tag, moving the inline code to a separate
module is always straightforward. 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.
It's a lot more like CSS, since CSS styles apply to the whole document
regardless of what part of the document defines them.
Hmm, I can't think of any more cons. :-) This seems like a big win
overall. Maybe we could try this in Zope 2 first.
Shane
More information about the Zope3-dev
mailing list