[Zope-dev] RE: Component Architecture / A modest proposal: Replace medusa with Twisted
Jean Jordaan
jean@upfrontsystems.co.za
Thu, 11 Oct 2001 13:52:33 +0200
Hi all
I don't know if you're all familiar with this already, but reading
about Twisted didn't immediately bring to mind Medusa, but rather
certain aspects (specifically, *aspects*) of TransWarp, and of the
Component Architecture (interfaces).
I'm including a bite from
http://twistedmatrix.com/page.epy/twistedphil.html
Interesting?
Regards,
Jean
Adverb Oriented
Twisted is "adverb oriented", which takes this one step further.
Using inheritance and a simple naming convention, Twisted classes
indicate what sort of events they are responding to. This allows
for conveniently extensible protocols along defined "vectors" for
extension.
Let's say you wanted an object to be both a Twisted Reality player, and
also an object accessible through Twisted PerspectiveBroker. You could
define a class that looked like the following::
class RemotePlayer(reality.player.Player, spread.pb.Referenced):
def ability_kill(self, sentence): #kills another player
foo()
def remote_killPlayer(self): #remote callable method.
bar()
Reality objects can have abilities, which you define by making a method
prefixed with ability_. pb objects have remotely callable
methods, which you define by making methods that begin with
remote_; so this is effectively the same as a class, a
snippet from the configuration file for a multi-user dungeon, and a
remote interface definition file; the three of which are normally
defined in different languages. Using "adverb orientation" and some
simple python features, we can avoid the need for macros or complex
parsing to achieve this effect.