mò $á¸Ec@s\dZddd!ZdklZlZlZlZdkZdk Z dkl Z dk l Z dk lZd k lZd k lZdkZ dkZdkZdkZdkZd klZd klZlZlZd klZdklZdklZede ƒƒZ!dd„Z#dei$i%ee i&e i'i(efd„ƒYZ)e e)ƒdS(sŒExternal Method Product This product provides support for external methods, which allow domain-specific customization of web environments. s$Revision: 1.52 $i iþÿÿÿ(s PersistentsDTMLFiles MessageDialogsHTMLN(sInitializeClass(sClassSecurityInfo(schange_external_methods(sview_management_screens(sview(s pretty_tb(s getObjectsgetPathsFuncCode(sDevelopmentMode(s Navigation(sComputedAttributesdtml/methodAddcCszt|ƒ}t|ƒ}t|ƒ}t|ƒ}t||||ƒ}|i||ƒ|dj o|i ||ƒSndS(sNAdd an external method to a folder Un addition to the standard object-creation arguments, 'id' and title, the following arguments are defined: function -- The name of the python function. This can be a an ordinary Python function, or a bound method. module -- The name of the file containing the function definition. The module normally resides in the 'Extensions' directory, however, the file name may have a prefix of 'product.', indicating that it should be found in a product directory. For example, if the module is: 'ACMEWidgets.foo', then an attempt will first be made to use the file 'lib/python/Products/ACMEWidgets/Extensions/foo.py'. If this failes, then the file 'Extensions/ACMEWidgets.foo.py' will be used. N( tstrtidttitletmoduletfunctiontExternalMethodtitselft _setObjecttREQUESTtNonet manage_main(RRRRRR R((tE/data/zmath/zope/lib/python/Products/ExternalMethod/ExternalMethod.pytmanage_addExternalMethod$s     RcBs~tZdZdZeƒZeieƒed„ƒZ ed„ƒZ e i Z e i Ze i Zhdd<dd<dd\scCs |iƒS(N(Rt getFuncCode(R((R R]stlabelt PropertiestactionR thelpRsExternal-Method_Properties.stxtTesttsExternal-Method_Try-It.stxcCs ||_|i|||ƒdS(N(RRt manage_editRRR(RRRRR((R t__init__os sdtml/methodEditRcCsµt|ƒ}t|ƒ}t|ƒ}||_|ddjo|d }n |ddjo|d }n||_||_|idƒ|o d}|i ||d|ƒSndS( s“Change the external method See the description of manage_addExternalMethod for a descriotion of the arguments 'module' and 'function'. Note that calling 'manage_edit' causes the "module" to be effectively reloaded. This is useful during debugging to see the effects of changes, but can lead to problems of functions rely on shared global data. iýÿÿÿs.pyiüÿÿÿs.pycisExternal Method Uploaded.tmanage_tabs_messageN( RRRRRt_modulet _functiont getFunctionR tmessageR (RRRRR R((R Rws        icCslt|i|i|ƒ}t|dƒo |i}n|}|i |_ t |||j ƒ|_ ||_ |S(Ntim_func(t getObjectRRRtreloadtfthasattrRtfft func_defaultst_v_func_defaultstFuncCodet _v_func_codet_v_f(RR R!R#((R Rs   cCs`ti|iƒƒti}t|dƒ p||ijo|idƒ|_ ||_ndS(Nt _v_last_readi( toststatRtfilepathtST_MTIMEttsR"R)RR((RR.((R treloadIfChangeds!cCs4|iƒt|dƒp|iƒ|_n|iS(NR%(RR/R"RR(R%(R((R R¨s cCs4|iƒt|dƒp|iƒ|_n|iS(NR'(RR/R"RR(R'(R((R R®s cCs*t|dƒp|iƒ|_n|iS(NR%(R"RRR(R%(R((R R´scCs*t|dƒp|iƒ|_n|iS(NR'(R"RRR(R'(R((R R¹st__call__cOsR|iƒ}|djo td‚ntii|ƒp td‚nto|i ƒnt |dƒo |i }n |i ƒ}|||if}y|||ŽSWn¤tj o˜}tiƒd}zu|iit|ipfƒdt|ƒjo4|iiddjo||iiƒ||ŽSnt||‚Wdd}XnXdS( s‘Call an ExternalMethod Calling an External Method is roughly equivalent to calling the original actual function from Python. Positional and keyword parameters can be passed as usual. Note however that unlike the case of a normal Python method, the "self" argument must be passed explicitly. An exception to this rule is made if: - The supplied number of arguments is one less than the required number of arguments, and - The name of the function's first argument is 'self'. In this case, the URL parent of the object is supplied as the first argument. s6external method could not be called because it is NonesCexternal method could not be called because the file does not existR(iiiRN(RR,tfilePathR t RuntimeErrorR*tpathtexiststDevelopmentModeR/R"R(R!RtargstkwR%t__traceback_info__t TypeErrortvtsystexc_infottbR't co_argcounttlent co_varnamest aq_parenttthis(RR6R7R!R1R=R8R:((R R0¿s*      HcCs|iS(N(RR(R((R RôscCs|iS(N(RR(R((R RõscCs6t|dƒptd|iddƒ|_n|iS( Nt _v_filepatht ExtensionstsuffixesRtpytpyctpyp(RRFRGRH(R"RtgetPathRRC(R((R R,÷s (sExternalMethodsExternal-Method_Properties.stx(sExternalMethodsExternal-Method_Try-It.stx()t__name__t __module__t__doc__t meta_typetClassSecurityInfotsecuritytdeclareObjectProtectedtViewtComputedAttributeR$t func_codet AcquisitiontAcquiredtZopeTimetHelpSystmanage_page_headertOFSt SimpleItemtItemtmanage_optionst AccessControltRolet RoleManagerRtdeclareProtectedtview_management_screenstDTMLFiletglobalsR tchange_external_methodsR RRR/R5RRR0RRR,(((R REs6      \        5  (*RLt __version__tGlobalst PersistentRbt MessageDialogtHTMLtOFS.SimpleItemRYRTtInitializeClassR]RNtAccessControl.PermissionsRdRatviewRQtAccessControl.RoleR;R*R+t tracebackt pretty_tbtApp.ExtensionsRRIR&R5tApp.Managementt NavigationRRRctmanage_addExternalMethodFormR R RZR[tExplicitR^R_R(R+RRRpRtRsRIRdRiRkReRRRaRNRgRbR;R&RhRTRQR]R R5RYRoR*((R t?s$      -     !1¸