[Zope3-dev] Python scripts?
Jim Fulton
jim@zope.com
Mon, 12 May 2003 10:24:54 -0400
I'm wondering what form Python scripts should take for Zope 3.
Python scripts in Zope 3 will be "active content":
http://dev.zope.org/Zope3/ActiveContent
created by site scripters:
http://dev.zope.org/Zope3/SiteScripter
Scripters occasionally need to create Python code to:
- Implement one-off applications
- Provide computation for templates
- Manipulate the output of database queries
I see a number of alternatives:
- Port Zope 2 Python scripts
* without the bindings tab
* without context, script, namespace, and subpath variables.
(not sure about script)
Maybe these should be renamed "Python functions", since they aren't really
methods.
- Provide more of a module-like object. This would be a persistent
module that lived in content space. It would not be importable, but
would be accessable via traversal as in:
tal:content="container/somemodule/somefunction"
- Provide Python scripts
These would be written as scripts. They would not be able to
return anything. They would output via print. They would get input
via import. Frankly, I'm not crazy about this, but I mention it for
completeness.
- Provide the ability to define Python functions as part of ZPT, DTML,
and SQL Script definitions. This would appear as an extra tab on
these objects containing Python source.
There are three things I don't like about this approach:
* It complicates the UI for ZPT, DTML, and SQL scripts.
In particular, it complicated the file-system representation.
* It doesn't help in situations where code is to be reused among
multiple templates,
* It closely ties ZPT, DTML, and SQL scripts to Python. I'd love,
someday, to be able to support other scripting languages
(e.g. perl) and integrating Python so closely would make this
harder.
Thoughts?
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (703) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org