253 def __isAllowedImage(self, imageLimits, imageProperty):
257 if isinstance(imageLimits, MediaLimitsHandler.ImageLimits)
and \
258 isinstance(imageProperty, MediaLimitsHandler.ImageProperty):
260 if imageProperty.width
is not None and imageLimits.maxWidth
is not None and \
261 int(imageProperty.width) > int(imageLimits.maxWidth):
262 raise Exception(
"Parameter 'width' has not allowed value: %s > %s" % \
263 (str(imageProperty.width), str(imageLimits.maxWidth)))
265 if imageProperty.width
is not None and imageLimits.minWidth
is not None and \
266 int(imageProperty.width) < int(imageLimits.minWidth):
267 raise Exception(
"Parameter 'width' has not allowed value: %s < %s" % \
268 (str(imageProperty.width), str(imageLimits.minWidth)))
270 if imageProperty.height
is not None and imageLimits.maxHeight
is not None and \
271 int(imageProperty.height) > int(imageLimits.maxHeight):
272 raise Exception(
"Parameter 'height' has not allowed value: %s > %s" % \
273 (str(imageProperty.height), str(imageLimits.maxHeight)))
275 if imageProperty.height
is not None and imageLimits.minHeight
is not None and \
276 int(imageProperty.height) < int(imageLimits.minHeight):
277 raise Exception(
"Parameter 'height' has not allowed value: %s < %s" % \
278 (str(imageProperty.height), str(imageLimits.minHeight)))
280 if imageProperty.ratio
is not None and imageLimits.maxRatio
is not None and \
281 float(imageProperty.ratio) > float(imageLimits.maxRatio):
282 raise Exception(
"Parameter 'ratio' has not allowed value: %s > %s" % \
283 (str(imageProperty.ratio), str(imageLimits.maxRatio)))
285 if imageProperty.ratio
is not None and imageLimits.minRatio
is not None and \
286 float(imageProperty.ratio) < float(imageLimits.minRatio):
287 raise Exception(
"Parameter 'ratio' has not allowed value: %s < %s" % \
288 (str(imageProperty.ratio), str(imageLimits.minRatio)))
290 if imageProperty.colors
is not None and imageLimits.minColors
is not None and \
291 int(imageProperty.colors) < int(imageLimits.minColors):
292 raise Exception(
"Parameter 'colors' has not allowed value: %s < %s" % \
293 (str(imageProperty.colors), str(imageLimits.minColors)))
295 if imageProperty.format
is not None and imageLimits.contentType
is not None and \
296 isinstance(imageProperty.format, basestring)
and isinstance(imageLimits.contentType, list):
297 if not imageProperty.format.lower()
in \
298 [contentTypeName.lower()
for contentTypeName
in imageLimits.contentType]:
299 raise Exception(
"Parameter 'format' = '%s' has not allowed value by '%s' = %s" % \
300 (str(imageProperty.format),
301 str(MediaLimitsHandler.ImageLimits.propertyNamesDict[
'contentType']),
302 str(imageLimits.contentType)))
304 except Exception, err:
305 logger.debug(
"%s", str(err))