m .Ec@sdZdkZdkZdkZdkZdklZdkl Z dk l Z dkl Z dkl Z lZdklZlZdklZlZd klZd klZd klZd klZd klZdklZdklZdkl Z dkl!Z!dkl"Z"dkl#Z#dk$l%Z%l&Z&dk'l(Z(dk)l*Z*dZ+dei,i-efdYZ.deeefdYZ/e e/dfdYZ0de0e/e.fdYZ1e e1d e0e/e.fd!YZ2e e2d"eeei,i-fd#YZ3e e3d$e3fd%YZ4e e4d&e/fd'YZ5e e5d(efd)YZ6d*Z7d+Z8dS(,sJProperty sheets $Id: PropertySheets.py 40300 2005-11-21 16:54:03Z efge $ N(s IWriteLock(sWriteLockInterface(stype_converters(sInitializeClass(sDTMLFiles MessageDialog(sImplicitsExplicit(s rfc1123_dates iso8601_date(surlbase(sBase(s Persistent(s Traversable(saq_base(sClassSecurityInfo(saccess_contents_information(smanage_properties(sview_management_screens(sgetSecurityManager(sisDavCollection(s BadRequestsRedirect(sescape(sListTypes Bad RequesttViewcBs;tZdZdZdZdZdZdZRS(sA view of an object, typically used for management purposes This class provides bits of management framework needed by propertysheets to be used as a view on an object. cCs|i|ddS(s+Implement a "management" interface s/manageN(tRESPONSEtredirecttURL1(tselfRR((t1/data/zmath/zope/lib/python/OFS/PropertySheets.pytmanage_workspace3scCs |iS(N(RtgetId(R((RttpURL8sc Csy |i}Wn d }nX|d jo d}nP|d}x8d D]0}|id}|djo|| }qEqEW|d}g}x|iii D]t}|d}hd |d <d||<d d|<}|i d }|d j o||d Return a manage option data structure for me instance s../../tURLiiit/itactiontlabeltpaththelpN(iii(RtREQUESTtrtNonetpretitrfindtlt aq_parenttmanage_optionstdR toptiontgetRtappend( RRRRRRRR R((RR:s0        - cCsm|id}|djo8|| }|id}|djo|| }qTntid|||S(NR ittabs_path_info(R RRRtinheritedAttributeRtscript(RRR R((RRUs   cCs#y|iiiSWn dSnXdS(Nt(RRt meta_type(R((RR ^s(t__name__t __module__t__doc__RRRRR (((RR,s     t PropertySheetcBs|tZdZfZdZdZeZeie ei e d6d7Z dZ e dZd Zeie d d Zd Zd ZdZeie ddZeie de dZeie ddZdZde dZe dZdZeie ddZeie ddZeie ddZeie d d!Zd"Z eie d#d$Z!d%Z"d&Z#d'Z$e#d(Z%e#d)Z&e#e$d*Z'[#[$e(d+e)Z*eie+d,d-Z,eie+d.e d/Z-eie+d0d1Z.eie+d2e d3Z/eie+d4e e d5Z0RS(8sA PropertySheet is a container for a set of related properties and metadata describing those properties. PropertySheets may or may not provide a web interface for managing its properties.isp_/Properties_icont AnonymoustManagertvaluestitemscCs|iS(sPReturn a flag indicating whether new properties may be added or removed.N(Rt _extensible(R((Rtproperty_extensible_schema__sscCsJ||ijotd||ifn||_|ph|_dS(Ns.'%s' is a reserved Id (forbidden Ids are: %s) (tidRt_PropertySheet__reserved_idst ValueErrortmdt_md(RR+R.((Rt__init__xs cCs|iS(N(RR+(R((RRst xml_namespacecCs|iiddS(NtxmlnsR(RR/R(R((RR1scCs|S(N(R(R((Rtv_selfscCs |iS(N(RR3(R((Rtp_selfscCsV| pB|d djp1|d djp d|jpt||jodSndS(Nit_itaq_t i(R+tescape(RR+((Rtvalid_property_idsJt hasPropertycCs4x-|iD]}||djodSq q WdS(NR+ii(Rt _propertyMaptpropR+(RR+R<((RR:s   t getPropertycCs+|i|ot|i|Sn|S(N(RR:R+tgetattrR3tdefault(RR+R?((RR=stgetPropertyTypecCsI|i}x6|iD]+}|d|jo|iddSqqWdS(sSGet the type of property 'id', returning None if no such property existsR+ttypetstringN(RR4tpselft _propertiesR.R+RR(RR+R.RC((RR@s  cCs!t|do tdndS(Ntaq_bases&Invalid property value: wrapped object(thasattrtobjectR-(RRG((Rt _wrapperChecks RBcCs|i||i|ptdt|n|ip tdn|i}|i }t t ||o<|djo|i i| ptdt|qn|djo h}nhd|<d|<d|<}|i|f|_|d jo?|p td n||d <|djo d}qOg}ntid i|tjot|}nt|||dS(NsInvalid property id, %s.s1Properties cannot be added to this property sheetttitles/Invalid property id, %s. It is in use.R+RAtmetat selectionsmultiple selectionsGThe value given for a new selection property must be a variable name

tselect_variablet __builtin__(RKsmultiple selection(RRHtvalueR9R+t BadRequestR8R*R4RCR3RFREt__dict__thas_keyRJRRAR<RDtsystmodulestListTypettupletsetattr(RR+RNRARJR<RC((Rt _setPropertys0     ! !     c Csu|i||i|ptdt|n|i|}d|i ddjotdt|nt |t djo:|i dd}t i |ot ||}qn|dj oeg}|i}x=|iD]2}|d |jo||d s(RR:R+ROR8R3tvselfRFRatndR[RtdelattrR4RCRUtfilterRD(RR+RdReRC((Rt _delPropertys  /  t propertyIdscCstd|iS(NcCs|dS(NR+(R(R((RRc s(tmapRR;(R((RRi stpropertyValuescCst|d|iS(NcCs|i|dS(NR+(tsR=R(RRl((RRcs(RjRR;(R((RRks t propertyItemscCst|d|iS(NcCs|d|i|dfS(NR+(RRlR=(RRl((RRcs(RjRR;(R((RRms R[cCsGx-|iD]}|d|jo|Sq q Wtdt|dS(NR+sThe property %s does not exist.(RR;tpR+R-R8(RR+Rn((RR[s   cCs |iiS(N(RR4RD(R((RR;!st propertyMapcCsttd|iS(NcCs |iS(N(tdicttcopy(Rp((RRc*s(RURjRR;(R((RRo(scCs/h}x"|iD]}|||d %s HTTP/1.1 %s %s s: %s c Csvg}x5|iD]'}|d|idd}}|i|}|djodi t t |}n*|djodi t t |}n|idhid d}|dj o+t d |i}d i |}n+d }t|d |pt|}nd ||||f}|i|qW|pd Sndi |}||i|dd fS(NR+RARBttokensR7tliness RJt __xml_attrs__cCsd|S(Ns %s="%s"(Rb(Rb((RRcMsRtdav__s %ss200 OK(tresultRR;titemRtnameRAR=RNtjoinRjtstrRtattrsR(RFt xml_escapeR<RtpropstatR1( RR~RyRNR<RxRwRAR|((Rt dav__allprop=s,    cCsfg}x%|iD]}|id|qW|pdSndi|}||i|ddfS(Ns Rs s200 OK(RwRRiRyRRzR~R1(RR~RwRy((Rtdav__propnames\s c Cs|i}|i}|i|pPd||f} d} |i| p| g|| s 404 Not FoundR+RARBRsR7Rts RJRucCsd|S(Ns %s="%s"(Rb(Rb((RRcsRsdav__%ss%s s200 OK(RR1txml_idRrtpropdictRQRyR<tcodeRwRRxRRAR=RNRzRjR{RR|R(RFR}( RRyRwR~tpropdescRRNRRxRR<RAR|((Rt dav__propstatgs:      sdtml/propertiestmanage_propertiesFormcCst|ddS(R7s/manageN(tRedirectR(RR((RRstmanage_addPropertycCs\ti|ot||}n|i||||dj o|i ||SndS(s_Add a new property via the web. Sets a new property with the given id, type, and value.N( R^RQRARNRRWR+RRtmanage(RR+RNRAR((RRs  tmanage_editPropertiescCsyx]|iD]O}|d}d|iddjo&|i|d}|i||q q Wtdddd d d S( s#Edit object properties via the web.R+RXRYRZRRIsSuccess!tmessagesYour changes have been savedR RN( RR;R<RyRRRNR`t MessageDialog(RRRyRNR<((RRs   tmanage_changePropertiescKs|d jo h}n|}|o+x(|iD]\}}|||(RR+R?R((RR=s RBcCstdt|dS(Ns%s cannot be set.(R-R8R+(RR+RNRARJ((RRWscCstdt|dS(Ns%s cannot be updated.(R-R8R+(RR+RN((RR` scCstdt|dS(Ns%s cannot be deleted.(R-R8R+(RR+((RRhscCsAt|ido$|ihdd<ddR(RR3RdtisDavCollection(RRd((Rtdav__resourcetype s  cCst|iiS(N(t rfc1123_dateRR3R(R((Rtdav__getlastmodified&scCsR|i}t|dot|iSnt|dot|iSndS(Nt content_typetdefault_content_typeR(RR3RdRFRRR(RRd((Rtdav__getcontenttype)s  cCs.|i}t|do|iSndS(Ntget_sizeR(RR3RdRFR(RRd((Rtdav__getcontentlength1s cCsD|i}t|do$t|i}d||fSndS(Nt document_srcsO %s %s/document_src R(RR3RdRFturlbaset absolute_urlturl(RRRd((Rt dav__source7s  cCsD|i}d}ti|pti|o|d7}n|S(Ns su (RR3Rdtoutt IWriteLockt providedBytWriteLockInterfacetisImplementedBy(RRdR((Rtdav__supportedlockAs   c Cst}|ii}|i}d}t i |pt i |o}|i dd}xZ|D]R}|id}||jo d}nd}d||idd|f}qfWd |}n|S( Ns t killinvalidsiiis%s %sRbtfakes%s (tgetSecurityManagerRtgetUserRtuserRR3RdRRRRRt wl_lockValuestlockstlockt getCreatortcreatorRtasLockDiscoveryProperty( RRRRRRRdRR((Rtdav__lockdiscoveryLs    #(R!R"R#R+R/RRR=RWR`RhR;RoRRRRRRRRR(((RRs&             tPropertySheetscBsmtZdZdZeZeieeiede Z e Z dZ dZedZdZeiedd Zeied d Zeied ed ZeiededZeieddZeieddZdZfedZdZdZeiedei de!Z"dZ#dZ$RS(sfA tricky container to keep property sets from polluting an object's direct attribute namespace.tpropertysheetsR%R&cCs |ifS(N(RR(R((Rt _get_defaultssscCs,|ii}|t|f}|i|S(N(RRt __propsets__tpropsetsRAt__traceback_info__R(RRR((RRvs cCsHx8|iD]*}|i|jo|i|Sq q Wt||S(N(RRtpropsetRRyt__of__R>(RRRyR((Rt__bobo_traverse__{s  cCs|i|i|S(N(RRRbR(RRb((Rt __getitem__sR'cCs|i}t|d|S(NcCs |i|S(N(RbRRl(RbRl((RRcs(RRRRj(RR((RR's R(cCsf|i}g}xM|D]E}t|do |i}nd}|i||i|fqW|S(NR+R( RRRRRbRFR+RR(RRbRRR+((RR(s   RcCs_xX|iD]J}|i|jp#t|do$|i|jo|i|Sq q W|S(NR1( RRRR+RyRFR1RR?(RRyR?R((RRs  3tmanage_addPropertySheetcCsphd|<}|i||}|i||djo|Sn|i |}|i i d|i dS(R7R2s %s/manageN( tnsR.RtPropertySheetClassR+tpstaddPropertySheetRRRRRR(RR+RRR.R((RRs  RcCs)|ii}||f}||i_dS(N(RRRRR(RRR((RRs  tdelPropertySheetcCsjg}xK|iiD]=}|i|jo$|i|jo|i|qqWt ||i_dS(N( RwRRRRRRyR1RRU(RRyRRw((RRs  &cCsC|i|}|djodSn||ijodSndS(scurrently, we say that *name* is deletable when it is not a default sheet. Later, we may further restrict deletability based on an instance attribute.iiN(RRRyRRR(RRyR((Rt isDeletables cCsnx<|D]4}|i|ptd|n|i|qW|dj o|ii d|i ndS(s&delete all sheets identified by *ids*.s.attempt to delete undeletable property sheet: s %s/manageN( RR+RRtBadRequestExceptionRRRRRR(RRRR+((Rtmanage_delPropertySheetss cCst|iS(N(tlenRR(R((Rt__len__scCs|iS(N(RR+(R((RRsRsdtml/propertysheetscCsy |i}Wn d }nX|d jo d}nP|d}x8d D]0}|id}|djo|| }qEqEW|d}g}x?|ii D]1}|i hd|d<d||d<qW|S( s>Return a manage option data structure for me instance s../tURLPATH0iiR iR R N(ii( RRRRRRRRRRRR(RRRRRR((RRs&        /cCsC|id}|djo|| }ntid|||S(NR iR(R RRRRRR(RRR R((RRs (s AnonymoussManager(%R!R"R#R+RRRRRR$RRRRRRRRRR'R(RRRRRRRRRtview_management_screenstGlobalsRRRRR(((RRds@                   tDefaultPropertySheetscBs)tZdZeZeZdZRS(sA PropertySheets container that contains a default property sheet for compatibility with the arbitrary property mgmt design of Zope PropertyManagers.cCs|i|ifS(N(RR?R(R((RRs(R!R"R#RR?RRR(((RRs   t FixedSchemacBs5tZdZedZdZdZdZRS(sKA Fixed-schema property sheet has no control over it's schema It gets its schema from another proprtysheet but has control over its value storage. This mix-in is used for ZClass instance proprtysheets, which store their data in instances, but get their schema from the proprtysheet managed in the ZClass. cCs&tid|||||_dS(NR0(RRRR+R.tbaset_base(RR+RR.((RR0scCs|g}xi|iiD]X}|i}|idd}d|jotd||d