def doit(self, level=100): if level == 0: context.depth = len(context.__dict__['__stack']) else: with context(self): print (context.__dict__['__stack']), level self.doit(level - 1) time.sleep(0.001)
def __init__(self, source, sink): self.source = source self.sink = sink roles = { 'source': MoneySource, 'sink': MoneySink, } self.transfer_context = context(self, **roles)
def doit(self, level=100): if level == 0: context.depth = len(context.__dict__["__stack"]) else: with context(self): print((context.__dict__["__stack"]), level) self.doit(level - 1) time.sleep(0.001)
def transfer_money(self, amount): """The interaction.""" with context(self), MoneySource.played_by( self.source), MoneySink.played_by(self.sink): self.source.transfer(amount) print("We can still access the original attributes", self.sink.balance) print("Is it still an Account?", isinstance(self.sink, Account)) self.source.save() self.sink.save()
def transfer_money(self, amount): """ The interaction. """ with context(self),\ MoneySource.played_by(self.source),\ MoneySink.played_by(self.sink): self.source.transfer(amount) print "We can still access the original attributes", self.sink.balance print "Is it still an Account?", isinstance(self.sink, Account) #print "Object equality?", dst == self.sink self.source.save() self.sink.save()
def __init__(self, source, sink): self.source = source self.sink = sink self.transfer_context = context(self, source=MoneySource, sink=MoneySink)
def transfer_money__with(self, amount): """ The interaction. """ with context(self): self.from_account.transfer(amount)
def doit(self): with context(self): # Save stack to ensure it's different context.stack = context.__dict__.get('__stack')
def transfer_money__with(self, amount): """The interaction.""" with context(self): assert isinstance(self.from_account, PaymentAccount) self.from_account.transfer(amount)
def doit(self): with context(self): # Save stack to ensure it's different context.stack = context.__dict__.get("__stack")