Merge branch 'master' of github.com:web2py/web2py
This commit is contained in:
commit
4b81f721ac
3 files changed
+14
-7
No files matched your search
+2
-2
@@ -676,8 +676,8 @@ def run_view_in(environment):
|
|||||||
else:
|
else:
|
||||||
filename = pjoin(folder, 'views', view)
|
filename = pjoin(folder, 'views', view)
|
||||||
if os.path.exists(path): # compiled views
|
if os.path.exists(path): # compiled views
|
||||||
x = view.replace('/', '_')
|
x = view.replace('/', '.')
|
||||||
files = ['views_%s.pyc' % x]
|
files = ['views.%s.pyc' % x]
|
||||||
is_compiled = os.path.exists(pjoin(path, files[0]))
|
is_compiled = os.path.exists(pjoin(path, files[0]))
|
||||||
# Don't use a generic view if the non-compiled view exists.
|
# 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)):
|
if is_compiled or (not is_compiled and not os.path.exists(filename)):
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ from gluon import current
|
|||||||
|
|
||||||
class RESIZE(object):
|
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'):
|
error_message=' image resize'):
|
||||||
(self.nx, self.ny, self.quality, self.error_message) = (
|
(self.nx, self.ny, self.quality, self.error_message, self.padding) = (
|
||||||
nx, ny, quality, error_message)
|
nx, ny, quality, error_message, padding)
|
||||||
|
|
||||||
def __call__(self, value):
|
def __call__(self, value):
|
||||||
if isinstance(value, str) and len(value) == 0:
|
if isinstance(value, str) and len(value) == 0:
|
||||||
@@ -41,7 +41,14 @@ class RESIZE(object):
|
|||||||
img = Image.open(value.file)
|
img = Image.open(value.file)
|
||||||
img.thumbnail((self.nx, self.ny), Image.ANTIALIAS)
|
img.thumbnail((self.nx, self.ny), Image.ANTIALIAS)
|
||||||
s = cStringIO.StringIO()
|
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)
|
s.seek(0)
|
||||||
value.file = s
|
value.file = s
|
||||||
except:
|
except:
|
||||||
|
|||||||
+1
-1
@@ -2364,7 +2364,7 @@ class SQLFORM(FORM):
|
|||||||
if deletable(record):
|
if deletable(record):
|
||||||
if ondelete:
|
if ondelete:
|
||||||
ondelete(table, request.args[-1])
|
ondelete(table, request.args[-1])
|
||||||
record.delete_record()
|
db(table[table._id.name] == request.args[-1]).delete()
|
||||||
if request.ajax:
|
if request.ajax:
|
||||||
# this means javascript is enabled, so we don't need to do
|
# this means javascript is enabled, so we don't need to do
|
||||||
# a redirect
|
# a redirect
|
||||||
|
|||||||
Reference in new issue
Block a user