[Zope] (more on) programatically adding ZClass instances ...

Darran Edmundson Darran.Edmundson@anu.edu.au
Tue, 23 Nov 1999 13:00:35 +1100


I am slowly coming to grips with using external methods
to reach into the ZODB.  Right now, I am trying to
create an instance of a folderish ZClass and then
populate it with (pre-existing) images from elsewhere
in the ZODB.  (The following URL has been very helpful
http://www.zope.org/Members/tazzzzz/addZClasses.)


Excerpts of my external method:

  # create an instance of MyClass
 
container=parent.Control_Panel.Products.MyProduct.MyClass(container_id)

  # make container a child object of parent
  parent._setObject(container_id, container)

  # set various attributes of container
  container.id = container_id
  container.foo = foobar

  # assume image points to a proper ZClass Image
  container.manage_addImage(image.id, image.data, '')


A few questions:

*) The final manage_addImage call occassionally fails
   with a seek error on image.data.  

   <!--
     Error type:  AttributeError
     Error value: seek
   -->
   File /usr/local2/Zope/lib/python/OFS/Image.py, line 265, in
_read_data
      (Object: default_image)
   AttributeError: (see above)

   I have verified that image is a valid Image and that:

   repr(image) = <Image instance at 8551e90>
   len(image.data) = 13611
   type(image.data) = <extension class
Acquisition.ImplicitAcquirerWrapper at 40160680>
   repr(image.content_type) = 'image/jpeg'

   Can someone offer advice as to why my read of image.data
   fails?


*) What happens to container if I *don't* execute
   parent._setObject(container_id, container)?  Doing
   this, I notice that the size of Data.fs does not
   increase (before running external method compard to
   after).  Does this mean that Zope has somehow
   recognized that container doesn't have a parent and
   deleted it?  I'm worried that I could corrupt my
   database during development of external methods that
   create/delete/manipulate the ZODB.

Cheers,
Darran.

-- 
Darran Edmundson [Darran.Edmundson@anu.edu.au]