m $Ec@sdZdkZdklZdklZdklZdkl Z dk l Z dk Z dk l Z dk lZd klZd klZd klZlZd klZd klZdklZlZdklZdkl Z l!Z!dk"l#Z#l$Z$dk%l&Z&dk'l(Z(dk)l*Z*dk)l+Z+dk)l,Z,dk-l.Z.dk-l/Z/dk0Z1e dZ2e de3Z4de5dZ6dZ7dZ8dZ9gZ:d Z;d!e<fd"YZ=d#efd$YZ>e i?e>de>efd%YZ@e i?e@dS(&sMBTreeFolder2 $Id: BTreeFolder2.py,v 1.27 2004/03/17 22:49:25 urbanape Exp $ N(sescape(squote(srandint(s StringType(s getLogger(sDTMLFile(s Persistent(saq_base(sOOBTree(sOIBTreesunion(sLength(s ConflictError(sBadRequestExceptionsBeforeDeleteException(sFolder(sgetSecurityManagersClassSecurityInfo(saccess_contents_informationsview_management_screens(sLazyMap(snotify(sObjectAddedEvent(sObjectRemovedEvent(snotifyContainerModified(sObjectWillBeAddedEvent(sObjectWillBeRemovedEventt BTreeFolder2t folderAddtcCsqt|}t|}t||_|i|||i|}|dj o|i ||ddSndS(s0Adds a new BTreeFolder object with id *id*. t update_menuiN( tstrtidRtobttitlet dispatchert _setObjectt_getObtREQUESTtNonet manage_main(RRRR R((tA/data/zmath/zope/lib/python/Products/BTreeFolder2/BTreeFolder2.pytmanage_addBTreeFolder5s   s7 itExhaustedUniqueIdsErrorcBstZRS(N(t__name__t __module__(((RRMstBTreeFolder2BasecBstZdZeZhdd<ddFill this folder with the contents of another folder. N( tsourcet objectIdstnameR R tvalueRt_setObtaq_base(RR R"R#((Rt_populateFromFolderrs   tmanage_fixCountcCsU|i\}}di|i}||jo d|Snd|||fSdS(s?Calls self._fixCount() and reports the result as text. t/s1No count mismatch detected in BTreeFolder2 at %s.sIFixed count mismatch in BTreeFolder2 at %s. Count was %d; corrected to %dN(Rt _fixCounttoldtnewtjointgetPhysicalPathtpath(RR+R*R.((RR'|s   cCsI|i}t|i}||jo|ii|n||fS(sChecks if the value of self._count disagrees with len(self.objectIds()). If so, corrects self._count. Returns the old and new count values. If old==new, no correction was performed. N(RRR*tlenR!R+tset(RR+R*((RR)s   tmanage_cleanupcCs@|i}di|i}|o d|Sn d|SdS(s>Calls self._cleanup() and reports the result as text. R(s)No damage detected in BTreeFolder2 at %s.s8Fixed BTreeFolder2 at %s. See the log for more details.N(Rt_cleanuptvR,R-R.(RR.R3((RR1s   cCsdkl}di|i}y||ixD|iiD]3}|ii |pt dt |qBqBW||i x|i i D]\}}|i i | p|i ||j ot dt |n||x>|iD]0}|i |pt dt |qqWqWdSWnt j otid|dtiyXt|i|_t}x-|i i D]\}}t|||sR`cCs |iS(s*Returns the number of items in the folder.N(RR(R((RR`FsR9cCs|ii|S(s8Indicates whether the folder has an item by ID. N(RRR9R(RR((RR9LsR!cCs|i}|djo|i}nt|to |g}nd}x@|D]8}|i |d}|dj ot ||}qPqPW|djofSn |iSdS(N( RRRNtspecR R7t isinstancet StringTypeR0RJRIRPtunion(RRrR0RJRPRN((RR!Ts     t objectValuescCst|i|i|S(N(tLazyMapRR R!Rr(RRr((RRvlst objectItemscCst|id|i|S(NcCs|||fS(N(RR (RR ((Rtys(RwRR R!Rr(RRr((RRxust objectMapcCs"td|ii|iS(NcCs.|\}}hd|<dt|ddRtmanage_addBTreeFolderFormR RRgRlRmRGRt ExceptionRRtInitializeClassR()R>RRRRRRRjRRtRRRuRRRRRR%RRRGRVRRRR@RRRwRRRRRRRmRBRgRlR((Rt?sP