Beispiel #1
0
	def jellyFor(self, jellier):
		return reflect.qual(self.__class__), jellier.invoker.registerReference(self)


	def remote_join(self, groupName):
		assert isinstance(groupName, unicode)
		def cbGroup(group):
			def cbJoin(ignored):
				return PBGroup(self.avatar.realm, self.avatar, group)
			d = self.avatar.join(group)
			d.addCallback(cbJoin)
			return d
		d = self.avatar.realm.getGroup(groupName)
		d.addCallback(cbGroup)
		return d
registerAdapter(ChatAvatar, iwords.IUser, pb.IPerspective)

class AvatarReference(pb.RemoteReference):
	def join(self, groupName):
		return self.callRemote('join', groupName)

	def quit(self):
		d = defer.Deferred()
		self.broker.notifyOnDisconnect(lambda: d.callback(None))
		self.broker.transport.loseConnection()
		return d

pb.setUnjellyableForClass(ChatAvatar, AvatarReference)


class WordsRealm(object):
Beispiel #2
0
        myPath = FilePath(self.importer.archive)
        itsPath = FilePath(fsPathString)
        if myPath == itsPath:
            return za
        # This is NOT a general-purpose rule for sys.path or __file__:
        # zipimport specifically uses regular OS path syntax in its pathnames,
        # even though zip files specify that slashes are always the separator,
        # regardless of platform.
        segs = itsPath.segmentsFrom(myPath)
        zp = za
        for seg in segs:
            zp = zp.child(seg)
        return zp


registerAdapter(_ZipMapImpl, zipimport.zipimporter, IPathImportMapper)


def _defaultSysPathFactory():
    """
	Provide the default behavior of PythonPath's sys.path factory, which is to
	return the current value of sys.path.

	@return: L{sys.path}
	"""
    return sys.path


class PythonPath:
    """
	I represent the very top of the Python object-space, the module list in
Beispiel #3
0
		za = ZipArchive(self.importer.archive)
		myPath = FilePath(self.importer.archive)
		itsPath = FilePath(fsPathString)
		if myPath == itsPath:
			return za
		# This is NOT a general-purpose rule for sys.path or __file__:
		# zipimport specifically uses regular OS path syntax in its pathnames,
		# even though zip files specify that slashes are always the separator,
		# regardless of platform.
		segs = itsPath.segmentsFrom(myPath)
		zp = za
		for seg in segs:
			zp = zp.child(seg)
		return zp

registerAdapter(_ZipMapImpl, zipimport.zipimporter, IPathImportMapper)

def _defaultSysPathFactory():
	"""
	Provide the default behavior of PythonPath's sys.path factory, which is to
	return the current value of sys.path.

	@return: L{sys.path}
	"""
	return sys.path


class PythonPath:
	"""
	I represent the very top of the Python object-space, the module list in
	sys.path and the modules list in sys.modules.
Beispiel #4
0
		"""


class ProtocolToConsumerAdapter(components.Adapter):
	implements(interfaces.IConsumer)

	def write(self, data):
		self.original.dataReceived(data)

	def registerProducer(self, producer, streaming):
		pass

	def unregisterProducer(self):
		pass

components.registerAdapter(ProtocolToConsumerAdapter, interfaces.IProtocol,
						   interfaces.IConsumer)

class ConsumerToProtocolAdapter(components.Adapter):
	implements(interfaces.IProtocol)

	def dataReceived(self, data):
		self.original.write(data)

	def connectionLost(self, reason):
		pass

	def makeConnection(self, transport):
		pass

	def connectionMade(self):
		pass