From c4d1f3f4147505a1d1a8216eda83c0e43abf31cb Mon Sep 17 00:00:00 2001 From: Jonathan Vasek Date: Sun, 21 Feb 2016 00:19:49 -0600 Subject: [PATCH 1/3] Fixed a bug whereby calling 'delete_record()' on a row object caused an AttributeError. --- gluon/sqlhtml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index fd06b8d6..fac6ec8d 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2364,7 +2364,7 @@ class SQLFORM(FORM): if deletable(record): if ondelete: ondelete(table, request.args[-1]) - record.delete_record() + db(table[table._id.name] == request.args[-1]).delete() if request.ajax: # this means javascript is enabled, so we don't need to do # a redirect From d494ec9c8896ff55c41396567df94afd41a24d7e Mon Sep 17 00:00:00 2001 From: Chen Levy Date: Mon, 22 Feb 2016 14:13:02 +0200 Subject: [PATCH 2/3] fix invalid view for purly complied app When packing a compiled app, and distributing it without the non-compiled view views, run_view_in searches only the old style compiled view file: e.g. views_default_index.html.pyc and not in views.default.index.html.pyc, resulting in "invalid view (default/index.html)" 404 Exception. --- gluon/compileapp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gluon/compileapp.py b/gluon/compileapp.py index 68e993d9..84d47528 100644 --- a/gluon/compileapp.py +++ b/gluon/compileapp.py @@ -676,8 +676,8 @@ def run_view_in(environment): else: filename = pjoin(folder, 'views', view) if os.path.exists(path): # compiled views - x = view.replace('/', '_') - files = ['views_%s.pyc' % x] + x = view.replace('/', '.') + files = ['views.%s.pyc' % x] is_compiled = os.path.exists(pjoin(path, files[0])) # Don't use a generic view if the non-compiled view exists. if is_compiled or (not is_compiled and not os.path.exists(filename)): From 8058dc2ce6b12e71fd109b48ec9b8b2b2f09e6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Aramis=20Aguilar=20Rodr=C3=ADguez?= Date: Tue, 1 Mar 2016 20:24:28 -0600 Subject: [PATCH 3/3] Update imageutils.py Adding a padding statement into imageutils, the goal is to allow a padding transparent/white border on pictures when being resized in different aspect ratio. --- gluon/contrib/imageutils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gluon/contrib/imageutils.py b/gluon/contrib/imageutils.py index 1dd19795..2c241bb1 100644 --- a/gluon/contrib/imageutils.py +++ b/gluon/contrib/imageutils.py @@ -27,10 +27,10 @@ from gluon import current class RESIZE(object): - def __init__(self, nx=160, ny=80, quality=100, + def __init__(self, nx=160, ny=80, quality=100, padding = False error_message=' image resize'): - (self.nx, self.ny, self.quality, self.error_message) = ( - nx, ny, quality, error_message) + (self.nx, self.ny, self.quality, self.error_message, self.padding) = ( + nx, ny, quality, error_message, padding) def __call__(self, value): if isinstance(value, str) and len(value) == 0: @@ -41,7 +41,14 @@ class RESIZE(object): img = Image.open(value.file) img.thumbnail((self.nx, self.ny), Image.ANTIALIAS) s = cStringIO.StringIO() - img.save(s, 'JPEG', quality=self.quality) + if self.padding: + background = Image.new('RGBA', (self.nx, self.ny), (255, 255, 255, 0)) + background.paste( + img, + ((self.nx - img.size[0]) / 2, (self.ny - img.size[1]) / 2)) + background.save(s, 'JPEG', quality=self.quality) + else: + img.save(s, 'JPEG', queality=self.quality) s.seek(0) value.file = s except: