When writing an application, we must try and cover the three activities mentioned in our overview of what a simple resource looks like:
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.
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.
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.
This activity was briefly covered in the MyApplication
example, but for "real world" applications the following topics must be
understood in more detail: