From 566f0309020633dd76a1cb7e00a552143d559719 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 10 Sep 2012 17:29:41 -0500 Subject: [PATCH] stream allows for optional headers and fixed a formtyle bug, thanks Anthony --- VERSION | 2 +- gluon/globals.py | 5 +++-- gluon/sqlhtml.py | 15 ++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index a2c32e82..153c3046 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.8 (2012-09-10 11:34:33) stable +Version 2.0.8 (2012-09-10 17:29:35) stable diff --git a/gluon/globals.py b/gluon/globals.py index 5e94b726..dab102f2 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -278,7 +278,8 @@ class Response(Storage): chunk_size = DEFAULT_CHUNK_SIZE, request=None, attachment=False, - filename=None + filename=None, + headers=None ): """ if a controller function:: @@ -298,7 +299,7 @@ class Response(Storage): default to the last request argument otherwise) """ - headers = self.headers + headers = headers if headers is not None else self.headers # for attachment settings and backward compatibility keys = [item.lower() for item in headers] if attachment: diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index 88c1f5bf..4a7857df 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -1105,20 +1105,21 @@ class SQLFORM(FORM): self.components = [table] def createform(self, xfields): - if isinstance(self.formstyle, basestring): - if self.formstyle in SQLFORM.formstyles: - self.formstyle = SQLFORM.formstyles[self.formstyle] + formstyle = self.formstyle + if isinstance(formstyle, basestring): + if formstyle in SQLFORM.formstyles: + formstyle = SQLFORM.formstyles[formstyle] else: raise RuntimeError, 'formstyle not found' - if callable(self.formstyle): + if callable(formstyle): # backward compatibility, 4 argument function is the old style - args, varargs, keywords, defaults = inspect.getargspec(self.formstyle) + args, varargs, keywords, defaults = inspect.getargspec(formstyle) if defaults and len(args) - len(defaults) == 4 or len(args) == 4: table = TABLE() for id,a,b,c in xfields: raw_b = self.field_parent[id] = b - newrows = self.formstyle(id,a,raw_b,c) + newrows = formstyle(id,a,raw_b,c) if type(newrows).__name__ != "tuple": newrows = [newrows] for newrow in newrows: @@ -1126,7 +1127,7 @@ class SQLFORM(FORM): else: for id,a,b,c in xfields: self.field_parent[id] = b - table = self.formstyle(self, xfields) + table = formstyle(self, xfields) else: raise RuntimeError, 'formstyle not supported' return table