m .Ec @sMdZdkZdkZdkZdkZdkZdkZdkZdk Z dk Z dk Z dk Z dkZ dk lZdklZdklZlZdklZdklZdk lZlZlZlZdklZd klZd kl Z d k!l"Z"d k#l$Z$d k%l&Z&dk'l(Z(dk)l*Z*dk+Z+dk,l-Z-dk.l/Z/dk.l0Z0dk.l1Z1dk2l2Z2e i3Z3dk4Z4e4i5Z6de"e$e-e i7i8e2e+i9ei:i:e i;i<fdYZ=ee=de=fdYZ>ddZ?de=e i@e iAeiBiCfdYZDeeDdS(s5This module implements a simple item mix-in for objects that have a very simple (e.g. one-screen) management interface, like documents, Aqueduct database adapters, etc. This module can also be used as a simple template for implementing new item types. $Id: SimpleItem.py 40468 2005-12-02 13:45:58Z chrisw $ N(sInitializeClass(sClassSecurityInfo(sgetSecurityManagers Unauthorized(sview(sgetRoles(saq_bases aq_parentsaq_inners aq_acquire(sComputedAttribute(s html_quote(sustr(sBase(sResource(sRedirect(sformat_exception(s implements(s CopySource(sIItem(s IItemWithName(s ISimpleItem(s TraversabletItemc BstZdZeeeZdZdZdZ e e _ dZ e e _ dZ e e _ dZeiddZedZdZd ZdZfZeiiieiiihd d <d d ess simple itemtlabelt Interfacestactiontmanage_interfacesicCs<|i}t|o |}n|o|Sn|iS(sBReturn the title if it is not blank and the id otherwise. N(RttitleRR (RR((Rt title_or_ids   cCsK|i}t|o |}n|i}|od||fp|S(sReturn the title if it is not blank and the id otherwise. If the title is not blank, then the id is included in parens. s%s (%s)N(RRRR R (RR R((Rt title_and_ids     cCs|S(N(R(R((RtthisscCs |iS(N(RR (R((RttpURLscCsfS(N((R((RttpValuesssdtml/editedDialogcKst|i||f|S(N(tapplyRt_manage_editedDialogtREQUESTtargs(RRR ((Rtmanage_editedDialogss [a-zA-Z]>c CsmzE|djotid}n|djotid}n|djo!|djotid}nt|tdj o#|djot|||}n,t|tdjo| o |}nt |do |i }nt |do|||nd|_ t |idjo|||n|pgyt|} Wn |} nXy|| } Wntj o d} nX| dj o |}qn|djo |}n|p|id}nyt |d ot|d } n|i}t|d } hd |<d |<d |<d |<d|<d| <} tt| ddo| ||| }n6t| o| | }nti | ||| }Wnnt!i"ddt#yt |} Wn dt t|i } nX| dt%tidf}nX|||Wdt |do |` nd}XdS(NiiiRR t_v_eektredirectRtstandard_error_messaget error_typet error_valueterror_tbterror_tracebackt error_messaget error_log_urlt isDocTemps*Exception while rendering an error messagetexc_infoss (Also, the following error occurred while attempting to render the standard error message, please see the event log for full details: %s)(R#(&R%R tsysR,R&ttbR'ttypet pretty_tbRR RR"tstrtlowerR)tustrtst tagSearchtmatcht TypeErrortclientRt aq_acquireR t aq_parentR*tkwargstaq_basetvRtHTMLt__call__tloggerterrortTruetstrvt html_quote(RR8RR%R&R.R'R)R5R*R;R6RCR4R=((Rtraise_standardErrorMessagesr  &!        <   % cCstd|dS(s s%s/manage_mainN(tRedirecttURL1(RRG((RtmanagescCsfS(N((Rtspec((Rt objectValuessc CsUdkl}d}tt|doy1tid|d|i o|dB}nWnt j onX|i |i t |d|i fo|dB}qntt|doy1tid|d|i o|dB}nWnt j onX|i |i t |d|i fo|dB}qAntt|d o|i} n3tt|dot|i } nd } tt|d o|ii}n ti}d }}tt|d o9x6|iD]$\}}d|jo |}PqqWnti|d d d||| |||f S(s9Psuedo stat, used by FTP for directory listings. (snobodyit manage_FTPgeti itPUTiitget_sizeitbobobase_modification_timetZopetget_local_rolestOwneriN(tAccessControl.UsertnobodytmodeRR<RtgetSecurityManagertvalidateR RKt UnauthorizedtallowedtgetRolesRLRMtsizetlenRNttimeTimetmtimettimetownertgroupRPtusertrolestmarshaltdumps( RRRaR`RSRTR]R_RbRZ((Rtmanage_FTPstatsJ        cCs|}xFtii|otdnt|dpPn|i}q Wti |i |}|i }ti||fS(sDirectory listing for FTP. In the case of non-Foldoid objects, the listing should contain one object, the object itself. is*FTP List not supported on acquired objectsR:N(RtobtApptCommont is_acquiredt ValueErrorRR:RctloadsReRtstatR R Rd(RRRlRfR ((Rtmanage_FTPlist?s cCsdS(Ni((R((Rt__len__RscCsydi|i}Wnti|SnXd}t|}tt |}t |t |j o-ydi|i}Wqd}qXnd|i i}|d|7}|o|d|7}n|d7}|S(sKShow the physical path of the object and its context if available. t/s<%ss at %ss used for %st>N(tjoinRtgetPhysicalPathtpathtBaset__repr__R t context_pathR:tcontexttaq_innerRR<t __class__R tres(RRRzRvRwRs((RRuUs&  (7R t __module__t__doc__t implementstIItemtClassSecurityInfotsecuritytisPrincipiaFolderisht$isTopLevelPrincipiaApplicationObjectRRBt__five_method__RRR t declarePublicR tComputedAttributeticont meta_typeRt __propsets__RgtUndot UndoSupporttmanage_optionst AccessControltOwnedt AcquisitiontAcquiredRt*__allow_access_to_unprotected_subobjects__RRRRRtGlobalstDTMLFiletglobalsRR!R tretcompiletsearchRERHRJt objectIdst objectItemsReRmRnRu(((RR7sJ           5     0V    7  tItem_w__name__cBsEtZdZeedZdZdZdZdZ RS(s/Mixin class to support common name/id functionscCs|iS(s1Return the id of the object as a string. N(RR (R((RR tscCs|ip|iS(sBReturn the title if it is not blank and the id otherwise. N(RRR (R((RRyscCs+|i}|od||ifp|iS(sReturn the title if it is not blank and the id otherwise. If the title is not blank, then the id is included in parens. s%s (%s)N(RRttR (RR((RR~s cCs ||_dS(N(R RR (RR ((Rt_setIdscCsC|if}tt|}|dj o|i|}n|S(s%Get the physical path of the object. Returns a path (an immutable sequence of strings) that can be used to access this object again later, for example in a copy/paste operation. getPhysicalRoot() and getPhysicalPath() are designed to operate together. N(RR RsR:RxtpR Rr(RRRs((RRrs   ( R R{R|R}t IItemWithNameR RRRRr(((RRns      icCs+t|||d|}di|}|S(Ntas_htmls (tformat_exceptionRR=R.RRq(RR=R.R((RR0st SimpleItemcBs\tZdZeeeZeied e i hdd<dd<dd tloggingt getLoggerR@t ManagementtTabstElementRRRRRR0t PersistenttImplicittRolet RoleManagerR((RFR~R9R:RRR>RRR0RRtRRRxR}RR<RWRRRRYR-RRR@RRRRR3RRURgRR^RDRcR((Rt?sD $$                     @5 , +