# HG changeset patch # User paulb # Date 1163720410 0 # Node ID d7000fde266adda741268ff3f2500ef34c5990d8 # Parent 6621024fa2a7ecd51cb94c8ea2506de1b2e9fcac [project @ 2006-11-16 23:40:10 by paulb] Added rollback method implementations. diff -r 6621024fa2a7 -r d7000fde266a WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Thu Nov 16 23:39:56 2006 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Thu Nov 16 23:40:10 2006 +0000 @@ -103,6 +103,18 @@ self.trans.end_headers() self.trans.wfile.write(content) + def rollback(self): + + """ + A special method, partially synchronising the transaction with + framework-specific objects, but discarding previously emitted content + that is to be replaced by an error message. + """ + + self.content = StringIO() + self.headers_out = {} + self.cookies_out = SimpleCookie() + # Server-related methods. def get_server_name(self): diff -r 6621024fa2a7 -r d7000fde266a WebStack/CGI.py --- a/WebStack/CGI.py Thu Nov 16 23:39:56 2006 +0000 +++ b/WebStack/CGI.py Thu Nov 16 23:40:10 2006 +0000 @@ -100,6 +100,18 @@ self.content.seek(0) self.output.write(self.content.read()) + def rollback(self): + + """ + A special method, partially synchronising the transaction with + framework-specific objects, but discarding previously emitted content + that is to be replaced by an error message. + """ + + self.content = StringIO() + self.headers_out = {} + self.cookies_out = SimpleCookie() + # Server-related methods. def get_server_name(self): diff -r 6621024fa2a7 -r d7000fde266a WebStack/Django.py --- a/WebStack/Django.py Thu Nov 16 23:39:56 2006 +0000 +++ b/WebStack/Django.py Thu Nov 16 23:40:10 2006 +0000 @@ -60,6 +60,17 @@ self.content.seek(0) self.response.content = self.content.read() + def rollback(self): + + """ + A special method, partially synchronising the transaction with + framework-specific objects, but discarding previously emitted content + that is to be replaced by an error message. + """ + + self.response = HttpResponse() + self.content = StringIO() + # Server-related methods. def get_server_name(self): diff -r 6621024fa2a7 -r d7000fde266a WebStack/Generic.py --- a/WebStack/Generic.py Thu Nov 16 23:39:56 2006 +0000 +++ b/WebStack/Generic.py Thu Nov 16 23:40:10 2006 +0000 @@ -74,6 +74,16 @@ pass + def rollback(self): + + """ + A special method, partially synchronising the transaction with + framework-specific objects, but discarding previously emitted content + that is to be replaced by an error message. + """ + + pass + # Utility methods. def parse_header_value(self, header_class, header_value_str): diff -r 6621024fa2a7 -r d7000fde266a WebStack/WSGI.py --- a/WebStack/WSGI.py Thu Nov 16 23:39:56 2006 +0000 +++ b/WebStack/WSGI.py Thu Nov 16 23:40:10 2006 +0000 @@ -77,6 +77,18 @@ if self.session_store is not None: self.session_store.close() + def rollback(self): + + """ + A special method, partially synchronising the transaction with + framework-specific objects, but discarding previously emitted content + that is to be replaced by an error message. + """ + + self.content = StringIO() + self.headers_out = {} + self.cookies_out = SimpleCookie() + def get_wsgi_headers(self): wsgi_headers = []