[Commits] r473 - website
commits at geoext.org
commits at geoext.org
Sat Apr 25 18:13:57 CEST 2009
Author: tschaub
Date: 2009-04-25 18:13:57 +0200 (Sat, 25 Apr 2009)
New Revision: 473
Modified:
website/jst.py
website/jst.txt
Log:
removing context in favor of using filters in templates
Modified: website/jst.py
===================================================================
--- website/jst.py 2009-04-25 00:47:17 UTC (rev 472)
+++ website/jst.py 2009-04-25 16:13:57 UTC (rev 473)
@@ -59,13 +59,13 @@
if filename.endswith(SUFFIX_JS) and not filename.startswith("."):
filepath = os.path.join(root, filename)[len(sourcedir)+1:]
jsfile = SourceFile.from_filename(os.path.join(sourcedir, filepath))
- if jsfile.context:
+ if jsfile.data:
template_filename = os.path.join(sourcedir, filepath.split(SUFFIX_JS)[0] + SUFFIX_JST)
if not os.path.exists(template_filename):
# throw something if template not given in config here
template_filename = cfg["template"]
template = Template(open(template_filename, "U").read())
- out = template.render(jsfile.context)
+ out = template.render(jsfile.data)
output_filename = os.path.join(outdir, filepath.split(SUFFIX_JS)[0] + SUFFIX_RST)
f = open(output_filename, "w")
f.write(out)
@@ -160,23 +160,6 @@
self._data = None
return self._data
- @property
- def context(self):
- if self._context == _marker:
- data = self.data
- if data:
- context = {}
- for (key, val) in data.items():
- if isinstance(val, dict):
- # create ordered lists out of dictionaries
- context[key] = [val[k] for k in sorted(val.keys())]
- else:
- context[key] = val
- self._context = context
- else:
- self._context = None
- return self._context
-
Modified: website/jst.txt
===================================================================
--- website/jst.txt 2009-04-25 00:47:17 UTC (rev 472)
+++ website/jst.txt 2009-04-25 16:13:57 UTC (rev 473)
@@ -84,19 +84,3 @@
>>> obj.data['convenient']
'way'
-The context attribute is a simpler structure, similar to the data but with
-dictionaries as sorted lists::
-
- >>> from pprint import pprint
- >>> obj.context.keys()
- ['bar', 'keys', 'convenient', 'to', 'chicken', 'foo']
- >>> obj.data.keys() == obj.context.keys()
- True
- >>> pprint(obj.data['chicken'])
- {'pie': 'These will be dictionaries in the data and lists in the context.\n',
- 'rat': 'This will eventually allow for access to inherited data.\n',
- 'soup': 'Names in brackets for a sorted list.\n'}
- >>> pprint(obj.context['chicken'])
- ['These will be dictionaries in the data and lists in the context.\n',
- 'This will eventually allow for access to inherited data.\n',
- 'Names in brackets for a sorted list.\n']
More information about the Commits
mailing list