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 @@ ...@@ -15,7 +15,7 @@
HTML- and XML-based template objects using TAL, TALES, and METAL. 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 import sys
...@@ -69,6 +69,7 @@ class PageTemplate(Base): ...@@ -69,6 +69,7 @@ class PageTemplate(Base):
parent = getattr(self, 'aq_parent', None) parent = getattr(self, 'aq_parent', None)
if parent is not None: if parent is not None:
c['here'] = parent c['here'] = parent
c['context'] = parent
c['container'] = self.aq_inner.aq_parent c['container'] = self.aq_inner.aq_parent
while parent is not None: while parent is not None:
self = parent self = parent
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template from the filesystem. Zope object encapsulating a Page Template from the filesystem.
""" """
__version__ = '$Revision: 1.28 $'[11:-2] __version__ = '$Revision: 1.29 $'[11:-2]
import os, AccessControl import os, AccessControl
from Globals import package_home, DevelopmentMode from Globals import package_home, DevelopmentMode
...@@ -70,8 +70,10 @@ class PageTemplateFile(Script, PageTemplate, Traversable): ...@@ -70,8 +70,10 @@ class PageTemplateFile(Script, PageTemplate, Traversable):
def pt_getContext(self): def pt_getContext(self):
root = self.getPhysicalRoot() root = self.getPhysicalRoot()
context = self._getContext()
c = {'template': self, c = {'template': self,
'here': self._getContext(), 'here': context,
'context': context,
'container': self._getContainer(), 'container': self._getContainer(),
'nothing': None, 'nothing': None,
'options': {}, 'options': {},
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
Zope object encapsulating a Page Template. Zope object encapsulating a Page Template.
""" """
__version__='$Revision: 1.45 $'[11:-2] __version__='$Revision: 1.46 $'[11:-2]
import os, AccessControl, Acquisition, sys import os, AccessControl, Acquisition, sys
from types import StringType from types import StringType
...@@ -172,8 +172,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, ...@@ -172,8 +172,10 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
def pt_getContext(self): def pt_getContext(self):
root = self.getPhysicalRoot() root = self.getPhysicalRoot()
context = self._getContext()
c = {'template': self, c = {'template': self,
'here': self._getContext(), 'here': context,
'context': context,
'container': self._getContainer(), 'container': self._getContainer(),
'nothing': None, 'nothing': None,
'options': {}, 'options': {},
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
<head><title>Test of documentation templates</title></head> <head><title>Test of documentation templates</title></head>
<body> <body>
<span tal:replace="nothing"> blah </span> <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> <dt>The arguments to this test program were:</dt>
<dd> <dd>
<ul> <ul>
<li tal:repeat="arg here/args"> <li tal:repeat="arg context/args">
Argument number <span tal:replace="arg/num">99</span> Argument number <span tal:replace="arg/num">99</span>
is <span tal:replace="arg/arg">default</span> is <span tal:replace="arg/arg">default</span>
</li> </li>
</ul> </ul>
</dd> </dd>
</dl> </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. And thats da trooth.
</body> </body>
</html> </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