1.1 --- a/docs/paths-filesystem.html Sat Sep 08 16:01:41 2007 +0000
1.2 +++ b/docs/paths-filesystem.html Sat Sep 08 16:02:18 2007 +0000
1.3 @@ -1,68 +1,46 @@
1.4 +<?xml version="1.0" encoding="iso-8859-1"?>
1.5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1.6 <html xmlns="http://www.w3.org/1999/xhtml"><head>
1.7 -
1.8 - <title>Treating the Path Like a Filesystem</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.9 + <title>Treating the Path Like a Filesystem</title>
1.10 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.11 <body>
1.12 -<h1>Treating the Path Like a
1.13 -Filesystem</h1>
1.14 -<p>...or as a reference into
1.15 -deeply categorized resources. In this approach,
1.16 +<h1>Treating the Path Like a Filesystem</h1>
1.17 +<p>...or as a reference into deeply categorized resources. In this approach,
1.18 we take a path like this...</p>
1.19 <pre>/documents/news/2005/article.html</pre>
1.20 -<p>...and we consider <code>documents</code>,
1.21 -<code>news</code>,
1.22 -and
1.23 -<code>2005</code>
1.24 -as directories, and <code>article.html</code>
1.25 -as a
1.26 +<p>...and we consider <code>documents</code>, <code>news</code>, and
1.27 +<code>2005</code> as directories, and <code>article.html</code> as a
1.28 file-like resource. If we ask for the following path...</p>
1.29 <pre>/documents/news/2005</pre>
1.30 -<p>...we may decide to provide a
1.31 -listing of files within that directory, or
1.32 -we may decide to refuse such a request. Indeed some kinds of
1.33 -applications insist
1.34 -that such a listing may only be produced with the following path
1.35 -instead:</p>
1.36 +<p>...we may decide to provide a listing of files within that directory, or
1.37 +we may decide to refuse such a request. Indeed some kinds of applications insist
1.38 +that such a listing may only be produced with the following path instead:</p>
1.39 <pre>/documents/news/2005/</pre>
1.40 -<p>Applications of this kind are
1.41 -quite common since the publishing of files
1.42 -on a Web server often just involves exposing parts of a real filesystem
1.43 -to
1.44 +<p>Applications of this kind are quite common since the publishing of files
1.45 +on a Web server often just involves exposing parts of a real filesystem to
1.46 requests through the server.</p>
1.47 -<h2>Resource Hierarchies in
1.48 -WebStack</h2>
1.49 -<p>There are a number of different
1.50 -ways that paths can be interpreted and handled in WebStack
1.51 +<h2>Resource Hierarchies in WebStack</h2>
1.52 +<p>There are a number of different ways that paths can be interpreted and handled in WebStack
1.53 applications, including...</p>
1.54 <ul>
1.55 - <li>Using predefined hierarchies
1.56 -of resources.</li>
1.57 - <li>By inspecting the path in a
1.58 -top-level resource and then creating resources to deal with different
1.59 + <li>Using predefined hierarchies of resources.</li>
1.60 + <li>By inspecting the path in a top-level resource and then creating resources to deal with different
1.61 cases.</li>
1.62 - <li>By handling all kinds of
1.63 -paths in the same resource.</li>
1.64 + <li>By handling all kinds of paths in the same resource.</li>
1.65 </ul>
1.66 -<h3>Predefining Resource
1.67 -Hierarchies</h3>
1.68 -<p>We might decide to represent
1.69 -components in these kinds of paths using
1.70 +<h3>Predefining Resource Hierarchies</h3>
1.71 +<p>We might decide to represent components in these kinds of paths using
1.72 different resource classes; for example:</p>
1.73 <ul>
1.74 - <li>Folders or directories are
1.75 -represented by a special resource class which contains other
1.76 + <li>Folders or directories are represented by a special resource class which contains other
1.77 folders and possibly some files.</li>
1.78 - <li>Files or documents are
1.79 -represented by special resource classes which provide access
1.80 + <li>Files or documents are represented by special resource classes which provide access
1.81 to the content of such files.</li>
1.82 </ul>
1.83 -We might then predefine a hierarchy of resources
1.84 -so that when a request arrives for a resource, we can check it against
1.85 -the
1.86 -hierarchy and process the request according to whichever type of
1.87 -resource is
1.88 -being accessed. For example:<br />
1.89 +<p>We might then predefine a hierarchy of resources
1.90 +so that when a request arrives for a resource, we can check it against the
1.91 +hierarchy and process the request according to whichever type of resource is
1.92 +being accessed. For example:</p>
1.93 <ul>
1.94 <li><code>documents</code>
1.95 <ul>
1.96 @@ -84,23 +62,22 @@
1.97 </ul>
1.98 </li>
1.99 </ul>
1.100 -<p>Consider the above hierarchy;
1.101 -we would implement such a hierarchy with a
1.102 -resource object mapped to <code>documents</code>,
1.103 -and that resource object
1.104 +<p>Consider the above hierarchy; we would implement such a hierarchy with a
1.105 +resource object mapped to <code>documents</code>, and that resource object
1.106 would contain a mapping of years to other resources. Eventually, at the
1.107 bottom of the hierarchy, individual resources would represent articles
1.108 -and be
1.109 -mapped to names such as <code>article.html</code>.</p>
1.110 +and be mapped to names such as <code>article.html</code>.</p>
1.111 <div class="WebStack">
1.112 -<h3>WebStack API - Predefining
1.113 -Resource Hierarchies in Adapter Code</h3>
1.114 +<h3>WebStack API - Predefining Resource Hierarchies in Adapter Code</h3>
1.115
1.116 <p>WebStack provides the <code>MapResource</code>
1.117 class (in the <code>WebStack.Resources.ResourceMap</code> module) for convenient mapping of path
1.118 -components to resource objects<code></code>. See the <a href="resource-map.html">"ResourceMap - Simple Mappings from Names to Resources"</a> document for a more detailed description of the <code>MapResource</code> class.</p><p>This class can be used in <a href="deploying.html">adapter code</a>
1.119 -to initialise an
1.120 -application as follows:</p>
1.121 +components to resource objects<code></code>.
1.122 +See the <a href="resource-map.html">"ResourceMap - Simple Mappings from Names to Resources"</a>
1.123 +document for a more detailed description of the <code>MapResource</code> class.</p>
1.124 +
1.125 +<p>This class can be used in <a href="deploying.html">adapter code</a>
1.126 +to initialise an application as follows:</p>
1.127 <pre>from WebStack.Resources.ResourceMap import MapResource<br />from MyApplication import FileResource # import some resource class<br /><br />article_resource = FileResource(...) # make a resource representing the article<br />document_resource = FileResource(...) # make a resource representing the document<br />year_2004_resource = MapResource({"document.html" : document_resource})<br />year_2005_resource = MapResource({"article.html" : article_resource})<br />news_resource = MapResource({"2005" : year_2005_resource, "2004" : year_2004_resource})<br />documents_resource = MapResource({"news" : news_resource})<br />top_resource = MapResource({"documents" : documents_resource})</pre>
1.128 </div>
1.129 <p>Of course, predefining resource
1.130 @@ -108,4 +85,4 @@
1.131 hierarchies. We could inspect paths and act dynamically on the supplied
1.132 information, either choosing to create resources or choosing to handle
1.133 such paths in the same resource.</p>
1.134 -</body></html>
1.135 \ No newline at end of file
1.136 +</body></html>