m %Ec@sPdZddd!ZdkZdkZdkZdkZdkZdkZdkl Z dk l Z l Z l Z dkZdkZdkZdklZdklZd klZd klZd klZd klZd klZlZl Z dkl!Z!dk"l#Z#l$Z$dk%l&Z&dk'l(Z(l)Z)dk*l+Z+dk Z e dZ,dk-Z-e-i.Z/[-dZ0da1e de2Z3ei4i5e e2ddZ6gZ7e8e8dZ9dee#e&fdYZ:e i;e:dfdYZ<ei=dZ>ei=dZ?hd d!<d"d#<d$d%<d&d'<d(d)d?d@dAdBdCdDZ4e4Z5dEZ6dFZ7dGZ8dHZ9dIZ:dJZ;dKZ<e<Z=dLZ>e!e!dMZ?RS(QsWeb-callable scripts written in a safe subset of Python. The function may include standard python code, so long as it does not attempt to use the "exec" statement or certain restricted builtins. sScript (Python)RitlabeltEdittactiontZPythonScriptHTML_editFormthelpRsPythonScript_edit.stxtTesttZScriptHTML_tryFormsPythonScript_test.stxtProxytmanage_proxyFormtOFSPsDTML-DocumentOrMethod_Proxy.stxcCs$||_|it|idS(N(RRtZBindings_edittdefaultBindingst _makeFunction(RR((Rt__init__ns  tViewt__call__sView management screenst manage_mainRtPrincipiaSearchSourcet document_srctparamstbodyt get_filepathswww/pyScriptEditsChange Python ScriptstZPythonScriptHTML_editActiontZPythonScript_setTitletZPythonScript_edittZPythonScriptHTML_uploadtZPythonScriptHTML_changePrefscCs9|i||i||d}|i||d|S(s$Change the script's main parameters.sSaved changes.tmanage_tabs_messageN( RR4ttitleR5R0R1tmessageR R (RR R9R0R1R:((RR3s   cCs7t|}|i|jo||_|indS(N(RR9RtZCacheable_invalidate(RR9((RR4s  cCs|i|io tdnt|tdj o|i}n|i|jp|i |jp |i o t ||_|i |ndS(Ns The script is locked via WebDAV.R( Rt_validateProxyt wl_isLockedtResourceLockedErrorRR1Rt_paramsR0t_bodyt _v_changeRR(RR0R1((RR5s   *cCs|io tdnt|tdj o$|p tdn|i}n|i|d}|i ||d|S(s5Replace the body of the script with the text in file.s The script is locked via WebDAV.RsFile not specifiedsSaved changes.R8N( RR=R>RRt ValueErrorRRR:R R (RR RR:((RR6s     s100%t20c Cshdd<dd|idjod|_|_n|iti|idS(Nt Python_magict Script_magicis i(tScriptt __setstate__RtstatetgetattrR RqRrt_log_complainttLOGtinfoR@trstripR1t_compileRAt_codet_v_ftt_v_ft_newfuntmarshaltloads(RRuR1((RRts2    cOsti||S(N(tRestrictedPythontcompile_restricted_functiontargstkw(RRR((Rt _compilersc Csv|ii}|i|i|ipd|i|id|} | d}| d}t | d|_ |od|_d|_|_|iffdd}xQtt|D]=}||}|i|o|i|dd||",s Script(&RtgetBindingAssignmentstgetAssignedNamesInOrdert bind_namesRR?R@Rt meta_typetrtcodeterrorsttupletwarningsR R|R}R~t_setFuncSignaturet filestringtrangetlentitlinet startswithtreplaceRtdumpsRtft func_codetfct func_defaultst co_varnamest co_argcountRqRrRA( RRRRRRRRRR((RR{s8      !      cBsqe}e|d%s because you do not have proxy roles. ( trolesR RRtgetSecurityManagertgetUsertusertallowedt ForbiddenR(RRR((RR<]s  sChange proxy rolest manage_proxyswww/pyScriptProxycCsX|i||i|it||_|otddddddSndS(sChange Proxy RolesR9sSuccess!R:sYour changes have been savedRR-N(RR<RR;RRR t MessageDialog(RRR ((RRks    tPUTt manage_FTPputRtmanage_historyCopytmanage_beforeHistoryCopytmanage_afterHistoryCopycCsP|i|||i||dd|i|idd|id|S(s Handle HTTP PUT requests trefreshitBODYRiN(Rt dav__initR Rtdav__simpleifhandlerRRt setStatus(RR R((RR{s  c CsH|i|i}|ii}d} d}yxt i ||}|p d}Pn|idi} | d djo||id}Pn|id}t| djp| ddjp d| joq:n| didd\}}|ii}|i}|i|ptd| fn|||joq:n|d jo ||_q:|d jo ||_q:|d d jo||t|d twebdav.WriteLockInterfaceRtShared.DC.Scripts.ScriptRsR R(Rt OFS.HistoryR Rpt OFS.CacheR tAccessControl.ZopeGuardsRRt zExceptionsRRxtimpt get_magicRqRrRwRtmanage_addPythonScriptFormRKRRRR RR tInitializeClassRtcompileRRR(,R R RsR RRZRRRRRxRRpR$RrR RgRR RRRqR>RRRR'R3R(RRR5R RRR"RR%RRR!RR&R((Rt?sH 6