Exemplo n.º 1
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 def __init__(self, source, sink):
     self.source = source
     self.sink = sink
     self.transfer_context = context(self,
                                     source=MoneySource,
                                     sink=MoneySink)
Exemplo n.º 7
0
 def transfer_money__with(self, amount):
     """
     The interaction.
     """
     with context(self):
         self.from_account.transfer(amount)
Exemplo n.º 8
0
 def doit(self):
     with context(self):
         # Save stack to ensure it's different
         context.stack = context.__dict__.get('__stack')
Exemplo n.º 9
0
 def transfer_money__with(self, amount):
     """The interaction."""
     with context(self):
         assert isinstance(self.from_account, PaymentAccount)
         self.from_account.transfer(amount)
Exemplo n.º 10
0
 def doit(self):
     with context(self):
         # Save stack to ensure it's different
         context.stack = context.__dict__.get("__stack")
Exemplo n.º 11
0
 def __init__(self, source, sink):
     self.source = source
     self.sink = sink
     self.transfer_context = context(self,
             source=MoneySource,
             sink=MoneySink)
Exemplo n.º 12
0
 def transfer_money__with(self, amount):
     """
     The interaction.
     """
     with context(self):
         self.from_account.transfer(amount)