plone / plone.app.event

Event content type for Plone
https://pypi.python.org/pypi/plone.app.event
Other
17 stars 37 forks source link

implement purge support for event occurrences #317

Open frisi opened 4 years ago

frisi commented 4 years ago

just added this adapter to my package. should we add the same to plone.app.event?

from z3c.caching.interfaces import IPurgePaths

class EventOccurrencesPurgePaths(object):
    """purges urls for event occurrences
    """
    implements(IPurgePaths)
    adapts(IMyEvent)

    def __init__(self, context):
        self.context = context

    def getRelativePaths(self):
        prefix = self.context.absolute_url_path()
        result = []
        for occ in IRecurrenceSupport(self.context).occurrences():
            if occ.portal_type == 'Occurrence':
                result.append(prefix + '/' + occ.id)
        return result

    def getAbsolutePaths(self):
        return []

side note: first i tried to purge with a regex/glob character (eg <event-id>[\d-]*). but looks like this is what BANs are for in varnish (https://varnish-cache.org/docs/4.1/users-guide/purging.html). however, it looks like plone.cachepurging only issues PURGE requests only by default so the exact urls are needed.