# 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 @@
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 @@ + + + + +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 provides the following methods to transform path values:
+decode_path
encode_path
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 @@encoding
parameter may be used to assist the process of converting the path to a Unicode object - see below.get_path_without_info
encoding
parameter may be used to assist the process of converting the path to a Unicode object - see below.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 provides the following method to perform redirection:
+redirect
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