def _initSite(self, with_policy=False): from Products.CMFCore.CachingPolicyManager import CachingPolicyManager self.root.site = Folder(id='site') site = self.root.site mgr = CachingPolicyManager() site._setObject( mgr.getId(), mgr ) if with_policy: mgr.addPolicy( policy_id=self.POLICY_ID , predicate=self.PREDICATE , mtime_func=self.MTIME_FUNC , max_age_secs=self.MAX_AGE_SECS , no_cache=True , no_store=True , must_revalidate=True , vary=self.VARY , etag_func=self.ETAG_FUNC , s_max_age_secs=self.S_MAX_AGE_SECS , proxy_revalidate=True , public=True , private=True , no_transform=True , enable_304s=True , last_modified=False , pre_check=self.PRE_CHECK , post_check=self.POST_CHECK ) return site
def _initSite(self, with_policy=False): from Products.CMFCore.CachingPolicyManager import CachingPolicyManager self.root.site = Folder(id='site') site = self.root.site mgr = CachingPolicyManager() site._setObject(mgr.getId(), mgr) if with_policy: mgr.addPolicy(policy_id=self.POLICY_ID, predicate=self.PREDICATE, mtime_func=self.MTIME_FUNC, max_age_secs=self.MAX_AGE_SECS, no_cache=True, no_store=True, must_revalidate=True, vary=self.VARY, etag_func=self.ETAG_FUNC, s_max_age_secs=self.S_MAX_AGE_SECS, proxy_revalidate=True, public=True, private=True, no_transform=True, enable_304s=True, last_modified=False, pre_check=self.PRE_CHECK, post_check=self.POST_CHECK) return site
def _initSite(self, with_policy=False): site = Folder(id='site').__of__(self.app) cpm = CachingPolicyManager() getSiteManager().registerUtility(cpm, ICachingPolicyManager) if with_policy: cpm.addPolicy(policy_id=self.POLICY_ID, predicate=self.PREDICATE, mtime_func=self.MTIME_FUNC, max_age_secs=self.MAX_AGE_SECS, no_cache=True, no_store=True, must_revalidate=True, vary=self.VARY, etag_func=self.ETAG_FUNC, s_max_age_secs=self.S_MAX_AGE_SECS, proxy_revalidate=True, public=True, private=True, no_transform=True, enable_304s=True, last_modified=False, pre_check=self.PRE_CHECK, post_check=self.POST_CHECK) return site, cpm
def _initSite(self, with_policy=False): site = Folder(id='site').__of__(self.app) cpm = CachingPolicyManager() getSiteManager().registerUtility(cpm, ICachingPolicyManager) if with_policy: cpm.addPolicy(policy_id=self.POLICY_ID , predicate=self.PREDICATE , mtime_func=self.MTIME_FUNC , max_age_secs=self.MAX_AGE_SECS , no_cache=True , no_store=True , must_revalidate=True , vary=self.VARY , etag_func=self.ETAG_FUNC , s_max_age_secs=self.S_MAX_AGE_SECS , proxy_revalidate=True , public=True , private=True , no_transform=True , enable_304s=True , last_modified=False , pre_check=self.PRE_CHECK , post_check=self.POST_CHECK ) return site, cpm
def setUp(self): import Products.CMFCore.exportimport from Products.CMFCore.CachingPolicyManager import CachingPolicyManager BodyAdapterTestCase.setUp(self) zcml.load_config('configure.zcml', Products.CMFCore.exportimport) self._obj = CachingPolicyManager() self._BODY = _CPM_BODY
def setUp(self): from Products.CMFCore.CachingPolicyManager import CachingPolicyManager self._obj = CachingPolicyManager() self._BODY = _CPM_BODY
def _makeOne(self): from Products.CMFCore.CachingPolicyManager import CachingPolicyManager return CachingPolicyManager()
def setUp(self): from Products.CMFCore import CachingPolicyManager RequestTest.setUp(self) FSDVTest.setUp(self) setUpTraversing() zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.CMFCore) now = DateTime() # Create a fake portal and the tools we need self.portal = DummySite(id='portal').__of__(self.root) self.portal._setObject('portal_types', DummyTool()) # This is a FSPageTemplate that will be used as the View for # our content objects. It doesn't matter what it returns. path = os.path.join(self.skin_path_name, 'testPT2.pt') self.portal._setObject('dummy_view', FSPageTemplate('dummy_view', path)) uf = self.root.acl_users password = '******' uf.userFolderAddUser(portal_owner, password, ['Manager'], []) user = uf.getUserById(portal_owner) if not hasattr(user, 'aq_base'): user = user.__of__(uf) newSecurityManager(None, user) owner_auth = '%s:%s' % (portal_owner, password) self.auth_header = "Basic %s" % base64.encodestring(owner_auth) self.portal._setObject('doc1', DummyContent('doc1')) self.portal._setObject('doc2', DummyContent('doc2')) self.portal._setObject('doc3', DummyContent('doc3')) self.portal.doc1.modified_date = now self.portal.doc2.modified_date = now self.portal.doc3.modified_date = now CachingPolicyManager.manage_addCachingPolicyManager(self.portal) cpm = self.portal.caching_policy_manager # This policy only applies to doc1. It will not emit any ETag header # but it enables If-modified-since handling. cpm.addPolicy(policy_id = 'policy_no_etag', predicate = 'python:object.getId()=="doc1"', mtime_func = '', max_age_secs = 0, no_cache = 0, no_store = 0, must_revalidate = 0, vary = '', etag_func = '', enable_304s = 1) # This policy only applies to doc2. It will emit an ETag with # the constant value "abc" and also enable if-modified-since handling. cpm.addPolicy(policy_id = 'policy_etag', predicate = 'python:object.getId()=="doc2"', mtime_func = '', max_age_secs = 0, no_cache = 0, no_store = 0, must_revalidate = 0, vary = '', etag_func = 'string:abc', enable_304s = 1) # This policy only applies to doc3. Etags with constant values of # "abc" are emitted, but if-modified-since handling is turned off. cpm.addPolicy(policy_id = 'policy_disabled', predicate = 'python:object.getId()=="doc3"', mtime_func = '', max_age_secs = 0, no_cache = 0, no_store = 0, must_revalidate = 0, vary = '', etag_func = 'string:abc', enable_304s = 0)
def setUp(self): from Products.CMFCore import CachingPolicyManager PlacelessSetup.setUp(self) RequestTest.setUp(self) FSDVTest.setUp(self) zcml.load_config('meta.zcml', Products.Five) zcml.load_config('permissions.zcml', Products.Five) zcml.load_config('configure.zcml', Products.CMFCore) zcml.load_string(_TRAVERSE_ZCML) now = DateTime() # Create a fake portal and the tools we need self.portal = DummySite(id='portal').__of__(self.root) self.portal._setObject('portal_types', DummyTool()) # This is a FSPageTemplate that will be used as the View for # our content objects. It doesn't matter what it returns. path = os.path.join(self.skin_path_name, 'testPT2.pt') self.portal._setObject('dummy_view', FSPageTemplate('dummy_view', path)) uf = self.root.acl_users password = '******' uf.userFolderAddUser(portal_owner, password, ['Manager'], []) user = uf.getUserById(portal_owner) if not hasattr(user, 'aq_base'): user = user.__of__(uf) newSecurityManager(None, user) owner_auth = '%s:%s' % (portal_owner, password) self.auth_header = "Basic %s" % base64.encodestring(owner_auth) self.portal._setObject('doc1', DummyContent('doc1')) self.portal._setObject('doc2', DummyContent('doc2')) self.portal._setObject('doc3', DummyContent('doc3')) self.portal.doc1.modified_date = now self.portal.doc2.modified_date = now self.portal.doc3.modified_date = now CachingPolicyManager.manage_addCachingPolicyManager(self.portal) cpm = self.portal.caching_policy_manager # This policy only applies to doc1. It will not emit any ETag header # but it enables If-modified-since handling. cpm.addPolicy(policy_id='policy_no_etag', predicate='python:object.getId()=="doc1"', mtime_func='', max_age_secs=0, no_cache=0, no_store=0, must_revalidate=0, vary='', etag_func='', enable_304s=1) # This policy only applies to doc2. It will emit an ETag with # the constant value "abc" and also enable if-modified-since handling. cpm.addPolicy(policy_id='policy_etag', predicate='python:object.getId()=="doc2"', mtime_func='', max_age_secs=0, no_cache=0, no_store=0, must_revalidate=0, vary='', etag_func='string:abc', enable_304s=1) # This policy only applies to doc3. Etags with constant values of # "abc" are emitted, but if-modified-since handling is turned off. cpm.addPolicy(policy_id='policy_disabled', predicate='python:object.getId()=="doc3"', mtime_func='', max_age_secs=0, no_cache=0, no_store=0, must_revalidate=0, vary='', etag_func='string:abc', enable_304s=0)
def setUp(self): from Products.CMFCore.CachingPolicyManager import CachingPolicyManager BodyAdapterTestCase.setUp(self) self._obj = CachingPolicyManager() self._BODY = _CPM_BODY
def setUp(self): self._obj = CachingPolicyManager() self._BODY = _CPM_BODY
def _makeOne(self): return CachingPolicyManager()