FIx in sessions and added resize in imagefield

This commit is contained in:
Antonio de la Rosa 2017-06-14 02:08:54 +02:00
parent c23b650277
commit e853124bf2
2 changed files with 30 additions and 0 deletions

View file

@ -96,6 +96,16 @@ def generate_session(session={}):
return s return s
def regenerate_session():
token=create_key(30).replace('/', '#')
s={'token': token}
response.set_cookie(config.cookie_name, token, path=config.session_opts['session.path'])
return ParamecioSession(s)
def get_session(): def get_session():
s={} s={}

View file

@ -128,6 +128,26 @@ class ImageField(CharField):
im.close() im.close()
return "" return ""
if 'resize' in self.sizes:
height_t=0
width_t=0
if real_height<=self.sizes['resize'][1]:
height_t=self.sizes['resize'][1]
if real_width>self.sizes['resize'][0]:
width_t=self.sizes['resize'][0]
if height_t==0:
ratio=(real_width/width_t)
height_t=round(real_height/ratio)
size=(width_t, height_t)
if width_t>0 and height_t>0:
im.thumbnail(size, self.default_quality_thumb)
format_image=im.format format_image=im.format