[Zope3-dev] Re: Zope 3 Newsletter: Issue 10

Jim Fulton jim at zope.com
Sun Sep 7 10:14:59 EDT 2003


Chris Withers wrote:
> Gary Poster wrote:
> 
>>   Python <script> support in TAL
>>
>>     I finally got around implementing a TAL "script" attribute to
>>     work. The  support was mainly written for scripters to give
>>     them a better entry point to  Zope 3. Here an example of what
>>     you can do:
>>
>>       <script type="text/server-python">
>>         print "Hello World!"
>>       </script>
> 
> 
> YUK!
> 
> Why? Where was the discussion for this?

On IRC mainly.  Given how controversal this is, and was bound to be,
we really should have done a proposal.  I suppose it's not to late
to do so.

> What's the rational.

See my note on "Scripters vs developers". Scripters want quick and
dirthy solutions. Speed is important. Disciplione is not important.
For scripters, embedding some script code in their templates makes
a lot of sense.  If I have a one-off page and some code
that's needed only for that page, the quickest easiest thing I can do
is to include that code in the template.  Alternatively, I have to stick
some other Python thing in the folder with the template and manage that
Python thing as well. This extra Python thing now clutters up my content.
This would be OK if it was going to be shared among multiple pages,
but if it's only going to be used for a single page, it might even
be cleaner to embed it in the page. This choice only makes sense for
active content, where we are actually doing things in content space.

Now developers will make a differenr choice. Developers don't
work in content space. They put there things in site-management folders.
Their Python code will me in modules. Their templates will be contain
little or no Python code because there separation of presentation and code
had benefits when building reuasable (as opposed to one-off) complex
applications.  Developers won't use the script tag.

BTW, I think that a more common use of script tags will be to actually
embed moduleish things:

   <script>
      <!--

	from foo,bar import baz

         def something():
            ...

         def somethingelse(x, y):
            ...

      -->
   </script>

   <p tal:content="baz">blah blah</p>
   <p tal:content="something">blah blah</p>
   <p tal:content="python: somethingelse(splat, eek)">blah blah</p>

I suspect that this example would have been less offensive.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (703) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the Zope3-dev mailing list