Skip to content

Instantly share code, notes, and snippets.

@shanel
Created July 27, 2012 17:24
Show Gist options
  • Save shanel/3189240 to your computer and use it in GitHub Desktop.
Save shanel/3189240 to your computer and use it in GitHub Desktop.
MVC Thoughts and such...
Currently there isn't really any division between Model and Controller in the control panel. Views are _mostly_ separate into html/Mako templates. This means the big thing we need to do is create that division of Model and Controller. For the most part, CherryPy and its linking of method names to urls is basically doing most of the Controller-like heavy lifting. We are going to want to create Models of the different things (interfaces, webapps, etc) and have a way of letting them access and update their state.
In an ideal world we would break out and refactor files into different directories following a standard MVC setup:
models/
models/wired_network.py
models/wireless_network.py
models/mesh.py
models/daemon.py
models/webapp.py
models/state.py (or whatever we decide on for altering the persistance layer)
views/
views/directories_of_templates
controllers/
controllers/control_panel.py
controllers/gateways.py
controllers/meshconfiguration.py
controllers/networkconfiguration.py
controllers/networktraffic.py
controllers/services.py
controllers/status.py
static/
static/css/
static/images/
Models should be used for accessing the backend storage (currently sqlite3, something else soon). Controllers are basically just the functionality that CherryPy gives us.
Looking over the code here are some thoughts on what needs to be done:
* We need to factor out all the db calling stuff and replace it with Models (pulling them into their own files ideally)
- phase one would be to replace it all with code that can talk to sqlite3
- phase two would be to choose a different backend store and use that in the implementation
* We need to standardize on a style guide and update the code accordingly
* We need to write tests (ideally after we have broken stuff out)
@Sitwon
Copy link

Sitwon commented Jul 27, 2012

This looks like a pretty good plan to me. Whoever does this big refactoring job will basically hold a lock on the control panel until it's done. Anyone else trying to work on the control panel at the same time would have a hard time merging their changes with a big refactor like that.

@shanel
Copy link
Author

shanel commented Jul 27, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment