[Zope3-checkins] CVS: Zope3/src/zope/app/browser/content - zpt_inlinecode.pt:1.2 configure.zcml:1.37

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


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

Modified Files:
	configure.zcml 
Added Files:
	zpt_inlinecode.pt 
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/browser/content/zpt_inlinecode.pt 1.1 => 1.2 ===
--- /dev/null	Thu Aug 21 10:19:52 2003
+++ Zope3/src/zope/app/browser/content/zpt_inlinecode.pt	Thu Aug 21 10:19:21 2003
@@ -0,0 +1,82 @@
+<tal:tag condition="view/update"
+/><html metal:use-macro="views/standard_macros/page">
+  <body>
+  <div metal:fill-slot="body">
+
+  <div metal:define-macro="body">
+
+    <form action="." tal:attributes="action request/URL" method="POST"
+          enctype="multipart/form-data">
+
+      <div metal:define-macro="formbody">
+
+        <h3 tal:condition="view/label"
+            tal:content="view/label"
+            metal:define-slot="heading"
+            >Edit something</h3>
+
+        <div style="color:red; font-weight: bold">
+          <p i18n:translate="">
+            This screen allows you to activate Inline Code Evaluation. This
+            means that you can say
+            <span i18n:name="code-example-1"><pre>
+               &nbsp;&lt;script type="text/server-python"&gt;<br/>
+               &nbsp;&nbsp;print "Hello World!"<br/>
+               &lt;/script&gt;
+            </pre></span>
+            or
+            <span i18n:name="code-example-2"><pre>
+               &nbsp;&lt;p tal:script="text/server-python"&gt;<br/>
+               &nbsp;&nbsp;print "Hello World!"<br/>
+               &lt;/p&gt;
+            </pre></span>
+          </p>
+          <p i18n:translate="">
+            Now, many Zope 3 developers consider inline code blocks something
+            very bad, since it does not follow the design of Page Templates
+            or Zope 3 in general. However, application and application server
+            developers are not the only audience for Zope 3. Scripters are
+            used to inline code from other technologies liek PHP and it fits
+            their brain, which is very important.
+          </p>
+        </div>
+
+        <p tal:define="status view/update"
+           tal:condition="status"
+           tal:content="status" />
+
+         <p tal:condition="view/errors" i18n:translate="">
+           There are  <strong tal:content="python:len(view.errors)"
+                              i18n:name="num_errors">6</strong> input errors.
+        </p>
+
+        <tal:block repeat="error view/errors">
+          <div class="error" tal:content="error">error</div>
+        </tal:block>
+
+        <div class="row"
+             metal:define-macro="widget_rows" tal:repeat="widget view/widgets"
+             tal:content="structure widget/row">
+            <div class="label">Name</div>
+            <div class="field"><input type="text" style="width:100%" /></div>
+        </div>
+
+      </div>
+
+      <div class="row">
+        <div class="controls">
+          <input type="submit" value="Refresh" 
+              i18n:attributes="value refresh-button" />
+          <input type="submit" name="UPDATE_SUBMIT" value="Submit" 
+              i18n:attributes="value submit-button"/>
+        </div>
+      </div>
+
+    </form>
+
+  </div>
+
+  </div>
+  </body>
+
+</html>


=== Zope3/src/zope/app/browser/content/configure.zcml 1.36 => 1.37 ===
--- Zope3/src/zope/app/browser/content/configure.zcml:1.36	Wed Aug 20 14:21:03 2003
+++ Zope3/src/zope/app/browser/content/configure.zcml	Thu Aug 21 10:19:21 2003
@@ -196,11 +196,23 @@
       permission="zope.ManageContent" />
 
   <editform
+      for="zope.app.content.zpt.IZPTPage"
       schema="zope.app.content.zpt.IZPTPage"
       name="edit.html"
-      menu="zmi_views"
       label="Edit a ZPT page"
-      permission="zope.ManageContent" />
+      fields="source expand"
+      permission="zope.ManageContent" 
+      menu="zmi_views" title="Edit"/>
+
+  <editform
+      for="zope.app.content.zpt.IZPTPage"
+      schema="zope.app.content.zpt.IZPTPage"
+      name="inlineCode.html"
+      label="Inline Code"
+      fields="evaluateInlineCode"
+      template="zpt_inlinecode.pt"
+      permission="zope.ManageContent" 
+      menu="zmi_views" title="Inline Code"/>
 
   <page
       for="zope.app.content.zpt.IZPTPage"




More information about the Zope3-Checkins mailing list