# HG changeset patch # User Paul Boddie # Date 1227213083 -3600 # Node ID 991f6ca7563b15205c368b181bfb19afd3f04a5f # Parent 87123838ebfdc413826ac89faca8975206f50952 Added a filename attribute to FileContent instances. Updated release notes. diff -r 87123838ebfd -r 991f6ca7563b README.txt --- a/README.txt Tue Nov 18 20:28:58 2008 +0100 +++ b/README.txt Thu Nov 20 21:31:23 2008 +0100 @@ -77,6 +77,8 @@ * Added AuthInfoSelector for the retrieval of authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, provided for file + upload parameters. New in WebStack 1.2.7 (Changes since WebStack 1.2.6) ---------------------------------------------------- diff -r 87123838ebfd -r 991f6ca7563b WebStack/Helpers/Request.py --- a/WebStack/Helpers/Request.py Tue Nov 18 20:28:58 2008 +0100 +++ b/WebStack/Helpers/Request.py Thu Nov 20 21:31:23 2008 +0100 @@ -225,11 +225,13 @@ Instances of this class contain the following attributes: - * stream - a stream object through which the content of an uploaded file - may be accessed - * content - a plain string containing the contents of the uploaded file - * headers - a dictionary containing the headers associated with the - uploaded file + * stream - a stream object through which the content of an uploaded file + may be accessed + * content - a plain string containing the contents of the uploaded file + * filename - a plain string containing the supplied filename of the + uploaded file + * headers - a dictionary containing the headers associated with the + uploaded file """ def __init__(self, stream, headers=None): @@ -246,20 +248,30 @@ def __getattr__(self, name): """ - Provides a property value when 'name' is specified as "content". + Provides a property value when 'name' is specified as "content" or as + "filename". """ - if name != "content": - raise AttributeError, name + if name == "content": - if self.cache is not None: - return self.cache + if self.cache is not None: + return self.cache - if self.reset(): - return self.stream.read() + if self.reset(): + return self.stream.read() + else: + self.cache = self.stream.read() + return self.cache + + elif name == "filename": + try: + content_disposition = self.headers["Content-Disposition"] + return content_disposition.filename + except (KeyError, AttributeError): + return None + else: - self.cache = self.stream.read() - return self.cache + raise AttributeError, name def reset(self): diff -r 87123838ebfd -r 991f6ca7563b examples/Common/Form/__init__.py --- a/examples/Common/Form/__init__.py Tue Nov 18 20:28:58 2008 +0100 +++ b/examples/Common/Form/__init__.py Thu Nov 20 21:31:23 2008 +0100 @@ -137,7 +137,8 @@ if type(value) not in (type(""), type(u"")): value.reset() - details = "%s of length %s: %s" % ( + details = "file %s of type %s with length %s: %s" % ( + value.filename, value.headers.get("content-type") or "No content type", value.headers.get("content-length") or "Unknown", repr(value.stream.read(20)) diff -r 87123838ebfd -r 991f6ca7563b packages/ubuntu-feisty/jython-webstack/debian/changelog --- a/packages/ubuntu-feisty/jython-webstack/debian/changelog Tue Nov 18 20:28:58 2008 +0100 +++ b/packages/ubuntu-feisty/jython-webstack/debian/changelog Thu Nov 20 21:31:23 2008 +0100 @@ -29,6 +29,8 @@ authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, + provided for file upload parameters. -- Paul Boddie Sat, 15 Nov 2008 02:27:03 +0100 diff -r 87123838ebfd -r 991f6ca7563b packages/ubuntu-feisty/python-webstack/debian/changelog --- a/packages/ubuntu-feisty/python-webstack/debian/changelog Tue Nov 18 20:28:58 2008 +0100 +++ b/packages/ubuntu-feisty/python-webstack/debian/changelog Thu Nov 20 21:31:23 2008 +0100 @@ -29,6 +29,8 @@ authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, + provided for file upload parameters. -- Paul Boddie Sat, 15 Nov 2008 02:26:43 +0100 diff -r 87123838ebfd -r 991f6ca7563b packages/ubuntu-gutsy/jython-webstack/debian/changelog --- a/packages/ubuntu-gutsy/jython-webstack/debian/changelog Tue Nov 18 20:28:58 2008 +0100 +++ b/packages/ubuntu-gutsy/jython-webstack/debian/changelog Thu Nov 20 21:31:23 2008 +0100 @@ -29,6 +29,8 @@ authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, + provided for file upload parameters. -- Paul Boddie Sat, 15 Nov 2008 02:27:03 +0100 diff -r 87123838ebfd -r 991f6ca7563b packages/ubuntu-gutsy/python-webstack/debian/changelog --- a/packages/ubuntu-gutsy/python-webstack/debian/changelog Tue Nov 18 20:28:58 2008 +0100 +++ b/packages/ubuntu-gutsy/python-webstack/debian/changelog Thu Nov 20 21:31:23 2008 +0100 @@ -29,6 +29,8 @@ authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, + provided for file upload parameters. -- Paul Boddie Sat, 15 Nov 2008 02:26:43 +0100 diff -r 87123838ebfd -r 991f6ca7563b packages/ubuntu-hoary/python2.4-webstack/debian/changelog --- a/packages/ubuntu-hoary/python2.4-webstack/debian/changelog Tue Nov 18 20:28:58 2008 +0100 +++ b/packages/ubuntu-hoary/python2.4-webstack/debian/changelog Thu Nov 20 21:31:23 2008 +0100 @@ -29,6 +29,8 @@ authentication details and ConditionalAuthSelector for conditional authentication to WebStack.Resources.Selectors. + * Added a filename attribute to FileContent instances, + provided for file upload parameters. -- Paul Boddie Sat, 15 Nov 2008 02:24:13 +0100