[Checkins] SVN: megrok.cheetah/trunk/ Initial upload of package. Basic functionality with passing tests
Paul Wilson
paulalexwilson at gmail.com
Mon Mar 30 16:41:27 EDT 2009
Log message for revision 98630:
Initial upload of package. Basic functionality with passing tests
Changed:
A megrok.cheetah/trunk/CHANGES.txt
A megrok.cheetah/trunk/README.txt
A megrok.cheetah/trunk/TODO.txt
A megrok.cheetah/trunk/bootstrap/
A megrok.cheetah/trunk/bootstrap/bootstrap.py
A megrok.cheetah/trunk/buildout.cfg
A megrok.cheetah/trunk/setup.py
A megrok.cheetah/trunk/src/
A megrok.cheetah/trunk/src/megrok/
A megrok.cheetah/trunk/src/megrok/__init__.py
A megrok.cheetah/trunk/src/megrok/cheetah/
A megrok.cheetah/trunk/src/megrok/cheetah/__init__.py
A megrok.cheetah/trunk/src/megrok/cheetah/components.py
A megrok.cheetah/trunk/src/megrok/cheetah/configure.zcml
A megrok.cheetah/trunk/src/megrok/cheetah/ftesting.zcml
A megrok.cheetah/trunk/src/megrok/cheetah/tests/
A megrok.cheetah/trunk/src/megrok/cheetah/tests/__init__.py
A megrok.cheetah/trunk/src/megrok/cheetah/tests/static/
A megrok.cheetah/trunk/src/megrok/cheetah/tests/static/test.css
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate.py
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/cavepainting.tmpl
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/food.tmpl
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/hunter.tmpl
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmpl
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmplc
A megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/static.tmpl
-=-
Added: megrok.cheetah/trunk/CHANGES.txt
===================================================================
--- megrok.cheetah/trunk/CHANGES.txt (rev 0)
+++ megrok.cheetah/trunk/CHANGES.txt 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,7 @@
+CHANGES
+=======
+
+Version 0.1
+-----------
+
+- Initial release
Property changes on: megrok.cheetah/trunk/CHANGES.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/README.txt
===================================================================
--- megrok.cheetah/trunk/README.txt (rev 0)
+++ megrok.cheetah/trunk/README.txt 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,87 @@
+megrok.cheetah
+==============
+
+megrok.cheetah makes it possible to use Cheetah templates in Grok.
+
+For more information about Grok and Cheetah visit:
+
+- http://grok.zope.org/
+- http://www.cheetahtemplate.org/
+
+Requirements
+------------
+
+- Grok v1.0a or later. Tested with Grok v1.0a.
+- Cheetah v2.0.1 or later. Tested with Cheetah v2.0.1
+
+Installation
+------------
+
+To use the Cheetah templates within Grok, megrok.cheetah must be first
+installed as an egg, and its ZCML included. After using grokproject,
+amend the setup.py to look like this:
+
+ install_requires=[''setuptools',
+ 'grok',
+ 'megrok.cheetah',
+ # Add extra requirements here
+ ],
+
+Then include megrok.cheetah in your configure.zcml. It should look
+something like this:
+
+ <configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:grok="http://namespaces.zope.org/grok">
+ <include package="grok" />
+ <include package="megrok.cheetah"/>
+ <grok:grok package="." />
+ </configure>
+
+Rerun buildout (bin/buildout), giving you something like:
+
+ Getting distribution for 'megrok.cheetah'.
+ Got megrok.cheetah 0.1
+
+That's it. You can now place Cheetah templates (with the .ch extension)
+into any template directory used within your project.
+
+Usage
+-----
+
+megrok.cheetah allows you to use the standard pattern of placing
+templates into a specially named directory (e.g. app_templates).
+megrok.cheetah uses the special file extension of '.tmpl' to distinguish
+Cheetah templates from others.
+
+You can use Cheetah templates inline:
+
+ from megrok.cheetah.components import CheetahTemplate
+ index = CheetahTemplate('<html>ME BASH CHEETAH</html>')
+
+Or from a file:
+
+ from megrok.cheetah.components import CheetahTemplate
+ index = CheetahTemplate(filename='thefilename.html')
+
+In addition, megrok.cheetah has support for compiled Cheetah templates.
+To use this, you must compile your Cheetah template to suppress its
+default of automatically calling callables in the namespace that it
+is passed. You accomplish this using the ``compiler-settings``
+directive:
+
+ #compiler-settings
+ useAutocalling = False
+ #end compiler-settings
+
+within your template to be compiled. If you do not include this,
+you will experience problems.
+
+Authors
+-------
+
+- Paul A. Wilson
+
+Thanks
+------
+
+- Lennart Regebro & Guido Wesdorp (for megrok.genshi)
Property changes on: megrok.cheetah/trunk/README.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/TODO.txt
===================================================================
--- megrok.cheetah/trunk/TODO.txt (rev 0)
+++ megrok.cheetah/trunk/TODO.txt 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,5 @@
+TODO
+====
+
+ * Profiling
+ * Extended test cases
Property changes on: megrok.cheetah/trunk/TODO.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/bootstrap/bootstrap.py
===================================================================
--- megrok.cheetah/trunk/bootstrap/bootstrap.py (rev 0)
+++ megrok.cheetah/trunk/bootstrap/bootstrap.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 80558 2007-10-03 18:24:08Z regebro $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+ import pkg_resources
+except ImportError:
+ ez = {}
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: megrok.cheetah/trunk/bootstrap/bootstrap.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/buildout.cfg
===================================================================
--- megrok.cheetah/trunk/buildout.cfg (rev 0)
+++ megrok.cheetah/trunk/buildout.cfg 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,56 @@
+[buildout]
+develop = .
+parts = app data zopectl test
+find-links = http://download.zope.org/distribution/
+newest = false
+
+[data]
+recipe = zc.recipe.filestorage
+
+[app]
+recipe = zc.zope3recipes>=0.5.3:application
+eggs = megrok.cheetah
+site.zcml = <include package="megrok.cheetah" />
+ <include package="zope.app.twisted" />
+
+ <unauthenticatedPrincipal id="zope.anybody"
+ title="Unauthenticated User" />
+ <unauthenticatedGroup id="zope.Anybody"
+ title="Unauthenticated Users" />
+ <authenticatedGroup id="zope.Authenticated"
+ title="Authenticated Users" />
+ <everybodyGroup id="zope.Everybody"
+ title="All Users" />
+ <principal id="zope.manager"
+ title="Manager"
+ login="grok"
+ password_manager="Plain Text"
+ password="grok"
+ />
+
+ <!-- Replace the following directive if you don't want
+ public access -->
+ <grant permission="zope.View"
+ principal="zope.Anybody" />
+ <grant permission="zope.app.dublincore.view"
+ principal="zope.Anybody" />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <role id="zope.Member" title="Site Member" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager"
+ principal="zope.manager" />
+
+[data]
+recipe = zc.recipe.filestorage
+
+# this section named so that the start/stop script is called bin/zopectl
+[zopectl]
+recipe = zc.zope3recipes:instance
+application = app
+zope.conf = ${data:zconfig}
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = megrok.cheetah
+defaults = ['--tests-pattern', '^f?tests$', '-v']
Property changes on: megrok.cheetah/trunk/buildout.cfg
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/setup.py
===================================================================
--- megrok.cheetah/trunk/setup.py (rev 0)
+++ megrok.cheetah/trunk/setup.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,37 @@
+from setuptools import setup, find_packages
+
+version = '0.1'
+
+long_description = (open('README.txt').read() +
+ '\n\n' +
+ open('CHANGES.txt').read())
+
+setup(name='megrok.cheetah',
+ version=version,
+ description="Integrate Cheetah Templates into Grok",
+ long_description=long_description,
+ # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+ classifiers=['Development Status :: 3 - Alpha',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ ],
+ keywords="grok cheetah",
+ author="Paul A. Wilson",
+ author_email="paulalexwilson at gmail.com",
+ license="ZPL",
+ package_dir={'': 'src'},
+ packages=find_packages('src'),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=['setuptools',
+ 'grok',
+ 'Cheetah',
+ ],
+ entry_points="""
+ # Add entry points here
+ """,
+ )
Property changes on: megrok.cheetah/trunk/setup.py
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: megrok.cheetah/trunk/src/megrok/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/__init__.py
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/__init__.py (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/__init__.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,13 @@
+##############################################################################
+#
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/components.py
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/components.py (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/components.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,66 @@
+##############################################################################
+#
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import zope.interface
+import os
+import grok
+from grokcore.view.components import GrokTemplate
+from grokcore.view.interfaces import ITemplateFileFactory
+from Cheetah.Template import Template
+from imp import new_module, load_source
+
+# Cheetah, by default, automatically calls callables found within the
+# namespace passed to it. Since the namespace contains the view itself,
+# the result is a circular calling race condition.
+COMPILER_SETTINGS = {'useAutocalling': False}
+class CheetahTemplate(GrokTemplate):
+ def setFromString(self, string):
+ self._template = Template.compile(string,
+ compilerSettings=COMPILER_SETTINGS,
+ )
+ def setFromFilename(self, filename, _prefix=None):
+ file = open(os.path.join(_prefix, filename))
+ self._template = Template.compile(file=file,
+ compilerSettings=COMPILER_SETTINGS,
+ )
+ def render(self, view):
+ return self._template(namespaces=self.getNamespace(view)).respond()
+
+class CheetahTemplateFactory(grok.GlobalUtility):
+ grok.implements(ITemplateFileFactory)
+ grok.name('tmpl')
+
+ def __call__(self, filename, _prefix=None):
+ return CheetahTemplate(filename=filename, _prefix=_prefix)
+
+import sys
+# Since cheetah templates are loaded as modules we create a separate
+# namespace for them to avold collisions.
+CHEETAH_NS = 'megrok.cheetah.ns'
+sys.modules[CHEETAH_NS] = new_module(CHEETAH_NS)
+class CompiledCheetahTemplate(GrokTemplate):
+ def setFromFilename(self, filename, _prefix=None):
+ template_name = os.path.basename(filename).split('.')[0]
+ compiled_module = load_source(CHEETAH_NS + '.' + template_name,
+ os.path.join(_prefix, filename))
+ self._template = getattr(compiled_module, template_name)
+
+ def render(self, view):
+ return self._template(namespaces=self.getNamespace(view)).respond()
+
+class CompiledCheetahTemplateFactory(grok.GlobalUtility):
+ grok.implements(ITemplateFileFactory)
+ grok.name('ctmpl')
+
+ def __call__(self, filename, _prefix=None):
+ return CompiledCheetahTemplate(filename=filename, _prefix=_prefix)
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/components.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/configure.zcml
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/configure.zcml (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/configure.zcml 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,8 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:grok="http://namespaces.zope.org/grok">
+
+ <include package="grok" />
+ <grok:grok package="." />
+
+</configure>
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/configure.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/ftesting.zcml
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/ftesting.zcml (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/ftesting.zcml 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,37 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:grok="http://namespaces.zope.org/grok"
+ i18n_domain="megrok.cheetah"
+ package="megrok.cheetah"
+ >
+
+ <include package="grok" />
+ <grok:grok package="." />
+ <grok:grok package=".tests" />
+
+ <!-- Typical functional testing security setup -->
+ <securityPolicy
+ component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+ />
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User"
+ />
+ <grant
+ permission="zope.View"
+ principal="zope.anybody"
+ />
+
+ <principal
+ id="zope.mgr"
+ title="Manager"
+ login="mgr"
+ password="mgrpw"
+ />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager" principal="zope.mgr" />
+
+</configure>
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/ftesting.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/__init__.py
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/__init__.py (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/__init__.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+# $Id: __init__.py 81774 2007-11-12 18:24:53Z regebro $ $Rev$ $Author$ $Date$
+import os.path
+import megrok.cheetah
+from zope.app.testing.functional import ZCMLLayer
+
+ftesting_zcml = os.path.join(
+ os.path.dirname(megrok.cheetah.__file__), 'ftesting.zcml')
+FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'FunctionalLayer')
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/__init__.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/static/test.css
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/static/test.css (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/static/test.css 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,3 @@
+body {
+ background-color: green;
+}
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/static/test.css
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate.py
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate.py (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate.py 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,119 @@
+##############################################################################
+#
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import grok
+import unittest
+from zope.publisher.browser import TestRequest
+from zope import component
+from megrok.cheetah import components
+
+class Mammoth(grok.Model):
+ pass
+
+class CavePainting(grok.View):
+ pass
+
+class Static(grok.View):
+ pass
+
+class Food(grok.View):
+ text = "ME GROK EAT MAMMOTH!"
+ def me_do(self):
+ return self.text
+
+class Hunter(grok.View):
+ game = "MAMMOTH!"
+
+class Scavenge(grok.View):
+ carcas = "BUFFALO!"
+
+class Inline(grok.View):
+ pass
+
+inline = components.CheetahTemplate("<html><body>ME GROK HAS INLINES!</body></html>")
+
+class CheetahTemplateTests(unittest.TestCase):
+
+ def test_templatedir(self):
+ # Templates can be found in a directory with the same name as the module:
+
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='cavepainting')
+ self.assertEquals(view(), """<html>
+<body>
+A cave painting.
+</body>
+</html>
+""")
+
+ def test_view_access(self):
+ # A template can access variables like "view" and it's
+ # methods and attributes.
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='food')
+ self.assertEquals(view(), """<html>
+<body>
+ME GROK EAT MAMMOTH!
+</body>
+</html>
+""")
+
+ def test_static(self):
+ # The URL of static resources can be gotten from the static variable.
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='static')
+ html = view()
+ self.assert_('@@/megrok.cheetah.tests/test.css' in html)
+
+ def test_snippet(self):
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='food')
+ view.text = "ME GROK EAT <MAMMOTH>!"
+ html = view()
+ self.assert_('ME GROK EAT <MAMMOTH>!' in html)
+
+ def test_texttemplate(self):
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='hunter')
+ text = view()
+ self.assertEquals(text, 'ME GROK HUNT MAMMOTH!!')
+
+ def test_compiledtemplate(self):
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='scavenge')
+ text = view()
+ self.assertEquals(text, 'ME GROK HUNT BUFFALO!!\n')
+
+ def test_inlinetemplate(self):
+ manfred = Mammoth()
+ request = TestRequest()
+ view = component.getMultiAdapter((manfred, request), name='inline')
+ html = view()
+ self.assert_('ME GROK HAS INLINES!' in html)
+
+def test_suite():
+ from megrok.cheetah.tests import FunctionalLayer
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(CheetahTemplateTests))
+ suite.layer = FunctionalLayer
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate.py
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/cavepainting.tmpl
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/cavepainting.tmpl (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/cavepainting.tmpl 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,5 @@
+<html>
+<body>
+A cave painting.
+</body>
+</html>
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/cavepainting.tmpl
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/food.tmpl
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/food.tmpl (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/food.tmpl 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,5 @@
+<html>
+<body>
+$view.me_do()
+</body>
+</html>
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/food.tmpl
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/hunter.tmpl
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/hunter.tmpl (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/hunter.tmpl 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1 @@
+ME GROK HUNT ${view.game}!
\ No newline at end of file
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/hunter.tmpl
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmpl
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmpl (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmpl 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+
+
+
+
+##################################################
+## DEPENDENCIES
+import sys
+import os
+import os.path
+from os.path import getmtime, exists
+import time
+import types
+import __builtin__
+from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
+from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
+from Cheetah.Template import Template
+from Cheetah.DummyTransaction import DummyTransaction
+from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
+from Cheetah.CacheRegion import CacheRegion
+import Cheetah.Filters as Filters
+import Cheetah.ErrorCatchers as ErrorCatchers
+
+##################################################
+## MODULE CONSTANTS
+try:
+ True, False
+except NameError:
+ True, False = (1==1), (1==0)
+VFFSL=valueFromFrameOrSearchList
+VFSL=valueFromSearchList
+VFN=valueForName
+currentTime=time.time
+__CHEETAH_version__ = '2.0.1'
+__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
+__CHEETAH_genTime__ = 1234916790.943553
+__CHEETAH_genTimestamp__ = 'Wed Feb 18 00:26:30 2009'
+__CHEETAH_src__ = 'scavenge.tmpl'
+__CHEETAH_srcLastModified__ = 'Wed Feb 18 00:26:21 2009'
+__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
+
+if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
+ raise AssertionError(
+ 'This template was compiled with Cheetah version'
+ ' %s. Templates compiled before version %s must be recompiled.'%(
+ __CHEETAH_version__, RequiredCheetahVersion))
+
+##################################################
+## CLASSES
+
+class scavenge(Template):
+
+ ##################################################
+ ## CHEETAH GENERATED METHODS
+
+
+ def __init__(self, *args, **KWs):
+
+ Template.__init__(self, *args, **KWs)
+ if not self._CHEETAH__instanceInitialized:
+ cheetahKWArgs = {}
+ allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
+ for k,v in KWs.items():
+ if k in allowedKWs: cheetahKWArgs[k] = v
+ self._initCheetahInstance(**cheetahKWArgs)
+
+
+ def respond(self, trans=None):
+
+
+
+ ## CHEETAH: main method generated for this template
+ if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
+ trans = self.transaction # is None unless self.awake() was called
+ if not trans:
+ trans = DummyTransaction()
+ _dummyTrans = True
+ else: _dummyTrans = False
+ write = trans.response().write
+ SL = self._CHEETAH__searchList
+ _filter = self._CHEETAH__currentFilter
+
+ ########################################
+ ## START - generated method body
+
+ write('''ME GROK HUNT ''')
+ _v = VFFSL(SL,"view.carcas",False) # '${view.carcas}' on line 4, col 14
+ if _v is not None: write(_filter(_v, rawExpr='${view.carcas}')) # from line 4, col 14.
+ write('''!
+''')
+
+ ########################################
+ ## END - generated method body
+
+ return _dummyTrans and trans.response().getvalue() or ""
+
+ ##################################################
+ ## CHEETAH GENERATED ATTRIBUTES
+
+
+ _CHEETAH__instanceInitialized = False
+
+ _CHEETAH_version = __CHEETAH_version__
+
+ _CHEETAH_versionTuple = __CHEETAH_versionTuple__
+
+ _CHEETAH_genTime = __CHEETAH_genTime__
+
+ _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
+
+ _CHEETAH_src = __CHEETAH_src__
+
+ _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
+
+ _mainCheetahMethod_for_scavenge= 'respond'
+
+## END CLASS DEFINITION
+
+if not hasattr(scavenge, '_initCheetahAttributes'):
+ templateAPIClass = getattr(scavenge, '_CHEETAH_templateClass', Template)
+ templateAPIClass._addCheetahPlumbingCodeToClass(scavenge)
+
+
+# CHEETAH was developed by Tavis Rudd and Mike Orr
+# with code, advice and input from many other volunteers.
+# For more information visit http://www.CheetahTemplate.org/
+
+##################################################
+## if run from command line:
+if __name__ == '__main__':
+ from Cheetah.TemplateCmdLineIface import CmdLineIface
+ CmdLineIface(templateObj=scavenge()).run()
+
+
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmpl
___________________________________________________________________
Added: svn:eol-style
+ native
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmplc
===================================================================
(Binary files differ)
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/scavenge.ctmplc
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/static.tmpl
===================================================================
--- megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/static.tmpl (rev 0)
+++ megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/static.tmpl 2009-03-30 20:41:26 UTC (rev 98630)
@@ -0,0 +1,5 @@
+<html>
+<body>
+${static['test.css']()}
+</body>
+</html>
Property changes on: megrok.cheetah/trunk/src/megrok/cheetah/tests/test_cheetahtemplate_templates/static.tmpl
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Checkins
mailing list