Esempio n. 1
0
    def setUp(self):
        TestCase.setUp(self)
        self.memcache = InMemoryMemcacheProtocol()
        self.ccn = MemcacheChangeNotifier(StubURLResource(':memory:'),
                                          cachePool=self.memcache)

        self.ccn._newCacheToken = instancemethod(_newCacheToken, self.ccn,
                                                 MemcacheChangeNotifier)
Esempio n. 2
0
    def doWork(self):
        """
        Calls the function that's been assigned to "function" and passes the root
        resource, directory, store, and whatever has been assigned to "params".
        """
        if (config.EnableResponseCache
                and config.Memcached.Pools.Default.ClientEnabled):
            # These class attributes need to be setup with our memcache\
            # notifier
            CachingDelegates.cacheNotifier = MemcacheChangeNotifier(
                None, cacheHandle="PrincipalToken")

        if self.function is not None:
            yield self.function(self.store, *self.params)
Esempio n. 3
0
    def __init__(self, path, *args, **kwargs):
        super(RootResource, self).__init__(path, *args, **kwargs)

        if config.EnableSACLs:
            self.useSacls = True

        self.contentFilters = []

        if (
            config.EnableResponseCache and
            config.Memcached.Pools.Default.ClientEnabled
        ):
            self.responseCache = MemcacheResponseCache(self.fp)

            # These class attributes need to be setup with our memcache\
            # notifier
            DirectoryPrincipalResource.cacheNotifierFactory = MemcacheChangeNotifier
            CachingDelegates.cacheNotifier = MemcacheChangeNotifier(None, cacheHandle="PrincipalToken")
        else:
            self.responseCache = DisabledCache()

        if config.ResponseCompression:
            from txweb2.filter import gzip
            self.contentFilters.append((gzip.gzipfilter, True))