Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Update Template.py with @classmethod decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Ballance committed Nov 16, 2009
1 parent b6ae120 commit 69194e5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions cheetah/Template.py
Expand Up @@ -314,14 +314,15 @@ class Template(Servlet):
_CHEETAH_cacheStore = None
_CHEETAH_cacheStoreIdPrefix = None

@classmethod
def _getCompilerClass(klass, source=None, file=None):
return klass._CHEETAH_compilerClass
_getCompilerClass = classmethod(_getCompilerClass)

@classmethod
def _getCompilerSettings(klass, source=None, file=None):
return klass._CHEETAH_compilerSettings
_getCompilerSettings = classmethod(_getCompilerSettings)

@classmethod
def compile(klass, source=None, file=None,
returnAClass=True,

Expand Down Expand Up @@ -819,8 +820,8 @@ def __str__(self): return self.respond()
templateClass._CHEETAH_generatedModuleCode = generatedModuleCode

return templateClass
compile = classmethod(compile)

@classmethod
def subclass(klass, *args, **kws):
"""Takes the same args as the .compile() classmethod and returns a
template that is a subclass of the template this method is called from.
Expand All @@ -834,8 +835,8 @@ def subclass(klass, *args, **kws):
else:
templateAPIClass = Template
return templateAPIClass.compile(*args, **kws)
subclass = classmethod(subclass)

@classmethod
def _preprocessSource(klass, source, file, preprocessors):
"""Iterates through the .compile() classmethod's preprocessors argument
and pipes the source code through each each preprocessor.
Expand All @@ -849,8 +850,8 @@ def _preprocessSource(klass, source, file, preprocessors):
preprocessor = klass._normalizePreprocessorArg(preprocessor)
source, file = preprocessor.preprocess(source, file)
return source, file
_preprocessSource = classmethod(_preprocessSource)

@classmethod
def _normalizePreprocessorArg(klass, arg):
"""Used to convert the items in the .compile() classmethod's
preprocessors argument into real source preprocessors. This permits the
Expand Down Expand Up @@ -880,8 +881,8 @@ class Settings(object):
settings = klass._normalizePreprocessorSettings(settings)
return klass._CHEETAH_defaultPreprocessorClass(settings)

_normalizePreprocessorArg = classmethod(_normalizePreprocessorArg)

@classmethod
def _normalizePreprocessorSettings(klass, settings):
settings.keepRefToGeneratedCode = True

Expand Down Expand Up @@ -936,8 +937,8 @@ class PreprocessTemplateAPIClass(klass): pass
directiveToken=settings.directiveToken
)
return settings
_normalizePreprocessorSettings = classmethod(_normalizePreprocessorSettings)

@classmethod
def _updateSettingsWithPreprocessTokens(
klass, compilerSettings, placeholderToken, directiveToken):

Expand All @@ -958,8 +959,8 @@ def _updateSettingsWithPreprocessTokens(
'*'+directiveToken)
if 'EOLSlurpToken' not in compilerSettings:
compilerSettings['EOLSlurpToken'] = directiveToken
_updateSettingsWithPreprocessTokens = classmethod(_updateSettingsWithPreprocessTokens)

@classmethod
def _addCheetahPlumbingCodeToClass(klass, concreteTemplateClass):
"""If concreteTemplateClass is not a subclass of Cheetah.Template, add
the required cheetah methods and attributes to it.
Expand Down Expand Up @@ -1033,10 +1034,7 @@ def __unicode__(self):
__unicode__ = new.instancemethod(__unicode__, None, concreteTemplateClass)
setattr(concreteTemplateClass, '__str__', __str__)
setattr(concreteTemplateClass, '__unicode__', __unicode__)

_addCheetahPlumbingCodeToClass = classmethod(_addCheetahPlumbingCodeToClass)

## end classmethods ##

def __init__(self, source=None,

Expand Down

0 comments on commit 69194e5

Please sign in to comment.