I am trying to convert this application i created into MVC style. This is my original source:
http://pastebin.com/xELEt0yi
Below is my attempt to create above source into MVC
http://pastebin.com/B21cskhA
My issues:
- I don't understand ho开发者_如何学编程w to call from another class. I tried making "_init _" under each class to call model, view or control. Unfortunately i ran into this error: RuntimeError: maximum recursion depth exceeded
- I thought about maybe turning my data into dictionaries but i don't know if i am creating that correctly. The attempted MVC source above has the dictionaries i am referring too.
- last thing is in my source my view can go two ways. If "y" does something if "n" does something else. How do i go about letting my controller switching from those, would it be something like this: http://pastebin.com/Z9pp1L3g
Can someone look at my MVC source and guide me to completing this task.
Thanks
My Application using MVC:
http://pastebin.com/0CiTqiwu
I was rather close in completing this task. I had it as
class Controller:
def __init__(self):
self.model = Model()
self.view = View()
def main(self):
self.model.filename()
self.view.tcpdump()
instead of:
class Controller:
def __init__(self):
self.view = View()
def main(self):
self.view.filename()
self.view.tcpdump()
Which after i changed it to that with the help of a co-worker, the script turned out to work perfect. Operation turn simple tcpdump script to MVC style, Success!
Thanks everyone for the help~
精彩评论