[Zope3-checkins] CVS: Zope3/src/zope/app/content - configure.zcml:1.27 zpt.py:1.15

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


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

Modified Files:
	configure.zcml zpt.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/content/configure.zcml 1.26 => 1.27 ===
--- Zope3/src/zope/app/content/configure.zcml:1.26	Wed Aug 20 14:21:08 2003
+++ Zope3/src/zope/app/content/configure.zcml	Thu Aug 21 10:19:22 2003
@@ -203,7 +203,7 @@
   <require
       permission="zope.ManageContent"
       interface="zope.app.interfaces.content.zpt.IZPTPage"
-      set_attributes="source expand" />
+      set_attributes="source expand evaluateInlineCode" />
 
   <require
       permission="zope.View"


=== Zope3/src/zope/app/content/zpt.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/content/zpt.py:1.14	Wed Aug  6 10:45:10 2003
+++ Zope3/src/zope/app/content/zpt.py	Thu Aug 21 10:19:22 2003
@@ -40,19 +40,31 @@
 
     implements(IZPTPage, IRenderZPTPage)
 
+    # See zope.app.interfaces.content.zpt.IZPTPage
     expand = False
 
+    # See zope.app.interfaces.content.zpt.IZPTPage
+    evaluateInlineCode = False
+
     def getSource(self):
-        '''See IZPTPage'''
+        '''See zope.app.interfaces.content.zpt.IZPTPage'''
         return self.read()
 
     def setSource(self, text, content_type='text/html'):
-        '''See IZPTPage'''
+        '''See zope.app.interfaces.content.zpt.IZPTPage'''
         if not isinstance(text, unicode):
             raise TypeError("source text must be Unicode" , text)
-
         self.pt_edit(text.encode('utf-8'), content_type)
 
+    # See zope.app.interfaces.content.zpt.IZPTPage
+    source = property(getSource, setSource, None,
+                      """Source of the Page Template.""")
+
+    def pt_getEngineContext(self, namespace):
+        context = self.pt_getEngine().getContext(namespace)
+        context.evaluateInlineCode = self.evaluateInlineCode
+        return context
+
     def pt_getContext(wrapped_self, instance, request, **_kw):
         # instance is a View component
         self = removeAllProxies(wrapped_self)
@@ -78,9 +90,6 @@
         return self.pt_render(namespace)
 
     render = ContextMethod(render)
-
-    source = property(getSource, setSource, None,
-                      """Source of the Page Template.""")
 
 
 class SearchableText:




More information about the Zope3-Checkins mailing list