[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - interpreter.py:1.2 size.py:1.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Aug 21 11:19:54 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/interfaces
In directory cvs.zope.org:/tmp/cvs-serv8485/src/zope/app/interfaces

Modified Files:
	size.py 
Added Files:
	interpreter.py 
Log Message:
Final HEAD checkin of "Inline Code Support in TAL". For detailed messages 
during the development, see "srichter-inlinepython-branch". I tested the 
code with both, Python 2.2.3 and Python 2.3 and all works fine.

Here an example of what you can do:

  <script type="text/server-python">
    print "Hello World!"
  </script>

and

 <p tal:script="text/server-python">
   print "Hello World!"
 </p>

A more elaborate example would be:

<html><body>
  <script type="text/server-python">
    global x
    x = "Hello World!"
  </script>
  <b tal:content="x" />
</body></html>

This support is currently only available in "Templated Pages" after you 
activate the hook using the "Inline Code" screen.


=== Zope3/src/zope/app/interfaces/interpreter.py 1.1 => 1.2 ===
--- /dev/null	Thu Aug 21 10:19:54 2003
+++ Zope3/src/zope/app/interfaces/interpreter.py	Thu Aug 21 10:19:23 2003
@@ -0,0 +1,60 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Interfaces for Code Interpreters
+
+$Id$
+"""
+from zope.interface import Interface
+
+class IInterpreterService(Interface):
+    """An interpreter service manages the available code interpreters.
+
+    Code interpreters are registered by type, which should be valid content
+    type entries based on the W3C standards. An example would be
+    'text/server-python'.
+    """
+
+    def getInterpreter(type):
+        """Return the interpreter for this type.
+
+        If no interpreter is found, raise a ComponentLookupError.
+        """
+
+    def queryInterpreter(type, default=None):
+        """Return the interpreter for this type.
+
+        If no interpreter is found, return the default value.
+        """
+
+
+class IGlobalInterpreterService(IInterpreterService):
+
+    def provideInterpreter(type, interpreter):
+        """Register a new interpreter with the service."""
+
+
+class IInterpreter(Interface):
+
+    def evaluate(code, globals):
+        """Evaluate the code given the global variables."""
+
+    def evaluateRawCode(code, globals):
+        """Evaluate the code given the global variables.
+
+        However, this method does a little bit more. Sometimes (or in our case
+        often) code might come from an uncontrolled environment, like a page
+        template and is not properly formatted, i.e. indentation, so that some
+        cleanup is necessary. This method does the cleanup before evaluating
+        the code.
+        """


=== Zope3/src/zope/app/interfaces/size.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/interfaces/size.py:1.4	Thu May  1 15:35:21 2003
+++ Zope3/src/zope/app/interfaces/size.py	Thu Aug 21 10:19:23 2003
@@ -1,4 +1,3 @@
-
 ##############################################################################
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.




More information about the Zope3-Checkins mailing list