paulb@327 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
paulb@327 | 2 | <html> |
paulb@327 | 3 | <head> |
paulb@327 | 4 | <meta http-equiv="Content-Type" content="text/html"> |
paulb@327 | 5 | <title>URLs and Paths</title> |
paulb@327 | 6 | <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/"> |
paulb@327 | 7 | <link href="styles.css" rel="stylesheet" type="text/css"> |
paulb@327 | 8 | </head> |
paulb@327 | 9 | |
paulb@327 | 10 | <body> |
paulb@327 | 11 | <h1>URLs and Paths</h1> |
paulb@327 | 12 | |
paulb@327 | 13 | <p>The URL at which your application shall appear is arguably the first part |
paulb@327 | 14 | of the application's user interface that any user will see. In this context, |
paulb@327 | 15 | a user can be any of the following things:</p> |
paulb@327 | 16 | <ul> |
paulb@327 | 17 | <li>A real person entering the URL into a browser's address bar.</li> |
paulb@327 | 18 | <li>A real person linking to your application by writing the URL in a |
paulb@327 | 19 | separate Web page.</li> |
paulb@327 | 20 | <li>A program which has the URL defined within it and which may manipulate |
paulb@327 | 21 | the URL to perform certain kinds of operations.</li> |
paulb@327 | 22 | </ul> |
paulb@327 | 23 | |
paulb@327 | 24 | <h2>Interpreting Path Information</h2> |
paulb@327 | 25 | |
paulb@327 | 26 | <p>What the URL is supposed to do is to say where (on the Internet or on an |
paulb@327 | 27 | intranet) your application resides and which resource or service is being |
paulb@327 | 28 | accessed, and these look like this:</p> |
paulb@327 | 29 | <pre>http://www.boddie.org.uk/python/WebStack.html</pre> |
paulb@327 | 30 | |
paulb@327 | 31 | <p>With WebStack, we also talk about a "path" as being just the part of the |
paulb@327 | 32 | URL which refers to the resource or service, ignoring the actual Internet |
paulb@327 | 33 | address, and so these look like this:</p> |
paulb@327 | 34 | <pre>/python/WebStack.html</pre> |
paulb@327 | 35 | |
paulb@327 | 36 | <p>When writing a Web application, most of the time you just need to |
paulb@327 | 37 | concentrate on the path because the address doesn't usually tell you anything |
paulb@327 | 38 | you don't already know. What you need to do is to interpret the path |
paulb@327 | 39 | specified in the request in order to work out which resource or service the |
paulb@327 | 40 | request is destined for.<br> |
paulb@327 | 41 | </p> |
paulb@327 | 42 | |
paulb@327 | 43 | <div class="WebStack"> |
paulb@327 | 44 | <h3>WebStack API - Path Methods in Transaction Objects</h3> |
paulb@327 | 45 | |
paulb@327 | 46 | <p>WebStack provides the following transaction methods for inspecting path |
paulb@327 | 47 | information:</p> |
paulb@327 | 48 | <dl> |
paulb@327 | 49 | <dt><code>get_path</code></dt> |
paulb@327 | 50 | <dd>This gets the entire path of a resource including parameter |
paulb@327 | 51 | information - see <a href="parameters.html">"Request Parameters and |
paulb@327 | 52 | Uploads"</a>.</dd> |
paulb@327 | 53 | <dt><code>get_path_without_query</code></dt> |
paulb@327 | 54 | <dd>This gets the entire path of a resource but without any parameter |
paulb@327 | 55 | information.</dd> |
paulb@327 | 56 | </dl> |
paulb@327 | 57 | </div> |
paulb@327 | 58 | |
paulb@327 | 59 | <h2>Paths To and Within an Application</h2> |
paulb@327 | 60 | One thing to be aware of in the code of an application is which part of a |
paulb@327 | 61 | path refers to the location of the application in a server environment and |
paulb@327 | 62 | which refers to some resource within the application itself. Consider this |
paulb@327 | 63 | path:<br> |
paulb@327 | 64 | |
paulb@327 | 65 | <pre>/folder/application/resource</pre> |
paulb@327 | 66 | Let us say that the application was deployed in a Zope server instance inside |
paulb@327 | 67 | <code>folder</code> and with the name <code>application</code>. We may then |
paulb@327 | 68 | say that the path to the application is this: |
paulb@327 | 69 | <pre>/folder/application</pre> |
paulb@327 | 70 | Meanwhile, the path within the application is just this: |
paulb@327 | 71 | <pre>/resource</pre> |
paulb@327 | 72 | |
paulb@327 | 73 | <div class="WebStack"> |
paulb@327 | 74 | <h3>WebStack API - Paths To Resources Within Applications</h3> |
paulb@327 | 75 | |
paulb@327 | 76 | <p>On transaction objects, the following methods exist to inspect paths to |
paulb@327 | 77 | resources within applications.</p> |
paulb@327 | 78 | <dl> |
paulb@327 | 79 | <dt><code>get_path_info</code></dt> |
paulb@327 | 80 | <dd>This gets the path of a resource within an application.</dd> |
paulb@327 | 81 | <dt><code>get_virtual_path_info</code></dt> |
paulb@327 | 82 | <dd>This gets the path of a resource within a part of an application - |
paulb@327 | 83 | the application itself decides the scope of the path and can set the |
paulb@327 | 84 | "virtual path info" using the <code>set_virtual_path_info</code> |
paulb@327 | 85 | method.</dd> |
paulb@327 | 86 | </dl> |
paulb@327 | 87 | </div> |
paulb@327 | 88 | |
paulb@327 | 89 | <h2>Approaches to Path Interpretation<br> |
paulb@327 | 90 | </h2> |
paulb@327 | 91 | |
paulb@327 | 92 | <p>There are various differing approaches to the problem of interpreting |
paulb@327 | 93 | paths to resources within Web applications, but these can mostly be divided |
paulb@327 | 94 | into three categories:</p> |
paulb@327 | 95 | |
paulb@327 | 96 | <table border="1" cellspacing="0" cellpadding="5"> |
paulb@327 | 97 | <tbody> |
paulb@327 | 98 | <tr> |
paulb@327 | 99 | <th>Approach</th> |
paulb@327 | 100 | <th>Examples</th> |
paulb@327 | 101 | </tr> |
paulb@327 | 102 | <tr> |
paulb@327 | 103 | <td><a href="paths-filesystem.html">Path as filesystem</a></td> |
paulb@327 | 104 | <td>WebDAV interface to a repository</td> |
paulb@327 | 105 | </tr> |
paulb@327 | 106 | <tr> |
paulb@327 | 107 | <td><a href="paths-services.html">Path as resource or service |
paulb@327 | 108 | identifier</a></td> |
paulb@327 | 109 | <td>A Web shop with very simple paths, eg. <code>/products</code>, |
paulb@327 | 110 | <code>/checkout</code>, <code>/orders</code></td> |
paulb@327 | 111 | </tr> |
paulb@327 | 112 | <tr> |
paulb@327 | 113 | <td><a href="paths-opaque.html">Path as opaque reference</a></td> |
paulb@327 | 114 | <td>An e-mail reader where the messages already have strange and |
paulb@327 | 115 | unreadable message identifiers</td> |
paulb@327 | 116 | </tr> |
paulb@327 | 117 | </tbody> |
paulb@327 | 118 | </table> |
paulb@327 | 119 | </body> |
paulb@327 | 120 | </html> |