コード例 #1
0
def addCacheForResourceRegistry(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    ram_cache_id = 'ResourceRegistryCache'
    if not ram_cache_id in portal.objectIds():
        RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
        cache = getattr(portal, ram_cache_id)
        settings = cache.getSettings()
        settings['max_age'] = 24 * 3600  # keep for up to 24 hours
        settings['request_vars'] = ('URL', )
        cache.manage_editProps('Cache for saved ResourceRegistry files',
                               settings)
        logger.info('Created RAMCache %s for ResourceRegistry output' %
                    ram_cache_id)
    reg = getToolByName(portal, 'portal_css', None)
    if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId',
                                   None) is not None:
        reg.ZCacheable_setManagerId(ram_cache_id)
        reg.ZCacheable_setEnabled(1)
        logger.info('Associated portal_css with %s' % ram_cache_id)
    reg = getToolByName(portal, 'portal_javascripts', None)
    if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId',
                                   None) is not None:
        reg.ZCacheable_setManagerId(ram_cache_id)
        reg.ZCacheable_setEnabled(1)
        logger.info('Associated portal_javascripts with %s' % ram_cache_id)
コード例 #2
0
def install_RSSCache(portal, out):
    if 'RSSCache' not in portal.objectIds():
        RAMCacheManager.manage_addRAMCacheManager(portal, 'RSSCache')

    portal.RSSCache.manage_editProps('RSSCache for getRSSResult', \
             settings={ 'threshold':1000,
                        'request_vars':['itemCount', 'rssUrl'],
                        'cleanup_interval':300,
                        'max_age':3600})
    out.write( "added and initalized RAMCache" )
コード例 #3
0
ファイル: test_FSDTMLMethod.py プロジェクト: wpjunior/proled
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        cache_id = "gofast"
        RAMCacheManager.manage_addRAMCacheManager(self.root, cache_id, REQUEST=None)
        self.fsDTML.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(self.fsDTML.ZCacheable_getManagerId(), cache_id)

        self.fsDTML.manage_doCustomize(folder_path="custom")
        custom_pt = self.custom.testDTML

        self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
コード例 #4
0
def setupRAMCache(portal, logger, ram_cache_id, title, age, reqvars, threshold):
    if not ram_cache_id in portal.objectIds():
        RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
        cache = getattr(portal, ram_cache_id)
        settings = cache.getSettings()
        settings['max_age'] = age
        settings['request_vars'] = reqvars
        settings['threshold'] = threshold
        cache.manage_editProps(title, settings)
        logger.info(' - created RAMCache %s' % ram_cache_id)
    else:
        logger.info(' - already exists RAMCache "%s"' % ram_cache_id)
コード例 #5
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        cache_id = 'gofast'
        RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
                                                  REQUEST=None)
        self.fsDTML.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(self.fsDTML.ZCacheable_getManagerId(), cache_id)

        self.fsDTML.manage_doCustomize(folder_path='custom')
        custom_pt = self.custom.testDTML

        self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
コード例 #6
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        cache_id = 'gofast'
        RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
                                                  REQUEST=None)
        self.fsPT.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(self.fsPT.ZCacheable_getManagerId(), cache_id)

        self.fsPT.manage_doCustomize(folder_path='custom')
        custom_pt = self.custom.testPT

        self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
コード例 #7
0
def setupRAMCache(portal, logger, ram_cache_id, title, age, reqvars,
                  threshold):
    if not ram_cache_id in portal.objectIds():
        RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
        cache = getattr(portal, ram_cache_id)
        settings = cache.getSettings()
        settings['max_age'] = age
        settings['request_vars'] = reqvars
        settings['threshold'] = threshold
        cache.manage_editProps(title, settings)
        logger.info(' - created RAMCache %s' % ram_cache_id)
    else:
        logger.info(' - already exists RAMCache "%s"' % ram_cache_id)
コード例 #8
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        root, tool, custom, fsdir, fsPS = self._makeSkins()

        cache_id = "gofast"
        RAMCacheManager.manage_addRAMCacheManager(root, cache_id, REQUEST=None)
        fsPS.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(fsPS.ZCacheable_getManagerId(), cache_id)

        fsPS.manage_doCustomize(folder_path="custom")
        custom_ps = custom.test6

        self.assertEqual(custom_ps.ZCacheable_getManagerId(), cache_id)
コード例 #9
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        root, tool, custom, fsdir, fsPS = self._makeSkins()

        cache_id = 'gofast'
        RAMCacheManager.manage_addRAMCacheManager(root, cache_id, REQUEST=None)
        fsPS.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(fsPS.ZCacheable_getManagerId(), cache_id)

        fsPS.manage_doCustomize(folder_path='custom')
        custom_ps = custom.test6

        self.assertEqual(custom_ps.ZCacheable_getManagerId(), cache_id)
コード例 #10
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        from Products.StandardCacheManagers import RAMCacheManager
        cache_id = 'gofast'
        self.custom.all_meta_types = ZPT_META_TYPES
        RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
                                                  REQUEST=None)
        self.fsReST.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(self.fsReST.ZCacheable_getManagerId(), cache_id)

        self.fsReST.manage_doCustomize(folder_path='custom')
        custom_pt = self.custom.testReST

        self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
コード例 #11
0
    def test_customize_caching(self):
        # Test to ensure that cache manager associations survive customizing
        _stool, custom, _fsdir, fsPS = self._makeContext('test6', 'test6.py')

        cache_id = 'gofast'
        RAMCacheManager.manage_addRAMCacheManager(self.app, cache_id,
                                                  REQUEST=None)
        fsPS.ZCacheable_setManagerId(cache_id, REQUEST=None)

        self.assertEqual(fsPS.ZCacheable_getManagerId(), cache_id)

        fsPS.manage_doCustomize(folder_path='custom')
        custom_ps = custom.test6

        self.assertEqual(custom_ps.ZCacheable_getManagerId(), cache_id)
コード例 #12
0
ファイル: alphas.py プロジェクト: gbastien/plone.app.upgrade
def addCacheForResourceRegistry(context):
    portal = getToolByName(context, 'portal_url').getPortalObject()
    ram_cache_id = 'ResourceRegistryCache'
    if not ram_cache_id in portal.objectIds():
        RAMCacheManager.manage_addRAMCacheManager(portal, ram_cache_id)
        cache = getattr(portal, ram_cache_id)
        settings = cache.getSettings()
        settings['max_age'] = 24*3600 # keep for up to 24 hours
        settings['request_vars'] = ('URL',)
        cache.manage_editProps('Cache for saved ResourceRegistry files', settings)
        logger.info('Created RAMCache %s for ResourceRegistry output' % ram_cache_id)
    reg = getToolByName(portal, 'portal_css', None)
    if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
        reg.ZCacheable_setManagerId(ram_cache_id)
        reg.ZCacheable_setEnabled(1)
        logger.info('Associated portal_css with %s' % ram_cache_id)
    reg = getToolByName(portal, 'portal_javascripts', None)
    if reg is not None and getattr(aq_base(reg), 'ZCacheable_setManagerId', None) is not None:
        reg.ZCacheable_setManagerId(ram_cache_id)
        reg.ZCacheable_setEnabled(1)
        logger.info('Associated portal_javascripts with %s' % ram_cache_id)