[Zope] External Methods: Object behavior different in 2.4.2 ?

Doyon, Jean-Francois Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Tue, 30 Oct 2001 16:04:59 -0500


Hello,

I have an External Method that imports a module that in turn imports a
Python/C library ... (A SWIG'ified software with shadow classes).

This used to work fine in 2.4.1 ... But now in 2.4.2 I am having =
problems:

It seems I can only run it once! If I hit refresh or something like =
that, I
get the following error:

Traceback (innermost last):
  File /usr/local/Zope-2.4.2/lib/python/ZPublisher/Publish.py, line =
223, in
publish_module
  File /usr/local/Zope-2.4.2/lib/python/ZPublisher/Publish.py, line =
187, in
publish
  File /usr/local/Zope-2.4.2/lib/python/Zope/__init__.py, line 226, in
zpublisher_exception_hook
    (Object: Zope)
  File /usr/local/Zope-2.4.2/lib/python/ZPublisher/Publish.py, line =
171, in
publish
  File /usr/local/Zope-2.4.2/lib/python/ZPublisher/mapply.py, line 160, =
in
mapply
    (Object: drawmap)
  File /usr/local/Zope-2.4.2/lib/python/ZPublisher/Publish.py, line =
112, in
call_object
    (Object: drawmap)
  File
/usr/local/Zope-2.4.2/lib/python/Products/ExternalMethod/ExternalMethod.=
py,
line 274, in __call__
    (Object: drawmap)
    (Info: ((400, 340, 'left'), {}, (400, 340, 'left')))
  File /usr/local/Zope-2.4.2/Extensions/mapserver.py, line 6, in =
drawmap
  File /usr/lib/python2.1/mapscript.py, line 1041, in __setattr__
TypeError: Type error. Expected _p_mapObj

And on the console:

Exception exceptions.TypeError: 'Type error. Expected _p_mapObj' in =
<method
mapObj.__del__ of mapObj instance at 0x895bafc> ignored

Here is the code, it is short:

from mapscript import *
import tempfile

def drawmap(width=3D400,height=3D340,align=3D"left"):
        mymap =3D mapObj("/home/mapdata/nac/177.map")
        mymap.width =3D width
        mymap.height =3D height
        myimage =3D mymap.draw()
        oldtempdir =3D tempfile.tempdir
        tempfile.tempdir =3D ""
        mytempfile =3D tempfile.mktemp()
        tempfile.tempdir =3D oldtempdir
=20
msSaveImage(myimage,"/usr/local/apache/htdocs/tempimages/"+mytempfile,0,=
0,0,
0)
        return "<IMG SRC=3Dhttp://localhost/tempimages/"+mytempfile+"
ALIGN=3D"+align+" BORDER=3D0>"

Note the "mapObj" called "mymap" ... It does all the work.  From what I =
see
above, once the object is instanciated, there's a problem destroying =
it, or
instantiating a new one ... This might be why I get th error above.

Funny thing is this worked fine in 2.4.1 ... Is this a bug, or did some =
sort
of behavior change with 2.4.2? And if so how do I get around it?

I tried adding a "mymap =3D None" here and there to force the object to =
be
destroyed after/before use, but that didn't seem to help.

Any ideas?

Thanks in advance,

Jean-Fran=E7ois Doyon
Internet Service Development and Systems Support
GeoAccess Division
Canadian Center for Remote Sensing
Natural Resources Canada
http://atlas.gc.ca
Phone: (613) 992-4902
Fax: (613) 947-2410