[Zope] Inconsistant behavior (long)
David Mackay
mackay_d@bellsouth.net
Wed, 10 Apr 2002 23:20:22 -0500
I have a DTML object that calls an external method which returns an
image. It works correctly for some images, but not for others. I am
using Zope 2.5.0, python2.1.3 on Linux 2.4.18. I get the following
traceback when it doesn't work:
Zope
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: TypeError
Error Value: argument 2 must be string or read-only buffer, not
ImplicitAcquirerWrapper
Troubleshooting Suggestions
* The URL may be incorrect.
* The parameters passed to this resource may be incorrect.
* A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML
source for this page.
If the error persists please contact the site maintainer. Thank you for
your patience.
Powered by Zope
Traceback (innermost last):
File ZPublisher/Publish.py, line 150, in publish_module
File ZPublisher/Publish.py, line 114, in publish
File Zope/__init__.py, line 158, in zpublisher_exception_hook
(Object: FAS)
File ZPublisher/Publish.py, line 98, in publish
File ZPublisher/mapply.py, line 88, in mapply
(Object: makeimage)
File ZPublisher/Publish.py, line 39, in call_object
(Object: makeimage)
File Products/ExternalMethod/ExternalMethod.py, line 202, in __call__
(Object: makeimage)
(Info: ((<Folder instance at 8915fb0>, <h3>form</h3><table><tr
valign="top"
align="left"><th>original_id</th><td>'FAS001908_png'</td></tr><tr
valign="top" align="left"><th>percentage</th><td>'25'</td></tr><tr
valign="top"
align="left"><th>rotation</th><td>'90'</td></tr></table><h3>cookies</h3><table><tr
valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr></table><h3>lazy
items</h3><table><tr valign="top"
align="left"><th>SESSION</th><td><Python Method object at
0x8279378></td></tr></table><h3>other</h3><table><tr valign="top"
align="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr
valign="top" align="left"><th>percentage</th><td>'25'</td></tr><tr
valign="top" align="l
eft"><th>rotation</th><td>'90'</td></tr><tr valign="top"
align="left"><th>PUBLISHED</th><td><ExternalMethod instance at
888c430></td></tr><tr valign="top"
align="left"><th>original_id</th><td>'FAS001908_png'</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>'http://localhost:8080/InsuranceLiquidators/FAS/makeimage'</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>'http://localhost:8080/InsuranceLiquidators/FAS'</td></tr><tr
valign="top"
align="left"><th>URL2</th><td>'http://localhost:8080/InsuranceLiquidators'</td></tr><tr
valign="top"
align="left"><th>BASE1</th><td>'http://localhost:8080'</td></tr><tr
valign="top"
align="left"><th>BASE0</th><td>'http://localhost:8080'</td></tr><tr
valign="top"
align="left"><th>URL1</th><td>'http://localhost:8080/InsuranceLiquidators/FAS'</td></tr><tr
valign="top"
align="left"><th>SERVER_URL</th><td>'http://localhost:8080'</td></tr><tr
valign="top"
align="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr><tr
valign="top"
align="left"><th>URL</th><td>'http://localhost:8080/InsuranceLiquidators/FAS/makeimage'</td></tr><tr
valign="top"
align="left"><th>AUTHENTICATED_USER</th><td>admin</td></tr><tr
valign="top"
align="left"><th>URL3</th><td>'http://localhost:8080'</td></tr><tr
valign="top"
align="left"><th>TraversalRequestNameStack</th><td>[]</td></tr><tr
valign="top"
align="left"><th>BASE2</th><td>'http://localhost:8080/InsuranceLiquidators'</td></tr><tr
valign="top"
align="left"><th>BASE4</th><td>'http://localhost:8080/InsuranceLiquidators/FAS/makeimage'</td></tr><tr
valign="top"
align="left"><th>URL0</th><td>http://localhost:8080/InsuranceLiquidators/FAS/makeimage</td></tr><tr
valign="top"
align="left"><th>URL1</th><td>http://localhost:8080/InsuranceLiquidators/FAS</t
d></tr><tr valign="top"
align="left"><th>URL2</th><td>http://localhost:8080/InsuranceLiquidators</td></tr><tr
valign="top"
align="left"><th>URL3</th><td>http://localhost:8080</td></tr><tr
valign="top"
align="left"><th>BASE0</th><td>http://localhost:8080</td></tr><tr
valign="top"
align="left"><th>BASE1</th><td>http://localhost:8080</td></tr><tr
valign="top"
align="left"><th>BASE2</th><td>http://localhost:8080/InsuranceLiquidators</td></tr><tr
valign="top"
align="left"><th>BASE3</th><td>http://localhost:8080/InsuranceLiquidators/FAS</td></tr><tr
valign="top"
align="left"><th>BASE4</th><td>http://localhost:8080/InsuranceLiquidators/FAS/makeimage</td></tr></table><h3>environ</h3><table><tr
valign="top" align="left"><th>SCRIPT_NAME</th><td>''</td></tr><tr
valign="top" align="left"><th>HTTP_ACCEPT_ENCODING</th><td>'gzip,
deflate, compress;q=0.9'</td></tr><tr valign="top"
align="left"><th>SERVER_PORT</th><td>'8080'</td></tr><tr valign="top"
align="left"><th>PATH_TRANSLATED</th><td>'/InsuranceLiquidators/FAS/makeimage'</td></tr><tr
valign="top"
align="left"><th>HTTP_ACCEPT</th><td>'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1'</td></tr><tr
valign="top"
align="left"><th>GATEWAY_INTERFACE</th><td>'CGI/1.1'</td></tr><tr
valign="top" align="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'en-us,
en;q=0.50'</td></tr><tr valign="top"
align="left"><th>REMOTE_ADDR</th><td>'127.0.0.1'</td></tr><tr
valign="top"
align="left"><th>SERVER_NAME</th><td>'vorpal.macdev.com'</td></tr><tr
valign="top" align="left"><th>HTTP_USER_AGENT</th><td>'Mozilla/5.0 (X11;
U; Linux i686; en-US; rv:0.9.9) Gecko/20020313'</td></tr><tr
valign="top" align="left"><th>HTTP_ACCEPT_CHA
RSET</th><td>'ISO-8859-1, utf-8;q=0.66, *;q=0.66'</td></tr><tr
valign="top"
align="left"><th>CONNECTION_TYPE</th><td>'keep-alive'</td></tr><tr
valign="top"
align="left"><th>channel.creation_time</th><td>1018477697</td></tr><tr
valign="top"
align="left"><th>QUERY_STRING</th><td>'original_id=FAS001908_png&percentage=25&rotation=90'</td></tr><tr
valign="top"
align="left"><th>SERVER_PROTOCOL</th><td>'HTTP/1.1'</td></tr><tr
valign="top" align="left"><th>HTTP_KEEP_ALIVE</th><td>'300'</td></tr><tr
valign="top"
align="left"><th>HTTP_HOST</th><td>'localhost:8080'</td></tr><tr
valign="top" align="left"><th>REQUEST_METHOD</th><td>'GET'</td></tr><tr
valign="top"
align="left"><th>PATH_INFO</th><td>'/InsuranceLiquidators/FAS/makeimage'</td></tr><tr
valign="top" align="left"><th>SERVER_SOFTWARE</th><td>'Zope/(Zope 2.5.0
(source release, python 2.1, linux2), python 2.1.3, linux2)
ZServer/1.1b1'</td></tr><tr valign="top"
align="left"><th>HTTP_COOKIE</th><td>'tree-s="eJyLjlZ3hANPW/XYWAAtiQTP"'</td></tr><tr
valign="top"
align="left"><th>HTTP_REFERER</th><td>'http://localhost:8080/InsuranceLiquidators/FAS/DisplayImage?original_id=FAS001908_png&percentage=25&rotation=90'</td></tr></table>,
ZServerHTTPResponse('')), {}, None))
File /usr/local/src/Zope-2.5.0-src/Extensions/makeimage.py, line 20,
in makeimage
(Object: FAS)
TypeError: (see above)
The DTML DisplayImage source is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Image</TITLE>
</HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red
(active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#0000FF"
ALINK="#FF0000"
>
<form action="processimagecontrols">
<input type="hidden" name="original_id" value="<dtml-var original_id>">
<input type="hidden" name="rotation" value="<dtml-var rotation>">
<input type="image" name="prev" value="prev" SRC="Icons/left-arrow_png">
<input type="image" name="left" value="left" SRC="Icons/button_undo_png">
<input type="image" name="zoom" value="zoom"
SRC="Icons/button_replace_png">
<input type="text" name="percentage" size="3" maxlength="3"
value="<dtml-var percentage>">
<input type="image" name="right" value="right"
SRC="Icons/button_redo_png">
<input type="image" name="next" value="right"
SRC="Icons/right-arrow_png">
<dtml-var original_id>
rotation <dtml-var rotation>
</form>
<script language="JavaScript">
Sheight = window.innerHeight - 50;
Swidth = window.innerWidth;
document.write('<iframe scrolling=yes
src="makeimage?original_id=<dtml-var original_id>&percentage=<dtml-var
percentage>&rotation=<dtml-var rotation>" name="Image Frame" height="' +
Sheight + '" width="' + Swidth + '">');
</script>
<!-- <iframe scrolling=yes src="makeimage?original_id=<dtml-var
original_id>&percentage=<dtml-var percentage>&rotation=<dtml-var
rotation>" name="Image Frame" height="600">" width="640">"> -->
</iframe>
</HTML>
The makeimage.py source is:
def makeimage(self, REQUEST, RESPONSE):
"""
Resizes and rotates the image given by original_id when
in the Images folder based on percentage and rotation.
The new image will be returned as a mime object.
"""
import _PyMagick
original_id = REQUEST['original_id']
percentage = long(REQUEST['percentage'])
rotation = long(REQUEST['rotation'])
# Get the original image data
Stuff=self.ZopeFind(self.Images,obj_metatypes=['Image'],obj_ids=[original_id])
if len(Stuff)==0:return
iobject=Stuff[0][1]
img = _PyMagick.getzimage(original_id,iobject.data,len(iobject.data))
if percentage>100:percentage=100
if percentage!=100:
factor = percentage/100.
nrows=long(img.rows*factor)
ncols=long(img.columns*factor)
sw = img.Resize(nrows,ncols,0,1.0)
else:sw=img
if rotation!=0:ri=sw.Rotate(float(rotation))
else:ri=sw
x = ri.ImageToBlob()
RESPONSE.setHeader('Content-Type','image/png')
RESPONSE.setHeader('Content-Length',len(x))
del(img)
del(sw)
return x
If anyone has any suggestions, I'd appreciate them.
Thanks,
Dave