[Erp5-dev] ERP5/Document/Image.py cast to int patch

Łukasz Nowak lukasz.nowak at ventis.com.pl
Mon May 5 11:20:20 CEST 2008


Hello,

While playing with DMS, I run into problem on preview with
Presentations. There was traceback:

2008-05-05T11:11:52 ERROR Zope.SiteErrorLog http://localhost:8380/erp5/document_module/2/index_html
Traceback (most recent call last):
  File "/usr/lib/erp5/lib/python/ZPublisher/Publish.py", line 114, in publish
    request, bind=1)
  File "/usr/lib/erp5/lib/python/ZPublisher/mapply.py", line 88, in mapply
    if debug is not None: return debug(object,args,context)
  File "/usr/lib/erp5/lib/python/ZPublisher/Publish.py", line 40, in call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5OOo/Document/OOoDocument.py", line 190, in index_html
    mime, result = self.convert(format=format, display=display, **kw)
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5OOo/Document/OOoDocument.py", line 431, in convert
    mime, data = temp_image.convert(original_format, display=display)
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5/Document/Image.py", line 312, in convert
    image_size=image_size)
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5/Document/Image.py", line 449, in _makeDisplayPhoto
    image_size=image_size)
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5/Document/Image.py", line 439, in _getDisplayPhoto
    image_size=image_size))
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5/Document/Image.py", line 424, in _getDisplayData
    (width, height) = self._getAspectRatioSize(width, height)
  File "/home/shufla/work/erp5head/unit_test/Products/ERP5/Document/Image.py", line 460, in _getAspectRatioSize
    if height > img_height * width / img_width:
TypeError: unsupported operand type(s) for /: 'str' and 'int'

In this case width was passed as string (eg. '400') not a int (eg.
400). Casting solves this problem, patch attached.

Maybe it shall be done on higher level, but I dunno. :)

Regards,
Luke

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ERP5-Document-Image.py-cast-to-int.patch
Type: text/x-patch
Size: 756 bytes
Desc: not available
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080505/3cb8149e/attachment.bin>


More information about the Erp5-dev mailing list