PhEc@sdZddklZddkTddkTddkZddkZddkZddkZddk Z ddk Z ddk Z ddk Z ddddd gZeed feed feed feed feedfeedfeedfeedffZdefdYZdefdYZd efdYZdefdYZdefdYZdefdYZdS(sthe component package defines the Component class and several subclasses. FileComponent serves as the base class for template style-components, and ModuleComponent the base for module-based components.i(t exception(t*Nt ComponenttModuleComponenttHTTPModuleComponentt FileComponentt SubComponenttrequired_request_argst request_argstrequired_subrequest_argstsubrequest_argst required_argstargstrequired_dynamic_argst dynamic_argscBseZdZdZedddZedddZedddZed dd Zed dd Z ed ddZ dZ edZ dZ dZdZdZdZd/dZedZdZdZdZdZdZdZdZedZd Zd!Z d"Z!d#Z"d$Z#d%Z$d&Z%d'Z&d(Z'd)Z(d*Z)d+Z*d,Z+d-Z,d.Z-RS(0sBase class for all components. the primary method is the run() method which executes the Component in the context of a particular request. A Component instance is usually cached in memory based on its component ID and can execute many requests simultaneously.cKsd|_d|_|_h|_h|_g|_||_t|_ |_ |_ |_ d|_ d|_||_t|_dS(sFinitializes a new Component. this method is called by the Interpreter.iN(tNonetfiltertownertparent_componenttflagstattrt argumentstcomponent_sourcetFalset is_methodtis_filetis_subcomponentt is_moduletsizet use_countt interpretert ThreadLocalt threads_init(tselfRRtparams((s4/usr/lib/python2.6/site-packages/myghty/component.pyt__init__,s        cCs |iiS((Rtid(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt?stdocs$unique identifier for this componentcCs |iiS((RR$(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Bss;unique identifier for the ComponentSource of this componentcCs |iiS((Rtname(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Essname of this componentcCs |iiS((Rtdir_name(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Hss(relative directory name of the componentcCs |iiS((Rtpath(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Kss#relative full path of the componentcCs |iiS((Rt file_path(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Nss3the actual filename of the component, if one existscCs#|idj o |iiSdSdS(N(RRt attributes(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt _parentattrQs cstifdS(cs iS((R,((R!(s4/usr/lib/python2.6/site-packages/myghty/component.pyR%Ws(t InheritedDictR(R!((R!s4/usr/lib/python2.6/site-packages/myghty/component.pyR%WscCs|i|idS(sinitializes the component after construction. Calls the do_component_init() method before setting up the component's arguments.N(tdo_component_initt_convert_component_args(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytcomponent_initYs c CsxtD]}|ig}t||dgD]}||d||dq/~7_t||dg}|iD]<}|i|djo"|i|djo||iqsqs~qWdS(Niii(targtypesRtgetattrtsetattrt __class__trequiredR'(R!targtypet_[1]targt_[2]((s4/usr/lib/python2.6/site-packages/myghty/component.pyR/_sKcCs tdS(sFoverridden by subclasses to perform per-instance initialization steps.N(tNotImplementedError(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR.lscKs|id7_h}x$|iD]}|i|||qW|i|i|iip|i|iit n|i d|d||S(sruns this component in the context of the given request. **params are the arguments sent to the component, which become ARGS in the context of the component's runtime environment.itmtARGS( RRtget_argtupdatet global_argsR texiststdo_thread_inittassigntTruetdo_run_component(R!trequestR"t compparamsR8((s4/usr/lib/python2.6/site-packages/myghty/component.pytrunps  cCs |idjS(s;returns True if this component defines a <%filter> section.N(RR(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt has_filterscs|iidot|id section.N(RRRRRtget_flagRC(R!tkeytinherittparent((s4/usr/lib/python2.6/site-packages/myghty/component.pyR[s   cCsdS(sbreturns a SubComponent of the given name, represented within the source of this Component.N(R(R!R'((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_sub_componentscKs tdS(sMoverridden by subclasses to provide the main execution body of the component.N(R:(R!R;R<R"((s4/usr/lib/python2.6/site-packages/myghty/component.pyRDscCsdS(sHoverridden by subclasses to provide a per-thread initialization routine.N((R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyRAscCs tdS(sreturns a method SubComponent of the given name, represented either within the source of this Component or within the source of an inherited Component, i.e. the inheritance hierarchy will be searched for the approrpriate method call.N(R:(R!t method_name((s4/usr/lib/python2.6/site-packages/myghty/component.pytlocate_inherited_methodscKs1|i|}tiii|d|d|S(s8calls a method SubComponent of the given name on this component. This amounts to locating it via locate_inherited_method, retrieving the current request via request.instance(), and then calling execute_component on that request. See also m.comp("component:methodname") R tbase_component(RatmyghtyREtinstancetexecute_component(R!R`R"tmethod_component((s4/usr/lib/python2.6/site-packages/myghty/component.pyt call_methods cKsJ|i|}t}tiii|d|d|d||iS(s{same as call_method, but returns the component output as a string See also m.scomp("component:methodname") R Rbtstore(RatStringIORcRERdRetgetvalue(R!R`R"Rftbuffer((s4/usr/lib/python2.6/site-packages/myghty/component.pyt scall_methods (cCs|iddtS(s|returns True if this component defines the "autoflush" flag as True, or if an inherited component defines this flag.RJR](R[RC(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytuse_auto_flushscCs |i|S(N(R+(R!R\R]((s4/usr/lib/python2.6/site-packages/myghty/component.pyt get_attributescCs|i||dS(N(R+(R!R\tvalue((s4/usr/lib/python2.6/site-packages/myghty/component.pyt set_attributescCs|iS(N(R+(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_attributesscCs|ii|S(N(R+RR(R!R\((s4/usr/lib/python2.6/site-packages/myghty/component.pytattribute_existsscCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt get_ownerscCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_parent_componentscCs|iS(N(R$(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_idscCs|iS(N(R'(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_namescCs|iS(N(t source_id(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt get_source_idscCs|iS(N(tfile(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_filescCs|iS(N(R)(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytget_pathscCs|iS(N(R((R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyt get_dir_namescCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytis_method_componentscCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytis_module_componentscCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytis_file_componentscCs|iS(N(R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pytis_sub_componentsN(.t__name__t __module__t__doc__R#tpropertyR$RwR'R(R)RyR,R+R0R/R.RGRHRRZRR[R_RDRARaRgRlRmRCRnRpRqRrRsRtRuRvRxRzR{R|R}R~RR(((s4/usr/lib/python2.6/site-packages/myghty/component.pyR&s\                                       cBsqeZdZdZdZdZdZdZdZdZ dZ d Z e e d Z RS( s6a component that corresponds to a Myghty template filecKsti||||d|_d|_d|_d|_t|_|i |_ |i |i ot d|i|_n|ioti|_n|ii|_|ii|i|idS(Ntcreator(RR#Rtdefstmethodst inherit_pathtinherit_start_pathRCRt modulesizeRR0tuses_thread_localRtthread_local_initializert thread_localtuses_request_localtweakreftWeakKeyDictionaryt request_localtcopyt subcomponentsR>t_determine_inheritance(R!RRR"((s4/usr/lib/python2.6/site-packages/myghty/component.pyR#s         cCs tdS(N(R:(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyRscCs tdS(N(R:(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyRscCstS(N(RC(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyRscCs'|ii|o |i|SdSdS(N(RRRR(R!R'((s4/usr/lib/python2.6/site-packages/myghty/component.pyR_s cKs6d}|io|ioe|ii|o|i|}q|ii||||}|||||}||i|s cCs|i}|i}|iidoD|iddjoqtiti|i|id|_ nh|i o]|i |i jo7|io)|idjoti |i|_qq|ii|_ndS(NR]t/(RRRRRRtunixpathtnormpathtjoinR(Rtuse_auto_handlersR'tauto_handler_nametdirnameR(R!Rtsource((s4/usr/lib/python2.6/site-packages/myghty/component.pyRHs  , c Cs%ytii}Wntj o d}nX|idj oH|dj o|i|idd}q!|ii|idd}n|i dj o|dj o:|it i |i |ii dt dtdd}q!|iit i |i |ii dt dtdd}nd}|S(sreturns the parent component of this component, taking into account the component's inherit flag as well as the interpreter's autohandler propertiestresolver_contextR]tsearch_upwardst raise_errorN(RcRERdRWRRtload_componentRtloadRRRRRCR(R!RER((s4/usr/lib/python2.6/site-packages/myghty/component.pyt_parent_component]s   :=cCsdS(N(R(tstp((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%s(RRRR#RRRR_RRaRRRR(((s4/usr/lib/python2.6/site-packages/myghty/component.pyRs        #cBseZdZdZdZedZeddZeddZedd Z d Z d Z d Z d Z RS(s]a component that corresponds to a <%def> or <%method> tag inside a file-based component.cKsNti||i|i|||_||_||_t|_|i dS(N( RR#RRt_SubComponent__namet_SubComponent__ownerRRCRR0(R!R'RRR"((s4/usr/lib/python2.6/site-packages/myghty/component.pyR#s     cKs|ii||||S(N(RR(R!R\R;R<R"((s4/usr/lib/python2.6/site-packages/myghty/component.pyRscCs|iid|iS(t:(RR$R'(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCs |iiS((RR(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCsdS(N(R(RR((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCs|iS((R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCsdS(N(R(RR((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCs|iS((R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCsdS(N(R(RR((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCs|ii|S(N(RR_(R!R'((s4/usr/lib/python2.6/site-packages/myghty/component.pyR_scCs|ii|S(N(RRa(R!R`((s4/usr/lib/python2.6/site-packages/myghty/component.pyRascOs|ii||S(N(RRg(R!R R"((s4/usr/lib/python2.6/site-packages/myghty/component.pyRgscOs|ii||S(N(RRl(R!R R"((s4/usr/lib/python2.6/site-packages/myghty/component.pyRls(RRRR#RRR$RR'RR_RaRgRl(((s4/usr/lib/python2.6/site-packages/myghty/component.pyRs    cBseZdZd edZeddZeddZdZ dZ dZ d Z d Z d Zd ZRS(sKA component that is a regular Python class inside of a plain Python module.cCsti||||ii|_t|_|i|_t |_ |djo ||_ n ||_ |o|i ndS(N(RR#R4Rt_ModuleComponent__nameRCRt last_modifiedt creationtimetRegistryRRt_ModuleComponent__ownerR0(R!tinterpRRtdo_init((s4/usr/lib/python2.6/site-packages/myghty/component.pyR#s      cCs|iS((R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCsdS(N(R(RR((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCs|iS((R(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%scCsdS(N(R(RR((s4/usr/lib/python2.6/site-packages/myghty/component.pyR%sc Cs<|i}ti|}|dpg}|dpg}tg}|iiidddgD]}||tfqa~}g} |dt|t|!D]!}|i |p | |qq~ g} |t|t|D]!}|i |p | |qq~ |_ |_ ||_ |ddj |_dS(NiiR;R<R!i(Rtinspectt getargspectdictRtcompilert allow_globalsRCtlenRRR R t_allargsRt _has_params( R!tfunctiontcsourcetargspectargnamest defaultvaluesR7taRPR9t_[3]((s4/usr/lib/python2.6/site-packages/myghty/component.pyt _inspect_argss FIS cCso|it|idjoAx>tD]}t||doPq'q'W|i|iin|idS(Nii( R.RRR1thasattrRRDtim_funcR/(R!R6((s4/usr/lib/python2.6/site-packages/myghty/component.pyR0s  cCsdS(N((R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR.scKs tdS(N(R:(R!R;R<R"((s4/usr/lib/python2.6/site-packages/myghty/component.pyRDscCstS(N(RC(R!((s4/usr/lib/python2.6/site-packages/myghty/component.pyR~scCs3|ii|jo|S|ii|id|S(NR(R4RRtload_module_componentR(R!R`((s4/usr/lib/python2.6/site-packages/myghty/component.pyt _find_methodscsGijo#iidfdSiiSdS(Nt createfunccstiS((RR((R`R!(s4/usr/lib/python2.6/site-packages/myghty/component.pyR%s(RRRRa(R!R`((R`R!s4/usr/lib/python2.6/site-packages/myghty/component.pyRas#N(RRRRRCR#RRR'RR0R.RDR~RRa(((s4/usr/lib/python2.6/site-packages/myghty/component.pyRs      cBs)eZdZdZdZdZRS(sKA ModuleComponent that contains methods specific to a generic HTTP request.cKs|iddS(Ni(tabort(R!R;trR"((s4/usr/lib/python2.6/site-packages/myghty/component.pytdo_postscKs|iddS(Ni(R(R!R;RR"((s4/usr/lib/python2.6/site-packages/myghty/component.pytdo_getscKsehtid6tid6}y$||i}|||||SWn tj o|idnXdS(NtGETtPOSTi(RRRtmethodRWR(R!R;RR"RRN((s4/usr/lib/python2.6/site-packages/myghty/component.pyRDs   (RRRRRRD(((s4/usr/lib/python2.6/site-packages/myghty/component.pyRs  tFunctionComponentcBs2eZdZdZdZdZdZRS(sa module component that "wraps" a regular Python function or method, including introspection of its signature to automatically produce the required_args and args lists cCs|i}|i|i|iio\|iii}t|do9t|d o(zt|d|Wdt|_XqndS(NR.t_component_init( RRt callable_t has_methodtim_selfRR2RCR(R!Rttarget((s4/usr/lib/python2.6/site-packages/myghty/component.pyR. s  !cKsk|io|ii|Sh}x3|iD](}|i|o|||| s.     $       M