Software as a Service (SAAS) demystified from a programming prespective


python 2.7
requests library
an internet facing linux server for testing.

I always get asked by people, what is this cloud computing fiasco and how do it affect me?

This tutorial is aimed at demystifying from the programmer's prespective and the Network Admin's prespective what cloud computing is.

We will start off with a program that runs without "cloud" and then a program that is "cloud".

Local Program:

a local program is a software where all processes run on the computer the program was launched from.

a simple local program:

    import sys
    def pr(cmd):
    if __name__ == "__main__":
        cmd = sys.argv[1]

This print program runs all processes on your computer and hence is a local program.

Now you might ask the question, what if the program makes a network connection?

In a networked program, you can write a client, but still not be a cloud program.


    import sys
    import urllib2
    response = urllib2.urlopen(sys.argv[1])
    html =
    print html

Even though we make a network connection, the server we connect to is passed as an argument. making this in my opinion not a true cloud program.

However, if you create a client that connects to a http REST API,
with this facebook example:

import requests
r = requests.get('')
access_token = r.text.split('=')[1]
print access_token

you have created a client that interfaces with a Internet facing service., as the provider (Facebook) has to verify your identity and return the OAUTH access token.

What does this make cloud computing?

Cloud computing is NOTHING MORE than a buzzword for software where part of the process is run on 1 or more internet facing servers provided by the vendor of the software.

When you think about it this way, that means AOL, XMPP, Slack, IRC all work the same way, IM software is likely the oldest of "cloud systems."

So, How does one write a simple cloud based software?

First we write a simple message server, we will use the twisted matrix examples and expand on those:

from twisted.protocols import basic

class MyChat(basic.LineReceiver):
    def connectionMade(self):
        print "Got new client!"

    def connectionLost(self, reason):
        print "Lost a client!"

    def lineReceived(self, line):
        print "received", repr(line)
        for c in self.factory.clients:

    def message(self, message):
        self.transport.write(message + '\n')

from twisted.internet import reactor, protocol
from twisted.application import service, internet

factory = protocol.ServerFactory()
factory.protocol = MyChat
factory.clients = []
reactor.listenTCP(8004, factory)

The above should be run a TEST VPS,not your home or production systems.

this is a matching client:

from twisted.internet import reactor, protocol
# a client protocol
def io(self):
    while True:
        msg = raw_input("MESG>>> ")
        reactor.callFromThread(self.sendData, msg)
class EchoClient(protocol.Protocol):
    def sendData(self,data):
        print "sending %s...." % data
        self.transport.write(data + "\r\n")

    def connectionMade(self):
        reactor.callInThread(io, self)

    def dataReceived(self, data):
        print data

    def connectionLost(self, reason):
        print "connection lost"

class EchoFactory(protocol.ClientFactory):
    protocol = EchoClient

    def clientConnectionFailed(self, connector, reason):
        print "Connection failed - goodbye!"

    def clientConnectionLost(self, connector, reason):
        print "Connection lost - goodbye!"

# this connects the protocol to a server runing on port 8000
def main():
    f = EchoFactory()
    reactor.connectTCP("localhost", 8004, f)

# this only runs if the module was *not* imported
if __name__ == '__main__':

and you will see that we are communicating from one client over the internet to ALL of the connected clients on the internet facing server.

at this point we have very basic internet based chat software. In my opinion this really is not yet a SAAS platfrom, as SAAS uses authentication not only for security, but to deliver the right information to the right person.

If you were to add a sqlite database with some basic authentication into the server and some handlers, then you would have the start of an SAAS application, and you could tweak the above code to literaly make anything you want.

I do not intend to post code for the authentication at this time. That I leave to you neophyte Smile