1.1 --- a/README.txt Mon Nov 21 12:59:14 2005 +0000
1.2 +++ b/README.txt Fri Nov 25 16:51:54 2005 +0000
1.3 @@ -61,6 +61,7 @@
1.4 the DirectoryRepository from the Repositories package.
1.5 * Added get_path_without_info, update_path and redirect methods to the
1.6 Transaction class.
1.7 + * Added get_attributes (attribute support) to the Transaction class.
1.8 * Added a values method to Helpers.Session.Wrapper.
1.9 * Improved/fixed exception handling in the adapters so that transactions are
1.10 committed as the final act of an adapter experiencing an unhandled
2.1 --- a/WebStack/Generic.py Mon Nov 21 12:59:14 2005 +0000
2.2 +++ b/WebStack/Generic.py Fri Nov 25 16:51:54 2005 +0000
2.3 @@ -627,6 +627,26 @@
2.4 else:
2.5 return real_path_info[:i]
2.6
2.7 + def get_attributes(self):
2.8 +
2.9 + """
2.10 + An application-specific method which obtains a dictionary mapping names
2.11 + to attribute values that can be used to store arbitrary information.
2.12 +
2.13 + Since the dictionary of attributes is retained by the transaction during
2.14 + its lifetime, such a dictionary can be used to store information that an
2.15 + application wishes to communicate amongst its components and resources
2.16 + without having to pass objects other than the transaction between them.
2.17 +
2.18 + The returned dictionary can be modified using normal dictionary-like
2.19 + methods. If no attributes existed previously, a new dictionary is
2.20 + created and associated with the transaction.
2.21 + """
2.22 +
2.23 + if not hasattr(self, "_attributes"):
2.24 + self._attributes = {}
2.25 + return self._attributes
2.26 +
2.27 # Utility methods.
2.28
2.29 def update_path(self, path, relative_path):
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/docs/attributes.html Fri Nov 25 16:51:54 2005 +0000
3.3 @@ -0,0 +1,37 @@
3.4 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.5 +<html xmlns="http://www.w3.org/1999/xhtml"><head>
3.6 + <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type" />
3.7 +
3.8 + <title>Transaction Attributes</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
3.9 + <link href="styles.css" rel="stylesheet" type="text/css" /></head>
3.10 +<body>
3.11 +<h1>Transaction Attributes</h1>
3.12 +<p>Sometimes, an application will process an incoming request using a number of different resource objects. For example, in the <a href="paths-filesystem.html">"Treating the Path Like a Filesystem"</a> document, an example is given which involves a number of <code>MapResource</code>
3.13 +objects arranged in a hierarchy, and whilst such objects are used
3.14 +merely to select other resources which are then used to provide some
3.15 +kind of output, there may be other situations where such objects may
3.16 +need to record some information about their activities, so that the
3.17 +output-producing resource may customise the output accordingly.</p><p>In the example mentioned above, let
3.18 +us consider the effect of replacing the special mapping from explicitly
3.19 +specified year numbers with a new resource object that recognises
3.20 +year numbers and dispatches requests to other resources:</p><pre>news_resource = YearResource({"document.html" : document_resource, "article.html" : article_resource})<br />documents_resource = MapResource({"news" : news_resource})<br />top_resource = MapResource({"documents" : documents_resource})</pre><p>What <code>YearResource</code> objects would do is to take the year number from the URL (see <a href="paths.html">"URLs and Paths"</a>)
3.21 +and then to match a name in the dictionary it was initialised with, in
3.22 +order to dispatch the transaction to a suitable resource. However, it
3.23 +is likely that the year number is important to such resources: we would
3.24 +expect to see a different Web page for <code>document.html</code> in <code>2005</code> than in <code>2004</code>, for example. Consequently, the <code>YearResource</code> needs a way to communicate such information to other resources.</p><p>Although we could provide special methods or change the parameters of the <code>respond</code> method in the <code>document_resource</code> and <code>article_resource</code>
3.25 +objects in order to create a "channel" through which year information
3.26 +could be passed, an alternative is to retain the existing interface and
3.27 +behaviour of those objects and to store such information in the
3.28 +transaction object itself. Since the transaction is essential in
3.29 +the processing of any incoming request, we can be certain that it will
3.30 +be available to store and to provide such information when necessary. </p><h2>Using Transaction Attributes</h2>
3.31 +<p>We may obtain the attributes from the transaction by performing a method call as follows:</p><pre> # In the respond method...<br /> attributes = trans.get_attributes()</pre><p>This
3.32 +will provide a dictionary mapping names to attribute values. The
3.33 +structure of the values is not strictly defined, and it is the
3.34 +application's role to enforce its own rules on the data stored in the
3.35 +attributes dictionary.</p><p>Setting and getting values is as straightforward as using a normal dictionary:</p>
3.36 +<pre> # Continuing from above...<br /> attributes["year"] = year<br /> # Later...<br /> if attributes.has_key("year"):<br /> year = attributes["year"]<br /></pre><p>As described in the <a href="../apidocs/public/WebStack.Generic.Transaction-class.html#get_attributes">API documentation</a>,
3.37 +the attributes dictionary exists as long as the transaction object
3.38 +itself. Should information need to be stored beyond the lifetime of a
3.39 +transaction, the appropriate persistent information facilities should
3.40 +be used instead - see <a href="sessions.html">"Sessions and Persistent Information"</a> for more details.</p></body></html>
3.41 \ No newline at end of file
4.1 --- a/docs/developing.html Mon Nov 21 12:59:14 2005 +0000
4.2 +++ b/docs/developing.html Fri Nov 25 16:51:54 2005 +0000
4.3 @@ -71,7 +71,7 @@
4.4 </ul><li><a href="users.html">Users and Authentication</a> (<code>Auth</code> example)</li>
4.5
4.6
4.7 - </ul>
4.8 + </ul><li><a href="attributes.html">Transaction Attributes</a></li>
4.9
4.10 </ul><li><a href="securing.html">Securing a WebStack Application</a></li><ul><li><a href="authenticators.html">Application-Wide Authenticators</a></li><li><a href="login-redirect.html">LoginRedirect and Login Modules</a> (<code>SimpleWithLogin</code> example, <code>Login</code> example)</li></ul><li><a href="integrating.html">Integrating with Other Systems</a></li>
4.11 </ul><p>The following topic is referenced in many locations and should
5.1 --- a/packages/ubuntu-hoary/python2.4-webstack/debian/changelog Mon Nov 21 12:59:14 2005 +0000
5.2 +++ b/packages/ubuntu-hoary/python2.4-webstack/debian/changelog Fri Nov 25 16:51:54 2005 +0000
5.3 @@ -7,6 +7,8 @@
5.4 Repositories package.
5.5 * Added get_path_without_info, update_path and redirect
5.6 methods to the Transaction class.
5.7 + * Added get_attributes (attribute support) to the
5.8 + Transaction class.
5.9 * Added a values method to Helpers.Session.Wrapper.
5.10 * Improved/fixed exception handling in the adapters so
5.11 that transactions are committed as the final act of an