Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: third_party/twisted_8_1/twisted/spread/publish.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/twisted_8_1/twisted/spread/pb.py ('k') | third_party/twisted_8_1/twisted/spread/refpath.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/twisted_8_1/twisted/spread/publish.py
diff --git a/third_party/twisted_8_1/twisted/spread/publish.py b/third_party/twisted_8_1/twisted/spread/publish.py
deleted file mode 100644
index 0f031fdd2fbf2adcbb13351e53b0db273622be67..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/spread/publish.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-
-"""
-Persistently cached objects for PB.
-
-Maintainer: U{Glyph Lefkowitz<mailto:glyph@twistedmatrix.com>}
-
-Future Plans: None known.
-"""
-
-# Twisted imports
-from twisted.internet import defer
-
-# sibling imports
-import jelly
-import banana
-import flavors
-
-# System Imports
-import time
-
-class Publishable(flavors.Cacheable):
- """An object whose cached state persists across sessions.
- """
- def __init__(self, publishedID):
- self.republish()
- self.publishedID = publishedID
-
- def republish(self):
- """Set the timestamp to current and (TODO) update all observers.
- """
- self.timestamp = time.time()
-
- def view_getStateToPublish(self, perspective):
- '(internal)'
- return self.getStateToPublishFor(perspective)
-
- def getStateToPublishFor(self, perspective):
- """Implement me to special-case your state for a perspective.
- """
- return self.getStateToPublish()
-
- def getStateToPublish(self):
- """Implement me to return state to copy as part of the publish phase.
- """
- raise NotImplementedError("%s.getStateToPublishFor" % self.__class__)
-
- def getStateToCacheAndObserveFor(self, perspective, observer):
- """Get all necessary metadata to keep a clientside cache.
- """
- if perspective:
- pname = perspective.perspectiveName
- sname = perspective.getService().serviceName
- else:
- pname = "None"
- sname = "None"
-
- return {"remote": flavors.ViewPoint(perspective, self),
- "publishedID": self.publishedID,
- "perspective": pname,
- "service": sname,
- "timestamp": self.timestamp}
-
-class RemotePublished(flavors.RemoteCache):
- """The local representation of remote Publishable object.
- """
- isActivated = 0
- _wasCleanWhenLoaded = 0
- def getFileName(self, ext='pub'):
- return ("%s-%s-%s.%s" %
- (self.service, self.perspective, str(self.publishedID), ext))
-
- def setCopyableState(self, state):
- self.__dict__.update(state)
- self._activationListeners = []
- try:
- data = open(self.getFileName()).read()
- except IOError:
- recent = 0
- else:
- newself = jelly.unjelly(banana.decode(data))
- recent = (newself.timestamp == self.timestamp)
- if recent:
- self._cbGotUpdate(newself.__dict__)
- self._wasCleanWhenLoaded = 1
- else:
- self.remote.callRemote('getStateToPublish').addCallbacks(self._cbGotUpdate)
-
- def __getstate__(self):
- other = self.__dict__.copy()
- # Remove PB-specific attributes
- del other['broker']
- del other['remote']
- del other['luid']
- # remove my own runtime-tracking stuff
- del other['_activationListeners']
- del other['isActivated']
- return other
-
- def _cbGotUpdate(self, newState):
- self.__dict__.update(newState)
- self.isActivated = 1
- # send out notifications
- for listener in self._activationListeners:
- listener(self)
- self._activationListeners = []
- self.activated()
- open(self.getFileName(), "wb").write(banana.encode(jelly.jelly(self)))
-
- def activated(self):
- """Implement this method if you want to be notified when your
- publishable subclass is activated.
- """
-
- def callWhenActivated(self, callback):
- """Externally register for notification when this publishable has received all relevant data.
- """
- if self.isActivated:
- callback(self)
- else:
- self._activationListeners.append(callback)
-
-def whenReady(d):
- """
- Wrap a deferred returned from a pb method in another deferred that
- expects a RemotePublished as a result. This will allow you to wait until
- the result is really available.
-
- Idiomatic usage would look like::
-
- publish.whenReady(serverObject.getMeAPublishable()).addCallback(lookAtThePublishable)
- """
- d2 = defer.Deferred()
- d.addCallbacks(_pubReady, d2.errback,
- callbackArgs=(d2,))
- return d2
-
-def _pubReady(result, d2):
- '(internal)'
- result.callWhenActivated(d2.callback)
« no previous file with comments | « third_party/twisted_8_1/twisted/spread/pb.py ('k') | third_party/twisted_8_1/twisted/spread/refpath.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698