Permalink
Browse files

Merge commit 'origin/next' into slide-compat

Le sigh

Conflicts:
	cheetah/Version.py
  • Loading branch information...
2 parents 4490f68 + 9bc0b37 commit 290f5e45c04f82034d700cf016d71e6256f1058e @rtyler rtyler committed Sep 1, 2009
Showing with 2,162 additions and 5,434 deletions.
  1. +1 −1 BUGS
  2. +11 −0 CHANGES
  3. +37 −20 SetupConfig.py
  4. +2 −18 SetupTools.py
  5. +1 −1 TODO
  6. +2 −2 bin/cheetah
  7. +2 −4 bin/cheetah-compile
  8. 0 {src → cheetah}/CacheRegion.py
  9. 0 {src → cheetah}/CacheStore.py
  10. +23 −2 {src → cheetah}/CheetahWrapper.py
  11. +45 −40 {src → cheetah}/Compiler.py
  12. +16 −0 cheetah/Django.py
  13. +0 −1 {src → cheetah}/DummyTransaction.py
  14. +0 −1 {src → cheetah}/ErrorCatchers.py
  15. +0 −1 {src → cheetah}/FileUtils.py
  16. +15 −23 {src → cheetah}/Filters.py
  17. +0 −1 {src → cheetah}/ImportHooks.py
  18. +0 −1 {src → cheetah}/ImportManager.py
  19. 0 {src → cheetah}/Macros/I18n.py
  20. 0 {src/Utils → cheetah/Macros}/__init__.py
  21. +5 −1 {src → cheetah}/NameMapper.py
  22. +38 −2 {src → cheetah}/Parser.py
  23. +5 −6 {src → cheetah}/Servlet.py
  24. +3 −31 {src → cheetah}/SettingsManager.py
  25. +0 −1 {src → cheetah}/SourceReader.py
  26. +49 −51 {src → cheetah}/Template.py
  27. +0 −1 {src → cheetah}/TemplateCmdLineIface.py
  28. +0 −1 {src → cheetah}/Templates/SkeletonPage.py
  29. 0 {src → cheetah}/Templates/SkeletonPage.tmpl
  30. +0 −1 {src → cheetah}/Templates/_SkeletonPage.py
  31. +1 −0 cheetah/Templates/__init__.py
  32. +46 −51 {src → cheetah}/Tests/CheetahWrapper.py
  33. +39 −0 cheetah/Tests/Cheps.py
  34. +4 −1 {src → cheetah}/Tests/Filters.py
  35. +3 −16 {src → cheetah}/Tests/NameMapper.py
  36. +106 −0 {src → cheetah}/Tests/Regressions.py
  37. +2 −11 {src → cheetah}/Tests/SyntaxAndOutput.py
  38. +18 −33 {src → cheetah}/Tests/Template.py
  39. +2 −4 {src → cheetah}/Tests/Test.py
  40. +23 −2 {src → cheetah}/Tests/Unicode.py
  41. 0 {src/Tools/turbocheetah/tests → cheetah/Tests}/__init__.py
  42. 0 {src → cheetah}/Tests/unittest_local_copy.py
  43. 0 {src → cheetah}/Tests/xmlrunner.py
  44. +0 −1 {src → cheetah}/Tools/CGITemplate.py
  45. +0 −1 {src → cheetah}/Tools/MondoReport.py
  46. 0 {src → cheetah}/Tools/MondoReportDoc.txt
  47. +0 −1 {src → cheetah}/Tools/RecursiveNull.py
  48. +0 −1 {src → cheetah}/Tools/SiteHierarchy.py
  49. 0 {src → cheetah}/Tools/__init__.py
  50. 0 {src → cheetah}/Tools/turbocheetah/__init__.py
  51. 0 {src → cheetah}/Tools/turbocheetah/cheetahsupport.py
  52. 0 {src/Tests → cheetah/Tools/turbocheetah/tests}/__init__.py
  53. 0 {src → cheetah}/Tools/turbocheetah/tests/test_template.py
  54. 0 {src → cheetah}/Unspecified.py
  55. +12 −24 {src → cheetah}/Utils/Indenter.py
  56. +0 −1 {src → cheetah}/Utils/Misc.py
  57. +2 −1 {src → cheetah}/Utils/VerifyType.py
  58. +0 −1 {src → cheetah}/Utils/WebInputMixin.py
  59. 0 {src/Macros → cheetah/Utils}/__init__.py
  60. 0 {src → cheetah}/Utils/htmlDecode.py
  61. 0 {src → cheetah}/Utils/htmlEncode.py
  62. +0 −1 {src → cheetah}/Utils/memcache.py
  63. 0 {src → cheetah}/Utils/statprof.py
  64. +2 −2 {src → cheetah}/Version.py
  65. +0 −2 {src → cheetah}/__init__.py
  66. +47 −0 cheetah/c/Cheetah.h
  67. +93 −0 cheetah/c/_filters.c
  68. +5 −2 {src → cheetah/c}/_namemapper.c
  69. +52 −0 cheetah/c/_template.c
  70. +107 −0 cheetah/c/_verifytype.c
  71. 0 {src → cheetah}/convertTmplPathToModuleName.py
  72. +0 −1 src/Templates/__init__.py
  73. +220 −0 src/Tests/Performance.py
  74. +157 −0 src/Tests/VerifyType.py
  75. 0 src/contrib/__init__.py
  76. +0 −30 src/contrib/markdown/LICENSE
  77. +0 −603 src/contrib/markdown/__init__.py
  78. +0 −95 src/contrib/markdown/blockparser.py
  79. +0 −460 src/contrib/markdown/blockprocessors.py
  80. +0 −96 src/contrib/markdown/commandline.py
  81. +0 −33 src/contrib/markdown/etree_loader.py
  82. 0 src/contrib/markdown/extensions/__init__.py
  83. +0 −95 src/contrib/markdown/extensions/abbr.py
  84. +0 −224 src/contrib/markdown/extensions/codehilite.py
  85. +0 −104 src/contrib/markdown/extensions/def_list.py
  86. +0 −49 src/contrib/markdown/extensions/extra.py
  87. +0 −117 src/contrib/markdown/extensions/fenced_code.py
  88. +0 −293 src/contrib/markdown/extensions/footnotes.py
  89. +0 −195 src/contrib/markdown/extensions/headerid.py
  90. +0 −62 src/contrib/markdown/extensions/html_tidy.py
  91. +0 −119 src/contrib/markdown/extensions/imagelinks.py
  92. +0 −468 src/contrib/markdown/extensions/legacy.py
  93. +0 −90 src/contrib/markdown/extensions/meta.py
  94. +0 −114 src/contrib/markdown/extensions/rss.py
  95. +0 −97 src/contrib/markdown/extensions/tables.py
  96. +0 −140 src/contrib/markdown/extensions/toc.py
  97. +0 −155 src/contrib/markdown/extensions/wikilinks.py
  98. +0 −274 src/contrib/markdown/html4.py
  99. +0 −371 src/contrib/markdown/inlinepatterns.py
  100. +0 −162 src/contrib/markdown/odict.py
  101. +0 −77 src/contrib/markdown/postprocessors.py
  102. +0 −214 src/contrib/markdown/preprocessors.py
  103. +0 −329 src/contrib/markdown/treeprocessors.py
  104. +88 −0 www/Makefile
  105. +17 −0 www/chep.rst
  106. +26 −0 www/cheps/1_chep.rst
  107. +122 −0 www/cheps/2_import.rst
  108. +36 −0 www/cheps/3_super.rst
  109. +197 −0 www/conf.py
  110. +49 −0 www/developers.rst
  111. +12 −0 www/documentation.rst
  112. +19 −0 www/download.rst
  113. +82 −0 www/index.rst
  114. +112 −0 www/make.bat
  115. +62 −0 www/recipes/inheritance.rst
  116. +59 −0 www/recipes/precompiled.rst
  117. +54 −0 www/recipes/staticmethod.rst
  118. +4 −0 www/recipes/writing_a_recipe.rst
  119. +27 −0 www/roadmap.rst
View
@@ -1,2 +1,2 @@
-Please see http://bugs.communitycheetah.org
+Please see http://bugs.cheetahtemplate.org
View
@@ -1,4 +1,15 @@
+2.2.2 (Unreleased)
+ - Prevent _namemapper.c from segfaulting when PyImport_ImportModule fails for some reason (Bogdano Arendartchuk <debogdano@gmail.com>)
+ - Removal of the contrib/markdown module (in favor of a setuptools dependency)
+ - Default setup.py to use setuptools by default, failing that, fall back to distutils
+
+2.2.1 (June 1st, 2009)
+ - 0000020: [Templates] Builtin support for using Cheetah with Django (rtyler)
+ - 0000021: [Compiler] @static and @classmethod don't properly define the _filter local (rtyler)
+ - 0000023: [Compiler] Update Template super calls to use super() (rtyler)
+ - Update all references to communitycheetah.org to point back at cheetahtemplate.org
+
2.2.0 (May 17th, 2009)
- Switch all internal representations of template code to unicode objects instead of str() objects
- Convert unicode compiled template to an utf8 char buffer when writing to a file (Jean-Baptiste Quenot <jbq@caraldi.com>)
View
@@ -1,18 +1,16 @@
#-------Main Package Settings-----------#
-name = "Cheetah"
-from src.Version import Version as version
+name = 'Cheetah'
+from cheetah.Version import Version as version
maintainer = "R. Tyler Ballance"
author = "Tavis Rudd"
author_email = "cheetahtemplate-discuss@lists.sf.net"
-url = "http://www.communitycheetah.org/"
+url = "http://www.cheetahtemplate.org/"
packages = ['Cheetah',
'Cheetah.Macros',
'Cheetah.Templates',
'Cheetah.Tests',
'Cheetah.Tools',
'Cheetah.Utils',
- 'Cheetah.contrib',
- 'Cheetah.contrib.markdown',
]
classifiers = [line.strip() for line in '''\
#Development Status :: 4 - Beta
@@ -31,28 +29,47 @@
Topic :: Text Processing'''.splitlines() if not line.strip().startswith('#')]
del line
-package_dir = {'Cheetah':'src'}
+package_dir = {'Cheetah':'cheetah'}
import os
import os.path
from distutils.core import Extension
-## we only assume the presence of a c compiler on Posix systems, NT people will
-# have to enable this manually.
-if os.name == 'posix':
- ext_modules=[Extension("Cheetah._namemapper", [os.path.join("src" ,"_namemapper.c")]
- )
- ]
-else:
- ext_modules=[]
-
+ext_modules=[
+ Extension("Cheetah._namemapper",
+ [os.path.join('cheetah', 'c', '_namemapper.c')]),
+ Extension("Cheetah._verifytype",
+ [os.path.join('cheetah', 'c', '_verifytype.c')]),
+ Extension("Cheetah._filters",
+ [os.path.join('cheetah', 'c', '_filters.c')]),
+ Extension('Cheetah._template',
+ [os.path.join('cheetah', 'c', '_template.c')]),
+ ]
## Data Files and Scripts
scripts = ['bin/cheetah-compile',
'bin/cheetah',
]
-data_files = ['recursive: src *.tmpl *.txt LICENSE README TODO CHANGES',
- ]
+
+data_files = ['recursive: src *.tmpl *.txt LICENSE README TODO CHANGES',]
+
+if not os.getenv('CHEETAH_INSTALL_WITHOUT_SETUPTOOLS'):
+ try:
+ from setuptools import setup
+ install_requires = [
+ "Markdown >= 2.0.1",
+ ]
+ # use 'entry_points' instead of 'scripts'
+ del scripts
+ entry_points = {
+ 'console_scripts': [
+ 'cheetah = Cheetah.CheetahWrapper:_cheetah',
+ 'cheetah-compile = Cheetah.CheetahWrapper:_cheetah_compile',
+ ]
+ }
+ except ImportError:
+ print 'Not using setuptools, so we cannot install the Markdown dependency'
+
description = "Cheetah is a template engine and code generation tool."
@@ -65,7 +82,7 @@
Documentation
================================================================================
For a high-level introduction to Cheetah please refer to the User\'s Guide
-at http://www.communitycheetah.org/learn.html
+at http://www.cheetahtemplate.org/learn.html
Mailing list
================================================================================
@@ -74,10 +91,10 @@
Credits
================================================================================
-http://www.communitycheetah.org/credits.html
+http://www.cheetahtemplate.org/credits.html
Recent Changes
================================================================================
-See http://www.communitycheetah.org/CHANGES.txt for full details
+See http://www.cheetahtemplate.org/CHANGES.txt for full details
'''
View
@@ -1,15 +1,4 @@
#!/usr/bin/env python
-# $Id: SetupTools.py,v 1.9 2007/11/03 19:44:38 tavis_rudd Exp $
-"""Some tools for extending and working with distutils
-
-CREDITS: This module borrows code and ideas from M.A. Lemburg's excellent setup
-tools for the mxBase package.
-
-"""
-
-__author__ = "Tavis Rudd <tavis@damnsimple.com>"
-__version__ = "$Revision: 1.9 $"[11:-2]
-
import os
from os import listdir
import os.path
@@ -20,13 +9,8 @@
import traceback
from distutils.core import setup
-if 'CHEETAH_USE_SETUPTOOLS' in os.environ:
- # @@TR: Please note that this is for testing purposes only! PEAK setuptools
- # is not required or recommended for installing Cheetah. Downstream
- # package managers (linux distros, etc.) should *not* enable this.
+if not os.getenv('CHEETAH_INSTALL_WITHOUT_SETUPTOOLS'):
try:
- # use http://peak.telecommunity.com/DevCenter/setuptools if it's installed
- # requires Py >=2.3
from setuptools import setup
except ImportError:
from distutils.core import setup
@@ -35,7 +19,7 @@
from distutils.command.install_data import install_data
#imports from Cheetah ...
-from src.FileUtils import findFiles
+from cheetah.FileUtils import findFiles
##################################################
## CLASSES ##
View
@@ -1,4 +1,4 @@
-NOTE: Please see http://bugs.communitycheetah.org
+NOTE: Please see http://bugs.cheetahtemplate.org
for future feature requests/bugs/TODO
View
@@ -1,3 +1,3 @@
#!/usr/bin/env python
-from Cheetah.CheetahWrapper import CheetahWrapper
-CheetahWrapper().main()
+from Cheetah.CheetahWrapper import _cheetah
+_cheetah()
View
@@ -1,5 +1,3 @@
#!/usr/bin/env python
-import sys
-from Cheetah.CheetahWrapper import CheetahWrapper
-sys.argv.insert(1, "compile")
-CheetahWrapper().main()
+from Cheetah.CheetahWrapper import _cheetah_compile
+_cheetah_compile()
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# $Id: CheetahWrapper.py,v 1.26 2007/10/02 01:22:04 tavis_rudd Exp $
"""Cheetah command-line interface.
@@ -174,7 +173,19 @@ def parseOpts(self, args):
pao("--parallel", action="store", type="int", dest="parallel", default=1, help='Compile/fill templates in parallel, e.g. --parallel=4')
pao('--shbang', dest='shbang', default='#!/usr/bin/env python', help='Specify the shbang to place at the top of compiled templates, e.g. --shbang="#!/usr/bin/python2.6"')
- self.opts, self.pathArgs = opts, files = self.parser.parse_args(args)
+ opts, files = self.parser.parse_args(args)
+ self.opts = opts
+ if sys.platform == "win32":
+ new_files = []
+ for spec in files:
+ file_list = glob.glob(spec)
+ if file_list:
+ new_files.extend(file_list)
+ else:
+ new_files.append(spec)
+ files = new_files
+ self.pathArgs = files
+
D("""\
cheetah compile %s
Options are
@@ -603,6 +614,16 @@ def _compileOrFillBundle(self, b):
f.close()
+# Called when invoked as `cheetah`
+def _cheetah():
+ CheetahWrapper().main()
+
+# Called when invoked as `cheetah-compile`
+def _cheetah_compile():
+ sys.argv.insert(1, "compile")
+ CheetahWrapper().main()
+
+
##################################################
## if run from the command line
if __name__ == '__main__': CheetahWrapper().main()
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
'''
Compiler classes for Cheetah:
ModuleCompiler aka 'Compiler'
@@ -106,7 +105,7 @@ class Error(Exception): pass
-class GenUtils:
+class GenUtils(object):
"""An abstract baseclass for the Compiler classes that provides methods that
perform generic utility functions or generate pieces of output code from
information passed in by the Parser baseclass. These methods don't do any
@@ -1077,8 +1076,11 @@ def _addAutoSetupCode(self):
self.addChunk('SL = self._CHEETAH__searchList')
else:
self.addChunk('SL = [KWS]')
- if self.setting('useFilters') and not self.isClassMethod() and not self.isStaticMethod():
- self.addChunk('_filter = self._CHEETAH__currentFilter')
+ if self.setting('useFilters'):
+ if self.isClassMethod() or self.isStaticMethod():
+ self.addChunk('_filter = lambda x, **kwargs: unicode(x)')
+ else:
+ self.addChunk('_filter = self._CHEETAH__currentFilter')
self.addChunk('')
self.addChunk("#" *40)
self.addChunk('## START - generated method body')
@@ -1224,8 +1226,8 @@ def _setupInitMethod(self):
__init__ = self._spawnMethodCompiler('__init__',
klass=self.methodCompilerClassForInit)
__init__.setMethodSignature("def __init__(self, *args, **KWs)")
- __init__.addChunk("%s.__init__(self, *args, **KWs)" % self._baseClass)
- __init__.addChunk(_initMethod_initCheetah%{'className':self._className})
+ __init__.addChunk('super(%s, self).__init__(*args, **KWs)' % self._className)
+ __init__.addChunk(_initMethod_initCheetah % {'className' : self._className})
for chunk in self._initMethChunks:
__init__.addChunk(chunk)
__init__.cleanupState()
@@ -1508,7 +1510,7 @@ def __init__(self, source=None, file=None,
extraImportStatements=None, # list of strings
settings=None # dict
):
- SettingsManager.__init__(self)
+ super(ModuleCompiler, self).__init__()
if settings:
self.updateSettings(settings)
# disable useStackFrames if the C version of NameMapper isn't compiled
@@ -1706,8 +1708,9 @@ def addImportedVarNames(self, varNames, raw_statement=None):
settings = self.settings()
if not varNames:
return
- if self._methodBodyChunks and raw_statement and not settings.get('useLegacyImportMode'):
- self.addChunk(raw_statement)
+ if not settings.get('useLegacyImportMode'):
+ if raw_statement and getattr(self, '_methodBodyChunks'):
+ self.addChunk(raw_statement)
else:
self._importedVarNames.extend(varNames)
@@ -1736,38 +1739,40 @@ def setBaseClass(self, baseClassName):
# - We also assume that the final . separates the classname from the
# module name. This might break if people do something really fancy
# with their dots and namespaces.
- chunks = baseClassName.split('.')
- if len(chunks)==1:
- self._getActiveClassCompiler().setBaseClass(baseClassName)
- if baseClassName not in self.importedVarNames():
- modName = baseClassName
- # we assume the class name to be the module name
- # and that it's not a builtin:
- importStatement = "from %s import %s" % (modName, baseClassName)
- self.addImportStatement(importStatement)
- self.addImportedVarNames( [baseClassName,] )
- else:
- needToAddImport = True
- modName = chunks[0]
- #print chunks, ':', self.importedVarNames()
- for chunk in chunks[1:-1]:
- if modName in self.importedVarNames():
- needToAddImport = False
- finalBaseClassName = baseClassName.replace(modName+'.', '')
- self._getActiveClassCompiler().setBaseClass(finalBaseClassName)
- break
- else:
- modName += '.'+chunk
- if needToAddImport:
- modName, finalClassName = '.'.join(chunks[:-1]), chunks[-1]
- #if finalClassName != chunks[:-1][-1]:
- if finalClassName != chunks[-2]:
+ baseclasses = baseClassName.split(',')
+ for klass in baseclasses:
+ chunks = klass.split('.')
+ if len(chunks)==1:
+ self._getActiveClassCompiler().setBaseClass(klass)
+ if klass not in self.importedVarNames():
+ modName = klass
# we assume the class name to be the module name
- modName = '.'.join(chunks)
- self._getActiveClassCompiler().setBaseClass(finalClassName)
- importStatement = "from %s import %s" % (modName, finalClassName)
- self.addImportStatement(importStatement)
- self.addImportedVarNames( [finalClassName,] )
+ # and that it's not a builtin:
+ importStatement = "from %s import %s" % (modName, klass)
+ self.addImportStatement(importStatement)
+ self.addImportedVarNames((klass,))
+ else:
+ needToAddImport = True
+ modName = chunks[0]
+ #print chunks, ':', self.importedVarNames()
+ for chunk in chunks[1:-1]:
+ if modName in self.importedVarNames():
+ needToAddImport = False
+ finalBaseClassName = klass.replace(modName+'.', '')
+ self._getActiveClassCompiler().setBaseClass(finalBaseClassName)
+ break
+ else:
+ modName += '.'+chunk
+ if needToAddImport:
+ modName, finalClassName = '.'.join(chunks[:-1]), chunks[-1]
+ #if finalClassName != chunks[:-1][-1]:
+ if finalClassName != chunks[-2]:
+ # we assume the class name to be the module name
+ modName = '.'.join(chunks)
+ self._getActiveClassCompiler().setBaseClass(finalClassName)
+ importStatement = "from %s import %s" % (modName, finalClassName)
+ self.addImportStatement(importStatement)
+ self.addImportedVarNames( [finalClassName,] )
def setCompilerSetting(self, key, valueExpr):
self.setSetting(key, eval(valueExpr) )
View
@@ -0,0 +1,16 @@
+import Cheetah.Template
+
+def render(template_file, **kwargs):
+ '''
+ Cheetah.Django.render() takes the template filename
+ (the filename should be a file in your Django
+ TEMPLATE_DIRS)
+
+ Any additional keyword arguments are passed into the
+ template are propogated into the template's searchList
+ '''
+ import django.http
+ import django.template.loader
+ source, loader = django.template.loader.find_template_source(template_file)
+ t = Cheetah.Template.Template(source, searchList=[kwargs])
+ return django.http.HttpResponse(t.__str__())
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
'''
Provides dummy Transaction and Response classes is used by Cheetah in place
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# $Id: ErrorCatchers.py,v 1.7 2005/01/03 19:59:07 tavis_rudd Exp $
"""ErrorCatcher class for Cheetah Templates
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# $Id: FileUtils.py,v 1.12 2005/11/02 22:26:07 tavis_rudd Exp $
"""File utitilies for Python:
Oops, something went wrong.

0 comments on commit 290f5e4

Please sign in to comment.