[Reality] getting started?

Christopher Armstrong reality@twistedmatrix.com
Sun, 24 Aug 2003 17:08:16 -0400


On Sun, Aug 24, 2003 at 01:29:03PM -0700, Eric Wong wrote:
>     In TR, "things" interact with one another through their "adapters"
>     which conform to and implement "interfaces", all of which are objects.

Pretty much, yes. All of the adapter and interface logic is actually a
part of Twisted; Reality is just one of its most demanding use cases.

> For example, if I wanted to add the ability to speak to players, I'd
> first define an interface ("ISpeaker" and "IListener", or if I were using
> action.TargetAction, "ISayActor", "ISayTarget" and "ISayPlace") write
> an adapter that implements that interface and register that adapter it
> to things.Player or things.Actor.  Then, later on, if I wanted to make
> a Bugs Bunny-like Singing Sword, I could just register the same Say
> adapter to an ordinary sword (thing with Weapon adapter).

This sounds right.

> This is probably a common complaint from someone not used to interface/
> adapters, but one thing that sort of bothers me is that an objects's
> adapters are registered in the adapter, not with the object.  For example
> Actor is defined in things.py, but the Damagable interface is registered
> to Actor in harm.py.

This is the _whole point_ of adapters -- separating concerns so you
don't need to modify the original object to add functionality to it.

-- 
 Twisted | Christopher Armstrong: International Man of Twistery
  Radix  |          Release Manager,  Twisted Project
---------+     http://twistedmatrix.com/users/radix.twistd/