[Twisted-Python] twisted.persisted.journal: a prevayler-inspired persistence system

Itamar Shtull-Trauring twisted at itamarst.org
Sun Oct 13 18:29:36 MDT 2002


On Sun, 13 Oct 2002 16:11:04 -0500 (CDT)
Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:

> 
> On Sun, 13 Oct 2002 02:44:05 -0400, Itamar Shtull-Trauring
> <twisted at itamarst.org> wrote:
> 
> > Prevayler has something like that where you have Clock passed to
> > commands, IIRC. I probably should add some code so commands can get
> > a "fake" time, i.e. the time they were supposed to have been run.
> > Not sure that randomness is worth doing - if you are using it
> > presumably any outcome is equally valid, or alternatively if that's
> > not that case you can't really use journal anyway.
> 
> Not in the case of a game: certain events have "random" outcomes,
> weighted randomness based on a die roll plus some skill modifiers and
> so forth.  You can still use object prevalence to persist this
> information, but you need the die rolls associated with a certain
> action to be the same the second time through.

OK then:

class RollDice:
   def __init__(self):
       self.value = rollDice()

   def execute(self, service, startTime):
       service.foo(self.value)

In other words - do it in the command, not in the framework, because
frankly I have no way of knowing what random generator you use and so
on.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python, Twisted, Zope and Java consulting




More information about the Twisted-Python mailing list