Ñò PhEc@sadZddkTddkiZddkTddkiZddkZddkZddk Zddk Zddk Zddk i Z ddkZddkZddkZddkTddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZddkZdgZddd„ƒYZdS(sˆThe interp package and its primary class, Interpreter, represents the runtime environment for Myghty components. It serves as a "home base" for configuration information and request construction, and also assists the Request object in locating components. The Interpreter maintains a pool of component objects and handles, at a high level, their compilation and filesystem representation.iÿÿÿÿ(t*Nt InterpretercBsMeZdZddddddeeeiiei ƒe ghddd„Z d„Z d„Z d„Zd„Zd„Zed „Zd „Zd „Zd „Zdd „Zd„Zddd„ƒYZe eed„Ze ed„Ze ed„Ze ed„Zd„Zd„Zd„Zdd„Zd„Z d„Z!d„Z"RS(sVRepresents an environment in which to create requests, compile and execute components.it autohandlerc s‡| phˆ_hˆ_|dj oˆii|ƒneˆid„ƒˆ_|ˆ_|ˆ_|ˆ_|ˆ_ |i de ƒˆ_ hˆ_ eii| dd| ƒˆ_e| ƒogeˆ_x+| D]#}ddd|}|eƒUqÏWˆiideˆƒei| d ƒfƒn e ˆ_|id ƒo |d =neiid ||ˆ_ˆi i d dƒdj o*ˆiid eiiˆi d ƒƒn|o |ˆ_ nei i!|ˆ_ ˆi i ddƒdj o#eiiˆi dƒˆi _"nˆpei#i$|‰ne%d‡fd†ƒˆ_#|o |ˆ_&nei&i'ˆ|ˆ_&|dj o7|ˆ_(e)i|dƒˆ_*e)i|dƒˆ_+ndˆ_(dˆ_*dˆ_+|djo e ˆ_ n!ˆi,ˆi*ƒˆi,ˆi+ƒe-i.ƒˆ_/‡fd†}e0|d|ƒˆ_1hei2i3d6ei2i4d6ei2i5d6ˆ_2ˆi2i| ƒdS(saconstructs a new Interpreter object. All Myghty configuration parameters are sent to this method as keyword parameters. Those parameters that are used directly by this Interpreter are consumed. Remaining arguments are sent off to other constructed objects, which include a Compiler, a Resolver, and a Request prototype object.cSsdS(N(tNone(((s1/usr/lib/python2.6/site-packages/myghty/interp.pyt@stuse_static_sourcetMyghtyt id_threadssdef log(msg): s' self.log_file.write('[%s] ' + msg) sself.debuggers[elem] = logs%s starting - debug logging: %st t componenttcache_data_dirtcachet debug_filet resolutiontcreatorcs ˆiƒS((tclone((tcompiler(s1/usr/lib/python2.6/site-packages/myghty/interp.pyRpstobjtlockcs;ˆio-ˆidˆii|i|ifdƒndS(Ns+code_cache size %d - removing %s (%d bytes)t codecache(t_debugtdebugt code_cachet currentsizetidtsize(tcomp(tself(s1/usr/lib/python2.6/site-packages/myghty/interp.pytcomponentdeletedŽs t deletefuncthtutxN(6t global_argst _attributesRtupdatet InheritedDictt attributest init_paramstuse_auto_handlerstauto_handler_nametuse_object_filestgettFalseRt debuggerstmyghtytbuffert LogFormattertlog_filetlentTrueRtlocalstwritetreprtstringtjointhas_keyR t CacheArgst cache_argst set_paramstFunctionBuffertresolvertResolverR RtCompilert ThreadLocaltrequesttRequesttdata_dirtunixpatht object_dirtlock_dirt_verify_directorytweakreftWeakValueDictionarytreverse_lookuptLRUCacheRtescapest html_escapet url_escapet xml_escape(RR%RCRR=RAtcode_cache_sizeR'R)R t debug_threadstdebug_elementsRLR!R(tparamstelemtsR((RRs1/usr/lib/python2.6/site-packages/myghty/interp.pyt__init__'sj          0  * #        0cKs|id||iƒS(s®executes the given component with the given request construction arguments. The component can be a string path which will be resolved, or a Component object.R (t make_requesttexecute(RR RS((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRX˜scKs|iid|d||S(sœcreates a new request with the given component and request construction arguments. The request is copied from an existing request instance, overriding its parameters with those given. The returned request is executed by calling its execute() method. The component can be a string path which will be resolved when the request is executed, or a Component object.R t interpreter(RAR(RR RS((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRWžscCsti|ƒ‚dS(s:raises an Interpreter error with the given message string.N(t exceptionR(Rterror((s1/usr/lib/python2.6/site-packages/myghty/interp.pyt raise_error¨scKs)|ii|dt|otStSdS(s†returns True if the given path can be resolved to a ComponentSource instance, i.e. if a component can be loaded for this path.R\N(R=tresolveR+R2(RtpathRS((s1/usr/lib/python2.6/site-packages/myghty/interp.pytcomponent_exists­scKs.|i||}|pdS|i|iƒS(sresolves and loads the component specified by the given path. **params is a set of keyword arguments passed to the resolution system.N(tresolve_componentRtload_componenttcsource(RR^RSR ((s1/usr/lib/python2.6/site-packages/myghty/interp.pytload¶scKstii|}|i|ƒS(snresolves and loads a module component specified within the given keyword parameters. The keyword parameters are passed directly to myghty.csource.ModuleComponentSource. The easiest way to use this method is to pass the keyword parameter "arg", which references a string in the form ":", where is a regular Python module to be loaded via __import__, and is the dotted path to either a callable object inside the module or a class inside the module which subclasses myghty.component.ModuleComponent.(R-RbtModuleComponentSourceRa(RR\RSRb((s1/usr/lib/python2.6/site-packages/myghty/interp.pytload_module_component½s cKs|ii||S(scresolves the component specified by the given path. a myghty.resolver.Resolution object is returned containing a myghty.csource.ComponentSource reference. Raises ComponentNotFound by default if the path cannot be resolved. **params is a set of keyword parameters sent directly to the resolve() method on myghty.resolver.Resolver.(R=R](RR^RS((s1/usr/lib/python2.6/site-packages/myghty/interp.pyR`Ésc sºˆi}yRˆi|}ˆip)|iiˆijo|iˆijo|St|_Wntj onXˆi |ƒ}‡‡fd†}d„}ˆii ||||ƒ}|S(s}loads the component corresponding to the given ComponentSource object. This can be any subclass of ComponentSource. If the component was already loaded and exists within this Interpreter's code cache, returns the existing Component. If the Component has been modified at its source, it will re-load or re-compile the Component as needed. If this Component has not been loaded, it will import or compile the Component as needed. This operation is also synchronized against other threads. On systems that support file-locking it is synchronized against other processes as well. cs{ˆiˆdˆidˆi ƒ}ˆio-ˆidˆii|i|ifdƒnt t i ƒƒ|_ t |_ |S(Ntuse_filetrecompile_newers)code_cache size %d - adding %s (%d bytes)R(tget_compiled_componentR)RRRRRRRtintttimet load_timeR+t needs_reload(R (RRb(s1/usr/lib/python2.6/site-packages/myghty/interp.pytcreateìs " - cSs|i S(N(Rl(R ((s1/usr/lib/python2.6/site-packages/myghty/interp.pytisvalidós( RRRtcomponent_sourcet last_modifiedRkR2RltKeyErrort_get_component_mutextsync_get(RRbt component_idR t name_lockRmRn((RRbs1/usr/lib/python2.6/site-packages/myghty/interp.pyRaÐs     cCstdd|ƒS(Nt identifiersinterpreter/loadcomponent/%s(tNameLock(RRt((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRrùscCs.tiid|d|ƒ}|i|dtƒS(sJcreates an in-memory template Component given its source as a string...this can be any Myghty template that would ordinarily be compiled from the filesystem. the optional "id" string parameter is used to identify this component within this Interpreter's code cache. If not given, one will be generated.tsourceRRf(R-RbtMemoryComponentSourceRhR+(RRxRRb((s1/usr/lib/python2.6/site-packages/myghty/interp.pytmake_componentüscCsd|id|id|id|id|id|id|id|id|idfS(s‰returns a tuple containing the full paths to the .py, .pyc, and .pyo files corresponding to the given FileComponentSource object.t/s.pys.pycs.pyo(REtpath_idR^(RRo((s1/usr/lib/python2.6/site-packages/myghty/interp.pytget_component_object_filess  t CompileRecordcBs&eZdZddd„Zd„ZRS(ska record used to link exception reporting back to the originating python and myghty template sourcecCs(||_||_||_||_dS(N(t module_idRbt compiledtotcompiledsource(RRRbR€R((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRVs   cCs2|idj oti|iƒSt|iƒSdS(N(RRtutiltStringIOtopenR€(R((s1/usr/lib/python2.6/site-packages/myghty/interp.pytget_compiled_sourcesN(t__name__t __module__t__doc__RRVR…(((s1/usr/lib/python2.6/site-packages/myghty/interp.pyR~scCsS|iƒp|i|||ƒS|p|i|||ƒS|i|||ƒSdS(sPused by load_component to deliver a new Component object from a ComponentSource.N(t can_compilet_get_module_componentt_get_inmemory_componentt_get_file_component(RRbtalways_recompileRgRf((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRhs  cCsÇ|i}|io'|id|it|ƒfdƒn|idjo,|p|o|iti|ƒƒqvn|i dj o*t |i t i iƒo|i ||ƒSt i i||ƒSdS(sxloads a module component from a regular Python module. Most of the module-loading code is in the util package.s*loading component %s from module object %st classloadingt__main__N(tmoduleRRRR5R†treloadtimportert reload_moduletclass_Rt issubclassR-R tModuleComponenttFunctionComponent(RRbRRgR((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRŠ(s  ')cs d}ˆiiƒ}dtiddˆiƒdtiddˆiƒ}ˆiˆƒ\‰}}tdˆidt dˆi ƒ} ‡‡‡‡‡fd†} t } | ƒo| i ƒzü| ƒoîˆi tiˆidˆid ˆiƒƒˆi|ƒoti|ƒnˆi|ƒoti|ƒnˆio!ˆid ˆiˆfd ƒntˆd ƒ}ˆi||ƒ|iƒtˆd t ƒo t } nt ˆ_nWd| iƒXn| iƒzïti|ˆdˆƒ} | ˆi ˆ<ˆioˆidˆd ƒnt!i"ˆd|d| ƒ} | ˆ_#| | _$ti%ˆƒt&ˆ_'t(| dƒ p| i)|i*ƒjo1t(ˆd ƒoˆio d‚nt ˆ_n t ˆ_Wd| i+ƒXˆio ˆi,ˆdˆdˆdt ƒS| i-ˆˆƒSdS(s^loads and compiles a file-based component as a regular Python module with a .py and .pyc file.t _myghtycomp_s\Wt_sinterpreter/filewriter/%st use_filesRFcsLˆpEˆoˆiˆiˆƒp(ˆiˆƒ ptˆdƒoˆiS(Nt_bad_magic_number(t _need_fileRpt _file_existsthasattrR›((t object_fileRRgRRb(s1/usr/lib/python2.6/site-packages/myghty/interp.pytneeds_recompileHss./R{scompiling %s in file %sRŽtwR›NR€s%loading component from source file %sRt forcereloadt _MAGIC_NUMBERsdassertion failed: csource magic number check completed but recompile still produces bad magic numberRRgRf(.RRR*tretsubR|RR}t SynchronizerR2RFR+tacquire_write_lockRGRDR7REtdir_nameRtostremoveRRtfiletget_object_codetclosetgetattrR›trelease_write_locktacquire_read_lockRR~RJR’t filemoduleRt_Interpreter__compiletstattST_SIZEt modulesizeRžR£tget_magic_numbertrelease_read_lockRht get_component(RRbRRgtdestbufRtcidtcompiled_object_filetoptimized_object_filetfile_name_lockR t force_reloadtcomprecR((RŸRRRbRgs1/usr/lib/python2.6/site-packages/myghty/interp.pyRŒ9sZ6"    . !             c svd }|iiƒ}deiddˆiƒdeiddˆiƒ}|io|idˆidƒne i ƒ}ˆi ||ƒd|}ˆi ‰‡‡‡‡fd†}|ƒoSe i|ƒ‰e|iƒ|dƒ} | ˆiˆiUeiƒˆ_ˆˆ_ nei|ˆd |iƒƒ} | |i|<| ˆ_e|iƒƒˆ_eˆ_ˆi|ˆƒS( sAloads and compiles a file-based component as an in-memory module.R˜s\WR™scompiling %s in memoryRŽsmemory:cs+ˆp$ˆdjpˆoˆiˆijS(N(RRpt_modified_time((RRgRbR(s1/usr/lib/python2.6/site-packages/myghty/interp.pyR ªs texecRN(RRR*R¤R¥R|RRRR‚RƒR¬Rtimpt new_moduletcompiletgetvaluet__dict__RjRÀRR~RJR²R1RµR+R›R¸( RRbRRgR¹RRºtfilenameR tcodeR¿((RRgRRbs1/usr/lib/python2.6/site-packages/myghty/interp.pyR‹™s,6         cCsti|tiƒS(N(R©taccesstF_OK(RR«((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRÃscCsHti|tiƒ p1|ti|ƒtjpti|ƒtdjS(Ni(R©RÉRÊR³tST_MTIMER´(Rt modified_timeR«((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRœÆscCst|ƒdS(N(tverify_directory(Rtdir((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRGËscCsU|djo|ii|ƒn1|ii|dƒ}|dj o||ƒndS(sðwrites a debug message to the debug file. the optional type string refers to a "debug_element" type, i.e. 'resolution', 'cache', etc. which will only write a message if that debug_element was enabled with this Interpreter.N(RR0R4R,R*(Rtmessagettypetlog((s1/usr/lib/python2.6/site-packages/myghty/interp.pyRÏs   cCs |i|ƒS(skgets an attribute from this Interpreter. deprecated, use the "attributes" member directly instead.(R%(Rtkey((s1/usr/lib/python2.6/site-packages/myghty/interp.pyt get_attributeÚscCs|i||ƒdS(sisets an attribute on this Interpreter. deprecated, use the "attributes" member directly instead.N(R%(RRÒtvalue((s1/usr/lib/python2.6/site-packages/myghty/interp.pyt set_attributeßscCs |iƒS(s{returns the attributes dictionary for this Interpreter. deprecated, use the "attributes" member directly instead.(R%(R((s1/usr/lib/python2.6/site-packages/myghty/interp.pytget_attributesäsN((#R†R‡RˆRR2R-R.t LinePrintertsyststderrR+RVRXRWR\R_RcReR`RaRrRzR}R~RhRŠRŒR‹RRœRGRRÓRÕRÖ(((s1/usr/lib/python2.6/site-packages/myghty/interp.pyR%sL c     )    `*     (( Rˆt myghty.utilR‚tmyghty.synchronizationtmyghty.exceptionRZtmyghty.resolverR-tmyghty.requesttmyghty.csourcetmyghty.compilertmyghty.escapestmyghty.importerR’t myghty.buffert myghty.cachetmyghty.componentR³RjR©R¤ttypesRØR6trandomt posixpathRDRHRÂt py_compilet__all__R(((s1/usr/lib/python2.6/site-packages/myghty/interp.pyts&           ` $