Permalink
Browse files

Merge commit 'abbeyj/performance' into performance

Conflicts:
	src/Template.py
	src/c/_template.c
  • Loading branch information...
2 parents 899407b + 714a46b commit c38cbebcf6cd29adace490f1fbe7dee8324a27c9 R. Tyler Ballance committed Jun 28, 2009
Showing with 39 additions and 28 deletions.
  1. +3 −0 SetupConfig.py
  2. +1 −0 bin/.gitattributes
  3. +1 −0 bin/cheetah.bat
  4. +15 −24 src/Template.py
  5. +15 −0 src/Tests/Template.py
  6. +4 −4 src/c/_template.c
View
@@ -34,6 +34,7 @@
import os
import os.path
+import sys
from distutils.core import Extension
ext_modules=[
@@ -51,6 +52,8 @@
scripts = ['bin/cheetah-compile',
'bin/cheetah',
]
+if sys.platform == "win32":
+ scripts.append('bin/cheetah.bat')
data_files = ['recursive: src *.tmpl *.txt LICENSE README TODO CHANGES',
]
if not os.getenv('CHEETAH_INSTALL_WITHOUT_SETUPTOOLS'):
View
@@ -0,0 +1 @@
+cheetah.bat -crlf
View
@@ -0,0 +1 @@
+@"%~dp0..\python" "%~dpn0" %*
View
@@ -25,11 +25,6 @@
from types import StringTypes
except ImportError:
StringTypes = (types.StringType,types.UnicodeType)
-try:
- from types import BooleanType
- boolTypeAvailable = True
-except ImportError:
- boolTypeAvailable = False
try:
from threading import Lock
@@ -607,11 +602,11 @@ def __str__(self): return self.respond()
N = types.NoneType; S = types.StringType; U = types.UnicodeType
D = types.DictType; F = types.FileType
C = types.ClassType; M = types.ModuleType
- I = types.IntType
+ I = types.IntType; B = types.BooleanType
+
+ IB = (I, B)
+ NS = (N, S)
- if boolTypeAvailable:
- B = types.BooleanType
-
vt(source, 'source', (N,S,U), 'string or None')
vt(file, 'file',(N,S,U,F), 'string, file-like object, or None')
@@ -622,12 +617,10 @@ def __str__(self): return self.respond()
cacheCompilationResults = valOrDefault(
cacheCompilationResults, klass._CHEETAH_cacheCompilationResults)
- if boolTypeAvailable:
- vt(cacheCompilationResults, 'cacheCompilationResults', (I,B), 'boolean')
+ vt(cacheCompilationResults, 'cacheCompilationResults', IB, 'boolean')
useCache = valOrDefault(useCache, klass._CHEETAH_useCompilationCache)
- if boolTypeAvailable:
- vt(cacheCompilationResults, 'cacheCompilationResults', (I,B), 'boolean')
+ vt(useCache, 'useCache', IB, 'boolean')
compilerSettings = valOrDefault(
compilerSettings, klass._getCompilerSettings(source, file) or {})
@@ -638,38 +631,36 @@ def __str__(self): return self.respond()
keepRefToGeneratedCode = valOrDefault(
keepRefToGeneratedCode, klass._CHEETAH_keepRefToGeneratedCode)
- if boolTypeAvailable:
- vt(cacheCompilationResults, 'cacheCompilationResults', (I,B), 'boolean')
-
- vt(moduleName, 'moduleName', (N,S), 'string or None')
+ vt(keepRefToGeneratedCode, 'keepRefToGeneratedCode', IB, 'boolean')
+
+ vt(moduleName, 'moduleName', NS, 'string or None')
__orig_file__ = None
if not moduleName:
if file and type(file) in StringTypes:
moduleName = convertTmplPathToModuleName(file)
__orig_file__ = file
else:
moduleName = klass._CHEETAH_defaultModuleNameForTemplates
-
+
className = valOrDefault(
className, klass._CHEETAH_defaultClassNameForTemplates)
- vt(className, 'className', (N,S), 'string or None')
+ vt(className, 'className', NS, 'string or None')
className = className or moduleName
mainMethodName = valOrDefault(
mainMethodName, klass._CHEETAH_defaultMainMethodNameForTemplates)
- vt(mainMethodName, 'mainMethodName', (N,S), 'string or None')
+ vt(mainMethodName, 'mainMethodName', NS, 'string or None')
moduleGlobals = valOrDefault(
moduleGlobals, klass._CHEETAH_defaultModuleGlobalsForTemplates)
cacheModuleFilesForTracebacks = valOrDefault(
cacheModuleFilesForTracebacks, klass._CHEETAH_cacheModuleFilesForTracebacks)
- if boolTypeAvailable:
- vt(cacheModuleFilesForTracebacks, 'cacheModuleFilesForTracebacks', (I,B), 'boolean')
-
+ vt(cacheModuleFilesForTracebacks, 'cacheModuleFilesForTracebacks', IB, 'boolean')
+
cacheDirForModuleFiles = valOrDefault(
cacheDirForModuleFiles, klass._CHEETAH_cacheDirForModuleFiles)
- vt(cacheDirForModuleFiles, 'cacheDirForModuleFiles', (N,S), 'string or None')
+ vt(cacheDirForModuleFiles, 'cacheDirForModuleFiles', NS, 'string or None')
except TypeError, reason:
raise TypeError(reason)
View
@@ -326,7 +326,22 @@ def test_BasicDecorator(self):
except AttributeError, ex:
self.fail(ex)
+class Useless(object):
+ def boink(self):
+ return [1, 2, 3]
+class MultipleInheritanceSupport(TemplateTest):
+ def runTest(self):
+ template = '''
+ #extends Template, Useless
+ #def foo()
+ #return [4,5] + $boink()
+ #end def
+ '''
+ template = Template.compile(template)
+ template = template()
+ result = template.foo()
+ print result
##################################################
View
@@ -14,7 +14,7 @@ static PyObject *unspecified = NULL;
static PyObject *py_valordefault(PyObject *self, PyObject *args, PyObject *kwargs)
{
- PyObject *value, *def, *res;
+ PyObject *value, *def;
if (!PyArg_ParseTuple(args, "OO", &value, &def))
return NULL;
@@ -31,7 +31,7 @@ static const char _template_doc[] = "\
\n\
";
static struct PyMethodDef _template_methods[] = {
- {"valOrDefault", py_valordefault, METH_VARARGS, NULL},
+ {"valOrDefault", (PyCFunction)py_valordefault, METH_VARARGS, NULL},
{NULL}
};
@@ -41,10 +41,10 @@ PyMODINIT_FUNC init_template()
_template_doc);
unspecifiedModule = PyImport_ImportModule("Cheetah.Unspecified");
if ( (PyErr_Occurred()) || (!unspecifiedModule) )
- return NULL;
+ return;
unspecified = PyObject_GetAttrString(unspecifiedModule, "Unspecified");
if (PyErr_Occurred())
- return NULL;
+ return;
}
#ifdef __cplusplus

0 comments on commit c38cbeb

Please sign in to comment.