/usr/lib64/python2.6/site-packages/Cheetah
NameSizeModeActions
Macros/-0755rm
Templates/-0755rm
Tests/-0755rm
Tools/-0755rm
Utils/-0755rm
CacheRegion.py44210644editdlrm
CacheRegion.pyc66360644editdlrm
CacheRegion.pyo65930644editdlrm
CacheStore.py30470644editdlrm
CacheStore.pyc58750644editdlrm
CacheStore.pyo58750644editdlrm
CheetahWrapper.py238850644editdlrm
CheetahWrapper.pyc229580644editdlrm
CheetahWrapper.pyo228950644editdlrm
Compiler.py802840644editdlrm
Compiler.pyc767540644editdlrm
Compiler.pyo766800644editdlrm
convertTmplPathToModuleName.py4960644editdlrm
convertTmplPathToModuleName.pyc7060644editdlrm
convertTmplPathToModuleName.pyo7060644editdlrm
DirectiveAnalyzer.py24450644editdlrm
DirectiveAnalyzer.pyc40430644editdlrm
DirectiveAnalyzer.pyo40430644editdlrm
Django.py5920644editdlrm
Django.pyc9450644editdlrm
Django.pyo9450644editdlrm
DummyTransaction.py32770644editdlrm
DummyTransaction.pyc56720644editdlrm
DummyTransaction.pyo56720644editdlrm
ErrorCatchers.py17550644editdlrm
ErrorCatchers.pyc36100644editdlrm
ErrorCatchers.pyo36100644editdlrm
FileUtils.py106640644editdlrm
FileUtils.pyc134550644editdlrm
FileUtils.pyo134550644editdlrm
Filters.py76390644editdlrm
Filters.pyc86750644editdlrm
Filters.pyo86750644editdlrm
ImportHooks.py44760644editdlrm
ImportHooks.pyc43680644editdlrm
ImportHooks.pyo43680644editdlrm
ImportManager.py175470644editdlrm
ImportManager.pyc172840644editdlrm
ImportManager.pyo172840644editdlrm
NameMapper.py130930644editdlrm
NameMapper.pyc141610644editdlrm
NameMapper.pyo141610644editdlrm
Parser.py1035990644editdlrm
Parser.pyc814660644editdlrm
Parser.pyo812770644editdlrm
Servlet.py34060644editdlrm
Servlet.pyc38840644editdlrm
Servlet.pyo38840644editdlrm
SettingsManager.py103610644editdlrm
SettingsManager.pyc118110644editdlrm
SettingsManager.pyo118110644editdlrm
SourceReader.py90590644editdlrm
SourceReader.pyc119640644editdlrm
SourceReader.pyo119640644editdlrm
Template.py847470644editdlrm
Template.pyc684040644editdlrm
Template.pyo683200644editdlrm
TemplateCmdLineIface.py33110644editdlrm
TemplateCmdLineIface.pyc39860644editdlrm
TemplateCmdLineIface.pyo39860644editdlrm
Unspecified.py2580644editdlrm
Unspecified.pyc8090644editdlrm
Unspecified.pyo8090644editdlrm
Version.py15400644editdlrm
Version.pyc18670644editdlrm
Version.pyo12990644editdlrm
_namemapper.so135760644editdlrm
__init__.py5820644editdlrm
__init__.pyc7560644editdlrm
__init__.pyo7560644editdlrm
Edit: /usr/lib64/python2.6/site-packages/Cheetah/Template.pyc (68404B)
ha-Kc-@sidZddkZddkZddkZddkZddkZddkZddkZddk l Z ddk Z ddk Z ddk Z ddkZddkZddkZddkZddklZlZyddklZWn%ej oeieifZnXyddklZWn&ej odfdYZnXy eZWn#ej odd klZnXdd klZl Z dd kl!Z!dd k"l#Z#dd k$l%Z%l&Z&ddk'l(Z(l)Z)ddk*l+Z+ddk*l,Z,ddk-l.Z.ddk/l0Z0ddk1l2Z2ddk3l4Z4l5Z5ddk6l7Z7l8Z8ddk9l:Z:ddk;l<Z<l=Z=l>Z>ddk?l@Z@eAZBdZCdeDfdYZEdeEfdYZFdZGdZHd ZIeJaKd!ZLd"eMfd#YZNd$eMfd%YZOd&e#fd'YZPePZQeeRePeP_Sd(ZTdS()sw Provides the core API for Cheetah. See the docstring in the Template class and the Users' Guide for more information iN(t randrange(t StringTypet ClassType(t StringTypes(tLockRcBseZdZdZRS(cCsdS(N((tself((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pytacquire"scCsdS(N((R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pytrelease$s(t__name__t __module__RR(((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR!s (tSet(tconvertVersionStringToTupletMinCompatibleVersionTuple(tMinCompatibleVersion(tServlet(t ParseErrort SourceReader(tCompilertDEFAULT_COMPILER_SETTINGS(t ErrorCatchers(tFilters(tconvertTmplPathToModuleName(t checkKeywords(tIndenter(tNotFoundtvalueFromSearchList(tMemoryCacheStoretMemcachedCacheStore(t CacheRegion(t _Convertert_lookuptNonNumericInputError(t UnspecifiedcCs|tde*ed3Z?ed4Z@e@ZAeeeeeeed5ZBd6ZCd7ZDeed&e2eeeed8ZEeee*eed9ZFed:ed;ZGd<ZHfd=d>d?d@d?d@edAZIRS(BsW This class provides a) methods used by templates at runtime and b) methods for compiling Cheetah source code into template classes. This documentation assumes you already know Python and the basics of object oriented programming. If you don't know Python, see the sections of the Cheetah Users' Guide for non-programmers. It also assumes you have read about Cheetah's syntax in the Users' Guide. The following explains how to use Cheetah from within Python programs or via the interpreter. If you statically compile your templates on the command line using the 'cheetah' script, this is not relevant to you. Statically compiled Cheetah template modules/classes (e.g. myTemplate.py: MyTemplateClasss) are just like any other Python module or class. Also note, most Python web frameworks (Webware, Aquarium, mod_python, Turbogears, CherryPy, Quixote, etc.) provide plugins that handle Cheetah compilation for you. There are several possible usage patterns: 1) tclass = Template.compile(src) t1 = tclass() # or tclass(namespaces=[namespace,...]) t2 = tclass() # or tclass(namespaces=[namespace2,...]) outputStr = str(t1) # or outputStr = t1.aMethodYouDefined() Template.compile provides a rich and very flexible API via its optional arguments so there are many possible variations of this pattern. One example is: tclass = Template.compile('hello $name from $caller', baseclass=dict) print tclass(name='world', caller='me') See the Template.compile() docstring for more details. 2) tmplInstance = Template(src) # or Template(src, namespaces=[namespace,...]) outputStr = str(tmplInstance) # or outputStr = tmplInstance.aMethodYouDefined(...args...) Notes on the usage patterns: usage pattern 1) This is the most flexible, but it is slightly more verbose unless you write a wrapper function to hide the plumbing. Under the hood, all other usage patterns are based on this approach. Templates compiled this way can #extend (subclass) any Python baseclass: old-style or new-style (based on object or a builtin type). usage pattern 2) This was Cheetah's original usage pattern. It returns an instance, but you can still access the generated class via tmplInstance.__class__. If you want to use several different namespace 'searchLists' with a single template source definition, you're better off with Template.compile (1). Limitations (use pattern 1 instead): - Templates compiled this way can only #extend subclasses of the new-style 'object' baseclass. Cheetah.Template is a subclass of 'object'. You also can not #extend dict, list, or other builtin types. - If your template baseclass' __init__ constructor expects args there is currently no way to pass them in. If you need to subclass a dynamically compiled Cheetah class, do something like this: from Cheetah.Template import Template T1 = Template.compile('$meth1 #def meth1: this is meth1 in T1') T2 = Template.compile('#implements meth1 this is meth1 redefined in T2', baseclass=T1) print T1, T1() print T2, T2() Note about class and instance attribute names: Attributes used by Cheetah have a special prefix to avoid confusion with the attributes of the templates themselves or those of template baseclasses. Class attributes which are used in class methods look like this: klass._CHEETAH_useCompilationCache (_CHEETAH_xxx) Instance attributes look like this: klass._CHEETAH__globalSetVars (_CHEETAH__xxx with 2 underscores) t_initCheetahInstancet searchListt errorCatchertgetVart varExiststgetFileContentsti18ntrunAsMainProgramtrespondtshutdowntwebInputtserverSidePathtgeneratedClassCodetgeneratedModuleCodet_getCacheStoret_getCacheStoreIdPrefixt_createCacheRegiontgetCacheRegiontgetCacheRegionst refreshCachet_handleCheetahIncludet2_getTemplateAPIClassForIncludeDirectiveCompilationtsubclasstcacheRegionClasst cacheStoretcacheStoreIdPrefixtcacheStoreClasst"DynamicallyCompiledCheetahTemplatecCs|iS(N(t_CHEETAH_compilerClass(RQRRRS((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyt_getCompilerClass=scCs|iS(N(t_CHEETAH_compilerSettings(RQRRRS((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyt_getCompilerSettingsAsc)Bs d}e|eief oe|ddfne|eieeif oe|ddfn| ejo |i} ne| eo | i } ne| eieei ei f oe|ddfn| ejo |i } ne| e ef oe|dd fn| ejo |i} ne| e ef oe|d d fn|ejo|i||ph}ne|e oe|d d fn|ejo|i||}n| ejo |i} n|ejo |i}ne|e ef oe|d d fne|eief oe|ddfne}| o:|o e|eoe|}|}n |i}n|ejo |i}ne|eief oe|ddfneidd|p|}|ejo |i}ne|eief oe|ddfn| ejo |i} n|ejo |i}ne|e ef oe|dd fn|ejo |i}ne|eief oe|ddfn| o%|}|i||| \}}ne}e}| oQe| eo | }n4e| ei ei fod| i }| }nne}e}|p e|eoe}|oe!|}ne}| oe!| }ne}|oDe"e#|}e$do |e"e%i&i'|7}nnyjdi(g}e#|||||e#|e#| ||e#|g D]}|e"|q~}WnnXnd}e}| o|o ||i)jo|i)|}|i*} nr|||d|d|d|d|d|ph}|o|i+|i,n|i-|i.} |i/}| oU|dj o6| i0d} | i1dd|di(| } n| i2|Sn|oe3i3|_4|i5Snz|i6i7e8|}!|!d}"|oWe%i&i9| oe:d|ne%i&i(||"}"e;|"d i<| ne=i>e"|!}#| o1x*| i?D]\}$}e@|#|$|qWn|"|#_A|oe%i&i9|o ||#_Bn| o|oe@|#||ny'e-| |"d!}%|%|#iCfd"UWneDj oQ}&yeE||| d#|&}'Wn#eF|"| | |&_G|&nX|'n/e:j o"}&eF|"| | |&_GnX|#eHiI|!(if module, must contain subclasses of Cheetah.Filters.Filter)Rpsstring, class or NonesB(if class, must be subclass of Cheetah.ErrorCatchers.ErrorCatcher)RRs-you must supply either a source string or thes& 'file' keyword argument, but not botht_CHEETAH_versionTupleslThis template was compiled with Cheetah version %s. Templates compiled before version %s must be recompiled.tprioritizeSearchListOverSelfs` The following keys are members of the Template class and will result in NameMapper collisions! s > %s s, s Please change the key's name or use the compiler setting "prioritizeSearchListOverSelf=True" to prevent the NameMapper from using s: the Template member in place of your searchList variable RoRt_globalSetVarst_preBuiltSearchListN(ssourcesstring or None(sfiles&string, file open for reading, or None(sfiltersstring or classs6(if class, must be subclass of Cheetah.Filters.Filter)(s filtersLibsstring or modules>(if module, must contain subclasses of Cheetah.Filters.Filter)(s errorCatchersstring, class or NonesB(if class, must be subclass of Cheetah.ErrorCatchers.ErrorCatcher)(scompilerSettingss dictionary(+R'RRRRRRRt issubclassRtFiltert ModuleTypeRXRRRt ErrorCatcherR tDictTypeRRmRORWR8R9RR t__CHEETAH_version__R R tAssertionErrorR R(tReserved_SearchListtsettkeystgettloggingtinfoRR*Rnt_compile(RRRRRoRSR R!RpRR$R%Rt errmsgextraterrRtcompiledVersiontcompiledVersionTuplet namespacet intersectiontwarn((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyROsz '                cCs|iS(seReturn the module code the compiler generated, or None if no compilation took place. (R(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR{scCs&|i|iid|iid!S(sdReturn the class code the compiler generated, or None if no compilation took place. s class s ## END CLASS DEFINITION(Rtfind(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRzscCs|iS(s-Return a reference to the searchlist (t_CHEETAH__searchList(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRoscCs|iS(s7Return a reference to the current errorCatcher (t_CHEETAH__errorCatcher(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRpscCsD|ip3|idj o|i|_q=|i|_n|iS(N(t_CHEETAH__cacheStoret_CHEETAH_cacheStoreRXt_CHEETAH_cacheStoreClass(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR|s  cCs,|idj o|iStt|SdS(N(t_CHEETAH_cacheStoreIdPrefixRXR:tid(R((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR}scCs(|id|d|id|iS(NtregionIDttemplateCacheIdPrefixR(t_CHEETAH_cacheRegionClassR}R|(RRC((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR~s  cCsE|ii|}| o'|o |i|}||i|R?( RRoRR R!RpR$RR%t filterNameRQterrorCatcherClasstec((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRnsb  $                       c Cs|tjo|i||ph}n|p|i}d|_d|_d|_|oVt|toF|i |}t i i ||_t i i |\|_|_n||_|i||d|d|d|dt}||_|i|t|dp d|_ndS(sCompile the template. This method is automatically called by Template.__init__ it is provided with 'file' or 'source' args. USERS SHOULD *NEVER* CALL THIS METHOD THEMSELVES. Use Template.compile instead. RRRRRcN(R Rt_CHEETAH_defaultMainMethodNameRXt _fileMtimet _fileDirNamet _fileBaseNameR'RRyRRRRt _filePathR\RRRORWRc(RRRRSRRRR((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR3s(    "    RSc Cs|}||ijo<|p|djodd}t|tjoAt|do|i|}}qtii|}}q|}n |}d}|i ||} | i d|d|} | d|i d|i } |i | _ |i | _| |i||djo1tdjotiandti} } nY| o|djotdn5| o|djotdn| o'|djod|ii } } n| o-|djo d |ii i } } n|djod|ii } } n|djod |ii } } na|djod|ii } } n:|djo d |ii i } } n t d | d} htd d||d 6tdt||d6tdt||d6}h}x3|D]+}t|| t|\}}||| tags. ** KLUDGE: 'debug' is supposed to insert into the template output, but it wasn't working so I changed it to a'print' statement. So the debugging output will appear wherever standard output is pointed, whether at the terminal, in a Webware log file, or whatever. *** Since we didn't specify any coversions, the value is a string. It's a 'single' value because we specified it in 'names' rather than 'namesMulti'. Single values work like this: * If one value is found, take it. * If several values are found, choose one arbitrarily and ignore the rest. * If no values are found, use or raise the appropriate 'default*' value. Multi values work like this: * If one value is found, put it in a list. * If several values are found, leave them in a list. * If no values are found, use the empty list ([]). The 'default*' arguments are *not* consulted in this case. Example: assume 'days' came from a set of checkboxes or a multiple combo box on a form, and the user chose'Monday', 'Tuesday' and 'Thursday'. #silent $webInput([], ['days']) The days you chose are: #slurp #for $day in $days $day #slurp #end for dic = self.webInput([], ['days']) write('The days you chose are: ') for day in dic['days']: write(day + ' ') Both these examples print: 'The days you chose are: Monday Tuesday Thursday'. By default, missing strings are replaced by '' and missing/bad numbers by zero. (A'bad number' means the converter raised an exception for it, usually because of non-numeric characters in the value.) This mimics Perl/PHP behavior, and simplifies coding for many applications where missing/bad values *should* be blank/zero. In those relatively few cases where you must distinguish between empty-string/zero on the one hand and missing/bad on the other, change the appropriate 'default*' and 'bad*' arguments to something like: * None * another constant value * $NonNumericInputError/self.NonNumericInputError * $ValueError/ValueError (NonNumericInputError is defined in this class and is useful for distinguishing between bad input vs a TypeError/ValueError thrown for some other rason.) Here's an example using multiple values to schedule newspaper deliveries. 'checkboxes' comes from a form with checkboxes for all the days of the week. The days the user previously chose are preselected. The user checks/unchecks boxes as desired and presses Submit. The value of 'checkboxes' is a list of checkboxes that were checked when Submit was pressed. Our task now is to turn on the days the user checked, turn off the days he unchecked, and leave on or off the days he didn't change. dic = self.webInput([], ['dayCheckboxes']) wantedDays = dic['dayCheckboxes'] # The days the user checked. for day, on in self.getAllValues(): if not on and wantedDays.has_key(day): self.TurnOn(day) # ... Set a flag or insert a database record ... elif on and not wantedDays.has_key(day): self.TurnOff(day) # ... Unset a flag or delete a database record ... 'source' allows you to look up the variables from a number of different sources: 'f' fields (CGI GET/POST parameters) 'c' cookies 's' session variables 'v' 'values', meaning fields or cookies In many forms, you're dealing only with strings, which is why the 'default' argument is third and the numeric arguments are banished to the end. But sometimes you want automatic number conversion, so that you can do numeric comparisions in your templates without having to write a bunch of conversion/exception handling code. Example: #silent $webInput(['name', 'height:int']) $name is $height cm tall. #if $height >= 300 Wow, you're tall! #else Pshaw, you're short. #end if dic = self.webInput(['name', 'height:int']) name = dic[name] height = dic[height] write('%s is %s cm tall.' % (name, height)) if height > 300: write('Wow, you're tall!') else: write('Pshaw, you're short.') To convert a value to a number, suffix ':int' or ':float' to the name. The method will search first for a 'height:int' variable and then for a 'height' variable. (It will be called 'height' in the final dictionary.) If a numeric conversion fails, use or raise 'badInt' or 'badFloat'. Missing values work the same way as for strings, except the default is 'defaultInt' or 'defaultFloat' instead of 'default'. If a name represents an uploaded file, the entire file will be read into memory. For more sophistocated file-upload handling, leave that name out of the list and do your own handling, or wait for Cheetah.Utils.UploadFileMixin. This only in a subclass that also inherits from Webware's Servlet or HTTPServlet. Otherwise you'll get an AttributeError on 'self.request'. EXCEPTIONS: ValueError if 'source' is not one of the stated characters. TypeError if a conversion suffix is not ':int' or ':float'. FUTURE EXPANSION: a future version of this method may allow source cascading; e.g., 'vs' would look first in 'values' and then in session variables. Meta-Data ================================================================================ Author: Mike Orr License: This software is released for unlimited distribution under the terms of the MIT license. See the LICENSE file. Version: $Revision: 1.186 $ Start Date: 2002/03/17 Last Revision Date: $Date: 2008/03/10 04:48:11 $ RbR1tfieldtcs#can't get cookies from a CGI scripttss-can't get session variables from a CGI scriptR#tsessiontcookiesarg 'src' invalidtstringRRtfloats
s	
i(RbR1N(tlowerRot_formUsedByWebInputRXtcgit FieldStoragetgetvaluet RuntimeErrortrequestR#RRRRRRRRRRtpprinttpformatRoR(Rtnamest namesMultiRSREt defaultIntt defaultFloattbadInttbadFloattdebugtisCgiRRtfunctsourcest converterstdictnameR5R1((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRxRsR           (JRR RlRRRRRRXRR(RRRRsRRRRRRRRRRRRRRRLRRRRRERR@R?RARRRR R\RRRRRRRROR{RzRoRpR|R}R~RRRRwRqRrthasVarRtRsRuRnR3RRRx(((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyRmsN     8L           N  , c CsSt|ttfo|pd}ti}tid||i}t|do |i }n"t t i d|i d}|i}g} xPtddD]?} || djoPn| i|d| ||| fqWg} xRtddD]A} || t|jpPn| i|| ||| fqW| id} | d7} x<| o4| i} | dh| dd 6| dd 67} qfWt|d o$| d d |ipdd7} nx<| o4| i} | dh| dd 6| dd 67} qWddddt|d| ddg}t i d|}|o;t |i d}t |i d}|idnd}d}t i ddi|t|dd}|oHt |i d}t |i d}|id|idndi|}t|d|}t||d|d|S(Nitlinenos[ ]*File.*line (\d+)iisLine|Python Code sC----|------------------------------------------------------------- s%(row)-4d|%(line)s trowtlinetoffsett is^ sCError in the Python code which Cheetah generated for this template:t=iPRsline (\d+), col (\d+)is) Here is the corresponding Cheetah code: s s( Here is the corresponding Cheetah code.sM** I had to guess the line & column numbers, so they are probably incorrect: RDtcol(R'R:RTRXtStringIOt tracebackt print_excRRWRRRtsearchtgroupRBtrangeR,RAtreversetpopRRtmaxRR(RRRStgeneratedPyCodeRRDtsiot formatedExctpyLinenoRHt prevLinestit nextLinestreporttlineInfoRUtcheetahPosMatchRRtreader((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyR:sr#   ! '#   )$ )   # (URlR8RRR1Rtos.pathRR;trandomRtimpRZRRRRRRRRt ImportErrort UnicodeTypet threadingRR.txt NameErrortsetsR tCheetah.VersionR R R tCheetah.ServletRtCheetah.ParserRRtCheetah.CompilerRRtCheetahRRt#Cheetah.convertTmplPathToModuleNameRtCheetah.Utils.MiscRtCheetah.Utils.IndenterRtCheetah.NameMapperRRtCheetah.CacheStoreRRtCheetah.CacheRegionRtCheetah.Utils.WebInputMixinRRRtCheetah.UnspecifiedR RR!R$RR%R&R+R)R?RXRRJRRKRLRmtTtdirR-R(((s6/usr/lib64/python2.6/site-packages/Cheetah/Template.pyts                   +