Commit 802b2476 authored by Shane Hathaway's avatar Shane Hathaway

Added "context", a synonym of "here", to page template namespaces.

This unifies the convention in templates, scripts, and Zope 3.
parent c54cd699
......@@ -15,7 +15,7 @@
HTML- and XML-based template objects using TAL, TALES, and METAL.
"""
__version__='$Revision: 1.30 $'[11:-2]
__version__='$Revision: 1.31 $'[11:-2]
import sys
......@@ -69,6 +69,7 @@ class PageTemplate(Base):
parent = getattr(self, 'aq_parent', None)
if parent is not None:
c['here'] = parent
c['context'] = parent
c['container'] = self.aq_inner.aq_parent
while parent is not None:
self = parent
......
......@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template from the filesystem.
"""
__version__ = '$Revision: 1.28 $'[11:-2]
__version__ = '$Revision: 1.29 $'[11:-2]
import os, AccessControl
from Globals import package_home, DevelopmentMode
......@@ -70,8 +70,10 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
def pt_getContext(self):
root = self.getPhysicalRoot()
context = self._getContext()
c = {'template': self,
'here': self._getContext(),
'here': context,
'context': context,
'container': self._getContainer(),
'nothing': None,
'options': {},
......
......@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template.
"""
__version__='$Revision: 1.45 $'[11:-2]
__version__='$Revision: 1.46 $'[11:-2]
import os, AccessControl, Acquisition, sys
from types import StringType
......@@ -172,8 +172,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def pt_getContext(self):
root = self.getPhysicalRoot()
context = self._getContext()
c = {'template': self,
'here': self._getContext(),
'here': context,
'context': context,
'container': self._getContainer(),
'nothing': None,
'options': {},
......
......@@ -2,18 +2,18 @@
<head><title>Test of documentation templates</title></head>
<body>
<span tal:replace="nothing"> blah </span>
<dl tal:condition="here/args">
<dl tal:condition="context/args">
<dt>The arguments to this test program were:</dt>
<dd>
<ul>
<li tal:repeat="arg here/args">
<li tal:repeat="arg context/args">
Argument number <span tal:replace="arg/num">99</span>
is <span tal:replace="arg/arg">default</span>
</li>
</ul>
</dd>
</dl>
<p tal:condition="not:here/args">No arguments were given.</p>
<p tal:condition="not:context/args">No arguments were given.</p>
And thats da trooth.
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment