; lh>c@sLdZdkZdkZdkZdkZdklZdklZdk l Z dk l Z dk Z dk Z dkZdklZlZlZdklZlZdklZd klZd Zd Zd Zd ZdddZedeZddeedZ dddZ!dee efdYZ"ei#e"dS(s, $RCSfile: CacheManager.py,v $ ZopeXMLMethods provides filters to apply to Zope objects for XML/XSLT processing. XSLTMethod associates XSLT transformers with XML documents. ZopeXMLMethods includes XML Method Cache Manager that is specialized to notice changes to the XML source files and to store cached contents in files in the filesystem, rather than the Zope object database. Author: Craeg Strong Modified by Philipp von Weitershausen $Id: CacheManager.py,v 1.22 2003/03/30 03:45:47 cstrong Exp $ N(s SimpleItem(s CatalogAware(sPropertyManager(s ICacheManager(s Acquisitions MessageDialogsHTML(saq_chains aq_parent(sClassSecurityInfo(sPageTemplateFilesEditsManage XML Method Caches ZopeXMLCachecCs7d}tidjo d}ntii|tSdS(Ns/tmpswin32sc:\tmp(sspoolDirectoryssyssplatformsosspathsjoins cachePrefix(sspoolDirectory((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysdefaultCachePrefix0s scCs&|idi|||||SdS(s This is a convenience factory method for creating an instance of CacheManager. It returns the object created, and may therefore be more convenient than the addCacheManager() method it calls. It is used by the unit testing programs. sZopeXMLMethodsN(sfoldersmanage_addProductsaddXMLMethodCacheManagersidstitles description(sfoldersidstitles description((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pys addInstance:sswww/create_cachemgr.ptcCsy.|i||||i|idWnJtj o>}t |}t i ddtddd|ddSnXd S( s Add an XML Method Cache Manager to a folder. Called from the create_cachemgr.dtml GUI form in the Zope Management interface. It calls addXMLMethodCacheManager to actually do the work. s /manage_mains s
stitlesErrorsmessagesactions manage_mainN(sselfsaddXMLMethodCacheManagersidstitles descriptionsRESPONSEsredirects absolute_urls Exceptionsesstrsmessagesmesagesreplaces MessageDialog(sselfsidstitles descriptionsREQUESTsRESPONSEsesmessage((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_addXMLMethodCacheManagerKs  cCs8| otdn|i|t|||dS(s Add an XML Method Cache Manager to a folder. You should call this method directly if you are creating an instance of CacheManager programmatically. s!Required fields must not be blankN(sids Exceptionsselfs _setObjects CacheManagerstitles description(sselfsidstitles description((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysaddXMLMethodCacheManager^ss CacheManagercBsatZdZdZeZhdd<dd<ddsbatchOperationOutputN(sselfsbatchSetCachingOnsREQUESTsmessagesreplacesmanage_cacheForm(sselfsREQUESTsmessage((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_setCachingOnssmanage_setCachingOffcCs3|i|}|idd|id|SdS(sJ ZMI method: turn caching off for all XML Method objects. s s
sbatchOperationOutputN(sselfsbatchSetCachingOffsREQUESTsmessagesreplacesmanage_cacheForm(sselfsREQUESTsmessage((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_setCachingOffssmanage_clearCachecCs0|i}|idd|id|SdS(s) ZMI method: clear cache s s
sbatchOperationOutputN(sselfs clearCachesmessagesreplacesmanage_cacheForm(sselfsmessage((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_clearCaches smanage_listCacheFilescCsfd}|i}|o#x&|D]}||d}q Wnd}|idd|id|SdS(s. ZMI method: list cache files sCache Files: s sNo files in caches
sbatchOperationOutputN(smessagesselfslistCacheFilesslistsfilesreplacesmanage_cacheForm(sselfslistsmessagesfile((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_listCacheFiless smanage_editPropertiescCsxs|iD]e}|d}|djoH|i|d}|i| o!tddd|ddd Sqrq q Wt i d ||Sd S( s Cover for PropertyManager.manage_editProperties() method. First validate cachePrefix, then pass it on to the inherited method for further processing sids cachePrefixsstitlesERRORsmessages is not a valid Cache Prefixsactionsmanage_propertiesFormsmanage_editPropertiesN( sselfs _propertyMapspropsnamesREQUESTsgetsvaluesisValidCachePrefixs MessageDialogs CacheManagersinheritedAttribute(sselfsREQUESTsnamesvaluesprop((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysmanage_editPropertiess     sbatchSetCachingOncCsA|i}d|id}||i|d|}|SdS(s Turns caching on for all instances of all types of XML Methods within the scope of this cache manager. s6Turning Caching On for all XML filter instances under s Folder: s setCachingOnN(sselfsgetParentFoldersparentsgetIdsmessages batchExecutesREQUEST(sselfsREQUESTsmessagesparent((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysbatchSetCachingOns  sbatchSetCachingOffcCsA|i}d|id}||i|d|}|SdS(s Turns caching off for all instances of all types of XML Methods within the scope of this cache manager. s7Turning Caching Off for all XML filter instances under s Folder: s setCachingOffN(sselfsgetParentFoldersparentsgetIdsmessages batchExecutesREQUEST(sselfsREQUESTsmessagesparent((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysbatchSetCachingOffs  scacheFileTimeStampcCsD|i|}d}tii|otii|SndSdS(s Return the last modified time of the cache file for the passed in filter client object, or 0 if the cache file does not exist iN( sselfs cacheFileNamesurlsfileNames cachetimesosspathsexistssgetmtime(sselfsurls cachetimesfileName((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pyscacheFileTimeStamps svalueFromCachecCs<|i|}t|d}|i}|i|SdS(s Retrieve the output from the cache for the passed in filter client object, or None if the cache file does not exist. srbN( sselfs cacheFileNamesurlsfileNamesopenscachesreadsresultsclose(sselfsurlscachesfileNamesresult((sJ/mnt/gmirror/ports/www/zope-xmlmethods/work/ZopeXMLMethods/CacheManager.pysvalueFromCaches   s saveToCachecCsO|i|}t|d}|i||i||i |