# HG changeset patch # User paulb # Date 1114382842 0 # Node ID bb9b193cc3bc38932a411396a2ef5a6ecb782a63 # Parent 3ff52e9a1e4053463678a990c8c898a68bbde6c5 [project @ 2005-04-24 22:47:22 by paulb] Updated the information about resource hierarchies. diff -r 3ff52e9a1e40 -r bb9b193cc3bc docs/index.html --- a/docs/index.html Sun Apr 24 15:43:10 2005 +0000 +++ b/docs/index.html Sun Apr 24 22:47:22 2005 +0000 @@ -1,36 +1,32 @@ - - +
This set of documents describes the process of making a Web application +
This set of documents describes the process of making a Web +application using the WebStack framework.
-First of all, let us assume that the WebStack distribution has been
unpacked and now sits in the WebStack-0.9
directory.
Before we begin, we must make sure that the WebStack package is available +
Before we begin, we must make sure that the WebStack package is
+available
to Python. The easiest way to do this is to change into the
WebStack-0.9
directory and to run the setup.py
script provided with the version of Python you are going to be using
(possibly as a privileged user like root
):
cd WebStack-0.9- -
python setup.py install
If you don't want to install WebStack in this way, or if you can't do so
-because you don't have root
privileges, you can just make sure
-that the WebStack-0.9
directory sits on the
+
If you don't want to install WebStack in this way, or if you can't
+do so
+because you don't have root
privileges, you can just make
+sure
+that the WebStack-0.9
directory sits on your
PYTHONPATH
.
...or as a reference into deeply categorized resources. In this approach, +
...or as a reference into +deeply categorized resources. In this approach, we take a path like this...
/documents/news/2005/article.html- -
...and we consider documents
, news
, and
-2005
as directories, and article.html
as a
+
...and we consider documents
,
+news
,
+and
+2005
+as directories, and article.html
+as a
file-like resource. If we ask for the following path...
/documents/news/2005- -
...we may decide to provide a listing of files within that directory, or -we may decide to refuse such a request. Indeed some approaches will insist -that such a listing may only be produced with the following path instead:
+...we may decide to provide a +listing of files within that directory, or +we may decide to refuse such a request. Indeed some kinds of +applications insist +that such a listing may only be produced with the following path +instead:
/documents/news/2005/- -
Applications of this kind are quite common since the publishing of files -on a Web server often just involves exposing parts of a real filesystem to +
Applications of this kind are +quite common since the publishing of files +on a Web server often just involves exposing parts of a real filesystem +to requests through the server.
- -We might decide to represent components in these kinds of paths using -different resource classes, so that folders or directories are represented by -one kind of resource class and files or documents are represented by other -kinds of resource classes. We might then predefine a hierarchy of resources -so that when a request arrives for a resource, we can check it against the -hierarchy and process the request according to whichever type of resource is -being accessed.
- -Consider the above hierarchy; we would implement such a hierarchy with a
-resource object mapped to documents
, and that resource object
+
There are a number of different +ways that paths can be interpreted and handled in WebStack +applications, including...
+We might decide to represent +components in these kinds of paths using +different resource classes; for example:
+documents
+ news
+ 2005
+ article.html
another.html
2004
+ document.html
Consider the above hierarchy;
+we would implement such a hierarchy with a
+resource object mapped to documents
,
+and that resource object
would contain a mapping of years to other resources. Eventually, at the
-bottom of the hierarchy, individual resources would represent articles and be
+bottom of the hierarchy, individual resources would represent articles
+and be
mapped to names such as article.html
.
WebStack provides a resource class for convenient mapping of path +
WebStack provides a resource
+class for convenient mapping of path
components (ie. names) to resource objects:
WebStack.Resources.ResourceMap.MapResource
This class can be used in adapter or "glue" code to initialise an +
This class can be used in adapter code +to initialise an application as follows:
-from WebStack.Resources.ResourceMap import MapResource -article_resource = [some resource representing the article] -year_2004_resource = [a MapResource with definitions] -year_2005_resource = MapResource({"article.html" : article_resource}) -news_resource = MapResource({"2005" : year_2005_resource, "2004" : year_2004_resource}) -documents_resource = MapResource({"news" : news_resource}) -top_resource = MapResource({"documents" : documents_resource})+
from WebStack.Resources.ResourceMap import MapResource
from MyApplication import FileResource # import some resource class
article_resource = FileResource(...) # make a resource representing the article
document_resource = FileResource(...) # make a resource representing the document
year_2004_resource = MapResource({"document.html" : document_resource})
year_2005_resource = MapResource({"article.html" : article_resource})
news_resource = MapResource({"2005" : year_2005_resource, "2004" : year_2004_resource})
documents_resource = MapResource({"news" : news_resource})
top_resource = MapResource({"documents" : documents_resource})
Of course, predefining hierarchies is not the only way to support such +
Of course, predefining resource +objects is not the only way to support such hierarchies. We could inspect paths and act dynamically on the supplied -information.
+information, either choosing to create resources or choosing to handle +such paths in the same resource.