Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. //WITHOUT DEPENDENCY INJECTION
  2. class MyClass:
  3.     def __init__():
  4.         pass
  5.    
  6.     def Method1(self):
  7.         if (session['key1'] == 'whatiexpect?'):
  8.             do something
  9.  
  10.  
  11.  
  12. //WITH DEPENDENCY INJECTION
  13. class MyClass:
  14.  
  15.     def __init__(session):
  16.         this.session = session
  17.  
  18.     def Method1(self):
  19.         if (this.session['key1'] == 'whatiexpect?'):
  20.             do something
  21.  
  22.  
  23. //CALLER CLASS
  24. realsession = session
  25. var c = MyClass(realsession)
  26.  
  27.  
  28. //test
  29. session['key1'] = 'valuetotest'
  30. var c = MyClass(session)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement