FIx in sessions and added resize in imagefield
This commit is contained in:
parent
c23b650277
commit
e853124bf2
2 changed files with 30 additions and 0 deletions
|
|
@ -96,6 +96,16 @@ def generate_session(session={}):
|
|||
|
||||
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():
|
||||
|
||||
s={}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,26 @@ class ImageField(CharField):
|
|||
im.close()
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue