m &Ec@s1dZdklZlZdklZdkZdkZdkZdk l Z dk l Z dk l Z dklZdkZdkZdklZd klZd klZeid Zd efd YZhZeiddZdeefdYZe ee de Z!ddZ#dS(s Accelerated HTTP cache manager -- Adds caching headers to the response so that downstream caches will cache according to a common policy. $Id$ (sCaches CacheManager(s SimpleItemN(sInitializeClass(sDTMLFile(sClassSecurityInfo(sview_management_screens(sescape(squote(s rfc1123_dates Zope.AcceleratedHTTPCacheManagertAcceleratedHTTPCachecBs>tZeiZdZdZdZdZdZ RS(NcCs h|_dS(N(tselft hit_counts(R((tY/data/zmath/zope/lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.pyt__init__-scCs|ii|dS(N(Rt__dict__tupdatetkw(RR((Rt initSettings0scCs|i}|ii|o|i|=n|itdi|f}|d|djo|d }ng}xs|i D]h} | i pqn| d idjo | }n d| }ti|\}} } }}} | iido| id} nx|D]}| id|}|i| }tid| |fy|i d|Wn8t!i"j o)d d d }ti$|| qnX|i%}d |i'|i(f} |i)| tid | qWqWddi|S(Nt/iiishttp://s/http://sPURGING host %s, path %stPURGEs"socket.gaierror: maybe the server s$at %s is down, or the cache manager sis misconfigured?s%s %sspurge response: %ssServer response(s): t;(*tobtgetPhysicalPatht phys_pathRRthas_keytabsolute_url_pathtquotetjoint purge_pathstresultst notify_urlsturltstriptlowertuturlparsetschemethosttpathtparamstquerytfragmentt startswithtlstriptob_pathtrstriptptconnection_factorythtloggertdebugtrequesttsockettgaierrortmsgterrort getresponsetrtstatustreasontappend(RR RRR#RRR-RR1R RRRR'RR%R0R((RtZCache_invalidate5sB !    !  cCs|S(N(tdefault(RR t view_nametkeywordst mtime_funcR5((Rt ZCache_getmscCsK|i} | i} d}| idd} | dj o!| idjo d}qXn|i} |i i | o|i | } nddg|i | <} |o| dd| dRHR<RBRRR=((Rt ZCache_setps*     ( t__name__t __module__thttplibtHTTPConnectionR&RRR4R9RK(((RR&s     8 t.itAcceleratedHTTPCacheManagercBshtZdZeZeiddhdd<dd<dedft sort_reverseiN(RR<treqR?RoRmRp(RRpRqRo((Rt _getSortInfos  tgetCacheReportcCs|i\}}|i}g}xT|iiD]C\}\}}|i hddi |<d|<d|<q4W|o,|i|d|o|iqn|S(so Returns the list of objects in the cache, sorted according to the user's preferences. RR R>tauthcCst||||S(N(tcmpte1Rote2(RvRwRo((RtsN(RRrRoRpRbtctrvalRtitemsRR>RtR3Rtsorttreverse(RRyRzRtRoR>RpR((RRss 5t sort_linkcCs}|i\}}|id|}d}||jo | }n|d|odpd}dt|dt|fS( s5 Utility for generating a sort link. s/manage_stats?sort_by=is&sort_reverse=t1t0s%siN( RRrRoRpt absolute_urlR]Rtnewsrtescapetname(RRR]RRRoRp((RR~s  (RS(RLRMt__doc__tClassSecurityInfotsecuritytsetPermissionDefaultt PRODUCT_DIRt CacheManagertmanage_optionst SimpleItemt meta_typeRRatdeclarePrivateRbtdeclareProtectedtview_management_screensRgtDTMLFiletglobalsRWR@RiRZRrRsR~(((RRQs,  \       s dtml/addAccelcCs;|i|t||dj o|i||SndS(RRN(Rt _setObjectR]RQR<R@RW(RR]R<((Rt%manage_addAcceleratedHTTPCacheManagers ($Rt OFS.CachetCacheRtOFS.SimpleItemRtloggingR+RGtGlobalstInitializeClassRt AccessControlRtAccessControl.PermissionsRRRNtcgiRturllibRt App.CommonRFt getLoggerR(RRdRLtsplitRRQRt)manage_addAcceleratedHTTPCacheManagerFormR@R(RRRRFRRRGRQR(RRRRRRRRNRR+RRRd((Rt?s,           jn