# HG changeset patch # User paulb # Date 1132165665 0 # Node ID 2c3acfc0fa8bc30ad4656292873f8a288e170f93 # Parent b0e8a3b6a06f75cf7721cb32582cb45399baf8d2 [project @ 2005-11-16 18:27:45 by paulb] Added details of the get_path_without_info, update_path and redirect methods, along with descriptions of decode_path and encode_path. diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/developing.html --- a/docs/developing.html Wed Nov 16 18:27:07 2005 +0000 +++ b/docs/developing.html Wed Nov 16 18:27:45 2005 +0000 @@ -32,7 +32,7 @@
  • Treating the Path Mostly Like a Filesystem
  • Using the Path as an Opaque Reference into an Application
  • - +
  • Encoding and Decoding Path Values
  • Manipulating Paths
  • Path Info Support in Server Environments
  • diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/path-info.html --- a/docs/path-info.html Wed Nov 16 18:27:07 2005 +0000 +++ b/docs/path-info.html Wed Nov 16 18:27:45 2005 +0000 @@ -83,10 +83,10 @@ Path Building links to -resources within an application - subtract the "path info" from -the end and you should get the location of the application. +resources within an application. - + Path without path infoFinding the location of the application in a server environment. (This is the path with the "path info" subtracted from +the end.) Path info Determining which resources are being accessed within an application. diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/path-manipulation.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/path-manipulation.html Wed Nov 16 18:27:45 2005 +0000 @@ -0,0 +1,13 @@ + + + + + Manipulating Paths + + +

    Manipulating Paths

    Whilst path values are useful in telling +us something about where a particular resource resides or how far the +processing of a resource has progressed, it is sometimes useful to +apply some kind of transformation to the path in order to produce a +reference to another resource or application. Consider the simple case +of redirecting a user to another resource:

    First we must obtain a reference to the current resource:

    this_resource = trans.get_path_without_query() # eg. "/app/resource/some-data"

    We may wish to redirect the user to the main application resource; this is done by removing resource from the end of the path:

    this_app = trans.update_path("..")             #     produces "/app/resource"

    A complete description of this method can be found in the API documentation.

    \ No newline at end of file diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/path-value-encoding.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/path-value-encoding.html Wed Nov 16 18:27:45 2005 +0000 @@ -0,0 +1,30 @@ + + + + + Encoding and Decoding Path Values + + +

    Encoding and Decoding Path Values

    On some occasions it can +be necessary to manually decode path values, producing genuine Unicode +objects, and then to encode them, producing plain strings that can be +used in response headers and other places. For such occasions, some +transaction methods are available:

    +

    WebStack API - Encoding and Decoding Path Values

    +

    WebStack provides the following methods to transform path values:

    +
    decode_path
    This method accepts a path containing "URL encoded" information (as defined in the "URLs and Paths" +document) and, using an optional encoding parameter, returns a Unicode +object containing genuine character values in place of the "URL +encoded" values.
    encode_path
    This method +accepts a Unicode object containing the path and an optional encoding +parameter; it reverses the process carried out by the decode_path method.
    +

    Generally, the decode_path method is of little interest; its only relatively common application might be to decode query strings:

    qs = trans.get_query_string()                # eg. "a=%E6"
    new_qs = trans.decode_path(qs, "iso-8859-1") # producing "a=æ"

    Such operations are generally better performed using the request parameter methods.

    The encode_path +method is slightly more useful: since various transaction methods +return values which have already been transformed into Unicode objects, +we must consider the use of encode_path to produce values +which are suitable for feeding into other methods. For example, having +obtained a path, we may wish to cause a redirect to another location +based on that path:

    path = trans.get_path_without_query("iso-8859-1") # eg. "/app/resource"
    path += "/æøå"
    new_path = trans.encode_path(path, "iso-8859-1") # producing "/app/resource/%E6%F8%E5"
    trans.redirect(new_path)

    It +is essential to encode the path in such situations because the +underlying mechanisms do not support the full range of Unicode +characters. Some cases where this limitation exists are listed in the "Character Encodings" document.

    \ No newline at end of file diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/paths.html --- a/docs/paths.html Wed Nov 16 18:27:07 2005 +0000 +++ b/docs/paths.html Wed Nov 16 18:27:45 2005 +0000 @@ -58,6 +58,12 @@
    This gets the entire path of a resource but without any parameter information.
    +An optional encoding parameter may be used to assist the process of converting the path to a Unicode object - see below.
    get_path_without_info
    This gets the entire path of a resource but without any parameter +information or any special "path info" (as described in "Paths To and Within Applications"). +The result is more or less equivalent to the location where an +application has been "published" - ie. the location of an application +in a server environment.
    + An optional encoding parameter may be used to assist the process of converting the path to a Unicode object - see below.
    @@ -124,7 +130,7 @@

    More About Paths

    diff -r b0e8a3b6a06f -r 2c3acfc0fa8b docs/redirection.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/redirection.html Wed Nov 16 18:27:45 2005 +0000 @@ -0,0 +1,18 @@ + + + + + Redirection + + + +

    Redirection

    Instead of presenting information to a user when +that user visits a particular URL, we may instead choose to redirect +that user to another URL, at which there may be information to be +viewed. To redirect a user of an application, we can use the following +transaction method:

    +

    WebStack API - Redirection

    +

    WebStack provides the following method to perform redirection:

    +
    redirect
    This method accepts a path value +suitable for use in response headers indicating the location to which a +user shall be redirected. An optional response code (see "Responses and Presentation") can be specified to modify the meaning of the redirection (as defined in the HTTP specifications).

    Since the path value must be usable in response header, it is necessary to transform paths as described in the "Encoding and Decoding Path Values" document, and an example of redirection is given in that document.

    \ No newline at end of file