URLs and Paths

The URL at which your application shall appear is arguably the first part of the application's user interface that any user will see. Remember that a user of your application does not have to be a real person; in fact, a user can be any of the following things:

Some application developers have a fairly rigid view of what kind of information a URL should contain and how it should be structured. In this guide, we shall look at a number of different approaches.

Interpreting Path Information

What the URL is supposed to do is to say where (on the Internet or on an intranet) your application resides and which resource or service is being accessed, and these look like this:

http://www.boddie.org.uk/python/WebStack.html

In an application the full URL, containing the address of the machine on which it is running, is not always interesting. In the WebStack API (and in other Web programming frameworks), we also talk about "paths" - a path is just the part of the URL which refers to the resource or service, ignoring the actual Internet address, and so the above example would have a path which looks like this:

/python/WebStack.html

When writing a Web application, most of the time you just need to concentrate on the path because the address doesn't usually tell you anything you don't already know. What you need to do is to interpret the path specified in the request in order to work out which resource or service the user is trying to access.

WebStack API - Path Methods in Transaction Objects

WebStack provides the following transaction methods for inspecting path information:

get_path
This gets the entire path of a resource including parameter information (as described in "Request Parameters and Uploads").
get_path_without_query
This gets the entire path of a resource but without any parameter information.

Query Strings

Sometimes, a "query string" will be provided as part of a URL; for example:

http://www.boddie.org.uk/application?param1=value1

The question mark character marks the beginning of the query string which contains encoded parameter information; such information and its inspection is discussed in "Request Parameters and Uploads".

More About Paths