コード例 #1
0
    def test_passed_registry(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True

        self.assertEqual(False, utils.isCachePurgingEnabled())
        self.assertEqual(True, utils.isCachePurgingEnabled(registry))
コード例 #2
0
    def test_passed_registry(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True

        self.assertEqual(False, utils.isCachePurgingEnabled())
        self.assertEqual(True, utils.isCachePurgingEnabled(registry))
コード例 #3
0
ファイル: test_utils.py プロジェクト: CGTIC/Plone_SP
    def test_passed_registry(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True
        settings.cachingProxies = ('http://localhost:1234',)

        self.assertEqual(False, utils.isCachePurgingEnabled())
        self.assertEqual(True, utils.isCachePurgingEnabled(registry))
コード例 #4
0
    def test_passed_registry(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True
        settings.cachingProxies = ('http://localhost:1234', )

        self.assertEqual(False, utils.isCachePurgingEnabled())
        self.assertEqual(True, utils.isCachePurgingEnabled(registry))
コード例 #5
0
ファイル: test_utils.py プロジェクト: CGTIC/Plone_SP
    def test_no_proxies(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        provideUtility(registry, IRegistry)

        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = False

        settings.cachingProxies = None
        self.assertEqual(False, utils.isCachePurgingEnabled())

        settings.cachingProxies = ()
        self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #6
0
    def test_no_proxies(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        provideUtility(registry, IRegistry)

        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = False

        settings.cachingProxies = None
        self.assertEqual(False, utils.isCachePurgingEnabled())

        settings.cachingProxies = ()
        self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #7
0
def purge(event):
    """Asynchronously send PURGE requests
    """

    request = event.request

    annotations = IAnnotations(request, None)
    if annotations is None:
        return

    paths = annotations.get(KEY, None)
    if paths is None:
        return

    registry = queryUtility(IRegistry)
    if registry is None:
        return

    if not isCachePurgingEnabled(registry=registry):
        return

    purger = queryUtility(IPurger)
    if purger is None:
        return

    settings = registry.forInterface(ICachePurgingSettings, check=False)
    for path in paths:
        for url in getURLsToPurge(path, settings.cachingProxies):
            purger.purgeAsync(url)
コード例 #8
0
ファイル: browser.py プロジェクト: dokai/plone.cachepurging
 def __call__(self):
     
     if not isCachePurgingEnabled():
         return 'Caching not enabled'
     
     notify(Purge(self.context))
     return 'Queued'
コード例 #9
0
    def __call__(self):

        if not isCachePurgingEnabled():
            return "Caching not enabled"

        notify(Purge(self.context))
        return "Queued"
コード例 #10
0
ファイル: hooks.py プロジェクト: dokai/plone.cachepurging
def purge(event):
    """Asynchronously send PURGE requests
    """
    
    request = event.request
    
    annotations = IAnnotations(request, None)
    if annotations is None:
        return
    
    paths = annotations.get(KEY, None)
    if paths is None:
        return
    
    registry = queryUtility(IRegistry)
    if registry is None:
        return
    
    if not isCachePurgingEnabled(registry=registry):
        return
    
    purger = queryUtility(IPurger)
    if purger is None:
        return
    
    settings = registry.forInterface(ICachePurgingSettings, check=False)
    for path in paths:
        for url in getURLsToPurge(path, settings.cachingProxies):
            purger.purgeAsync(url)
コード例 #11
0
    def test_enabled(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        provideUtility(registry, IRegistry)

        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True
        self.assertEqual(True, utils.isCachePurgingEnabled())
コード例 #12
0
    def test_enabled(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        provideUtility(registry, IRegistry)

        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = True
        self.assertEqual(True, utils.isCachePurgingEnabled())
コード例 #13
0
 def test_enabled(self):
     registry = Registry()
     registry.registerInterface(ICachePurgingSettings)
     provideUtility(registry, IRegistry)
     
     settings = registry.forInterface(ICachePurgingSettings)
     settings.enabled = True
     settings.cachingProxies = ('http://localhost:1234',)
     self.assertEquals(True, utils.isCachePurgingEnabled())
コード例 #14
0
    def test_disabled(self):
        registry = Registry()
        registry.registerInterface(ICachePurgingSettings)
        provideUtility(registry, IRegistry)

        settings = registry.forInterface(ICachePurgingSettings)
        settings.enabled = False
        settings.cachingProxies = ('http://localhost:1234', )

        self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #15
0
def queuePurge(event):
    """Find URLs to purge and queue them for later
    """

    request = getRequest()
    if request is None:
        return

    annotations = IAnnotations(request, None)
    if annotations is None:
        return

    if not isCachePurgingEnabled():
        return

    paths = annotations.setdefault(KEY, set())
    paths.update(getPathsToPurge(event.object, request))
コード例 #16
0
ファイル: hooks.py プロジェクト: dokai/plone.cachepurging
def queuePurge(event):
    """Find URLs to purge and queue them for later
    """
    
    request = getRequest()
    if request is None:
        return
    
    annotations = IAnnotations(request, None)
    if annotations is None:
        return
    
    if not isCachePurgingEnabled():
        return
    
    paths = annotations.setdefault(KEY, set())
    paths.update(getPathsToPurge(event.object, request))
コード例 #17
0
    def __call__(self):
        if not isCachePurgingEnabled():
            return "Caching not enabled"

        registry = getUtility(IRegistry)
        settings = registry.forInterface(ICachePurgingSettings)
        purger = getUtility(IPurger)
        out = StringIO()

        for path in getPathsToPurge(self.context, self.request):
            for url in getURLsToPurge(path, settings.cachingProxies):
                status, xcache, xerror = purger.purgeSync(url)
                out.write(
                    RESULT_TPL.format(url=url,
                                      status=status,
                                      xcache=xcache,
                                      xerror=xerror))
        return out.getvalue()
コード例 #18
0
ファイル: browser.py プロジェクト: dokai/plone.cachepurging
 def __call__(self):
     
     if not isCachePurgingEnabled():
         return 'Caching not enabled'
     
     registry = getUtility(IRegistry)
     settings = registry.forInterface(ICachePurgingSettings)
     
     purger = getUtility(IPurger)
     
     out = StringIO()
     
     for path in getPathsToPurge(self.context, self.request):
         for url in getURLsToPurge(path, settings.cachingProxies):
             status, xcache, xerror = purger.purgeSync(url)
             print >>out, "Purged", url, "Status", status, "X-Cache", xcache, "Error:", xerror
     
     return out.getvalue()
コード例 #19
0
ファイル: browser.py プロジェクト: nilbacardit26/plone_prova
    def __call__(self):

        if not isCachePurgingEnabled():
            return 'Caching not enabled'

        registry = getUtility(IRegistry)
        settings = registry.forInterface(ICachePurgingSettings)

        purger = getUtility(IPurger)

        out = StringIO()

        for path in getPathsToPurge(self.context, self.request):
            for url in getURLsToPurge(path, settings.cachingProxies):
                status, xcache, xerror = purger.purgeSync(url)
                print >> out, "Purged", url, "Status", status, "X-Cache", xcache, "Error:", xerror

        return out.getvalue()
コード例 #20
0
ファイル: browser.py プロジェクト: plone/plone.cachepurging
    def __call__(self):
        if not isCachePurgingEnabled():
            return "Caching not enabled"

        registry = getUtility(IRegistry)
        settings = registry.forInterface(ICachePurgingSettings)
        purger = getUtility(IPurger)
        out = StringIO()

        for path in getPathsToPurge(self.context, self.request):
            for url in getURLsToPurge(path, settings.cachingProxies):
                status, xcache, xerror = purger.purgeSync(url)
                out.write(
                    RESULT_TPL.format(
                        url=url, status=status, xcache=xcache, xerror=xerror
                    )
                )
        return out.getvalue()
コード例 #21
0
ファイル: utils.py プロジェクト: oikoumene/wcc.caching
def syncPurge(obj):
    request = getRequest()

    paths = getPathsToPurge(obj, request)

    registry = queryUtility(IRegistry)
    if registry is None:
        return

    if not isCachePurgingEnabled(registry=registry):
        return

    purger = queryUtility(IPurger)
    if purger is None:
        return

    settings = registry.forInterface(ICachePurgingSettings, check=False)
    purged_urls = []
    for path in paths:
        for url in getURLsToPurge(path, settings.cachingProxies):
            purger.purgeSync(url)
            purged_urls.append(url)

    return purged_urls
コード例 #22
0
ファイル: controlpanel.py プロジェクト: Vinsurya/Plone
 def purgingEnabled(self):
     return isCachePurgingEnabled()
コード例 #23
0
ファイル: test_utils.py プロジェクト: CGTIC/Plone_SP
 def test_no_settings(self):
     registry = Registry()
     registry.registerInterface(ICachePurgingSettings)
     provideUtility(registry, IRegistry)
     self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #24
0
 def test_no_registry(self):
     self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #25
0
 def purgingEnabled(self):
     return isCachePurgingEnabled()
コード例 #26
0
 def test_no_registry(self):
     self.assertEqual(False, utils.isCachePurgingEnabled())
コード例 #27
0
 def test_no_settings(self):
     registry = Registry()
     registry.registerInterface(ICachePurgingSettings)
     provideUtility(registry, IRegistry)
     self.assertEqual(False, utils.isCachePurgingEnabled())