I am making a product that draws a graph in PIL and then saves the image as a GIF in a Zope ObjectManager. If the image doesn't exist it will be rendered and saved in the objectManager. When I run it the first time the image renders just nicely in a dmtl page. If I try to reload it, I get an error that says:: Error Type: Bad Request Error Value: The id "laeringsGraf" is invalid--it is already in use. ... File C:\zope23\lib\python\Products\ots_laering\ots_laeringLogic.py, line 207, in updateGraph (Object: laering) File C:\zope23\lib\python\Products\ots_laering\ots_laeringLogic.py, line 196, in _drawTriangle (Object: laering) File C:\zope23\lib\python\OFS\ObjectManager.py, line 272, in _setObject (Object: laering) File C:\zope23\lib\python\OFS\ObjectManager.py, line 147, in checkValidId (Object: laering) So it seems that the Image gets saved OK ... somewhere, but I cannot se the id via self.objectIds() which simply returns an empty tuple (). My object inherits ObjectManager, but it doesn't seem like the Image gets saved in it. I can see it in a dtml page like <dtml-var laeringsGraf> but apparantly it's saved somewhere else .... I'm completely baffled. I check for existance of the image like so:: def updateGraph(self): "Render graf if it doesn't exist" imageID = 'laeringsGraf' print 'objects:', self.objectIds() if imageID in self.objectIds(): # allready exists pass else: # doesnt exist, so render first time self._drawTriangle([150, 0, 0, 0], 10, 10) The following is the snippet of code that saves the image from PIL into the ObjectManager # save it in the ZODB outf = StringIO() im.save(outf, 'GIF') del im data = outf.getvalue() outf.close() imageID = 'laeringsGraf' self._setObject(imageID, OFS.Image.Image(imageID,'Lærings graf','')) self._getOb(imageID).update_data(data) Anybody's got a clue??? Please. Regard Max M
On Wed, 30 May 2001, [iso-8859-1] Max M�ller Rasmussen wrote:
Error Type: Bad Request Error Value: The id "laeringsGraf" is invalid--it is already in use. ... imageID = 'laeringsGraf' self._setObject(imageID, OFS.Image.Image(imageID,'L�rings graf','')) self._getOb(imageID).update_data(data)
I'm not sure. I got a similar behaviour once when I di osomething like this: _setObject('id', someclass('anotherid', '')) If I recoall correctly, I couldn't see neither of them with objectIds() but I couldn't add 'id' or 'anotherid' either. Or something like that. It certainly doesn't look like that's your problem... I don't know :)
Max Møller Rasmussen wrote:
I am making a product that draws a graph in PIL and then saves the image as a GIF in a Zope ObjectManager.
If the image doesn't exist it will be rendered and saved in the objectManager.
When I run it the first time the image renders just nicely in a dmtl page. If I try to reload it, I get an error that says::
Error Type: Bad Request Error Value: The id "laeringsGraf" is invalid--it is already in use. ...
The problem is that you are subclassing SimpleItem.Item and ObjectManager which are incompatible base classes. SimpleItem.Item defines its own objectIds method which *always* returns and empty tuple (because it is not a container). You should be able to safely loose this base class and all will be right with the world.
Anybody's got a clue??? Please.
Regard Max M
hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
On 30 May 2001 08:59:28 -0600, Casey Duncan wrote:
The problem is that you are subclassing SimpleItem.Item and ObjectManager which are incompatible base classes. SimpleItem.Item defines its own objectIds method which *always* returns and empty tuple (because it is not a container). You should be able to safely loose this base class and all will be right with the world.
Are you sure ObjectManager and Item are incompatible base classes? I've been using them together to get title_or_id from Item for objectManagers without any problem, and actually, the standard Zope Folder class uses both as well. I think the problem might be in the order of the base classes in the class declaration. I think that if you put ObjectManager before Item, it should work fine. However, I'm not sure if this the reason behind the problem Max was having. Cheers, Arkaitz.
participants (4)
-
Arkaitz -
Casey Duncan -
Erik Enge -
Max Møller Rasmussen