skeletonz - The simple Python CMS system

Naming of methods and variables

  • Methods are camelCased.
  • Variables and internal functions are lower_cased.


Create, read, update, delete (CRUD) operations on the controller should be:

class MyController:
  def viewAdd(self, ...):
    """Returns the HTML site for adding an item"""

  def viewEdit(self, ...):
    """Returns the HTML site for editing an item"""

  def add(self, ...):
    """Adds something to the database and returns some HTML or similar"""

  def delete(self, ...):
    """Deletes something from the database and returns some HTML or similar"""

  def update(self, ...):
    """Update something in the database and returns some HTML or similar"""

Things to remember:

  • Never query directly to the database from add, delete or update... Call add, delete or update on the model!
  • If you have 2 of the same CRUD functions, then split the class in two.

Read operation(s) may be a lot of things, it could be a index() method that returns a website or viewHTML() method that returns some HTML or a method getJSON() that returns some JSON. This depends on what the controller does and what its operating domain is.


In the model the assessor and mutator functions should be separated.

class MyModel:
  def getItemById(self, ...):
  def getItemByIdent(self, ...):

  def add(self, ...):
  def update(self, ...):
  def delete(self, ...):
  def changeMyStyle(self, ...):

A model class should only "model" one domain.


In JavaScript add(), del() and update() should be used as CRUD methods. Operations that show something in a GreyBox window should be prefixed with view, e.g. viewAdd().

Powered by Skeletonz