Application Design Considerations

When writing an application, we must try and cover the three activities mentioned in our overview of what a simple resource looks like:

  1. Examine the transaction, decide what the user wants to do.
  2. Perform some kind of action with the information supplied.
  3. Produce some kind of response which tells the user what happened.

We briefly covered the third activity in the MyApplication example, but for a real, properly-behaved application, we need to visit each activity in detail.

Examine the Transaction

In WebStack, the transaction is an object which is passed into a resource when a user makes contact with an application. This transaction object effectively tells us what it is the user wants to do; it does so through a number of different pieces of information including the request method, headers, parameters, cookies and sessions.

The transaction object appears as the first parameter in a resource's respond method:

class MyResource:
def respond(self, trans):
[Here is where the code for the resource is written.]

Within this activity, certain topics are of interest:

For full information about transaction objects, see the API documentation for the WebStack.Generic.Transaction class.

Perform Actions

Of all activities summarised above, this is the most vague because the kinds of actions performed by applications will vary substantially depending on what the application is supposed to do. Indeed, it is within this activity that most applications will probably be integrated with other systems - they may access databases or Web services, for example.

WebStack does not mandate any particular style of integration with other systems. It is generally recommended that developers use whichever Python modules or packages they prefer and just to import these into their applications. See "Integrating with Other Systems" for advice on this subject.

Produce a Response

This activity was briefly covered in the MyApplication example, but for "real world" applications the following topics must be understood in more detail: