[Zope-dev] Blob detection in the ZODB for bug 739692

William Heymann kosh at aesaeion.com
Tue Apr 26 10:40:18 EDT 2011


I am working on a patch for Blob support in OFS.Image/File and I am running 
into a small problem. What is the correct way to detect if the current ZODB 
supports blobs?

If I just do

self.data = ZODB.blob.Blob(data)

in update_data in OFS.Image

and a system does not support blobs

I get this error

Traceback (innermost last):
  Module ZPublisher.Publish, line 134, in publish
  Module Zope2.App.startup, line 301, in commit
  Module transaction._manager, line 89, in commit
  Module transaction._transaction, line 329, in commit
  Module transaction._transaction, line 443, in _commitResources
  Module ZODB.Connection, line 563, in commit
  Module ZODB.Connection, line 619, in _commit
  Module ZODB.Connection, line 662, in _store_objects
Unsupported: Storing Blobs in <ZEO.ClientStorage.ClientStorage object at 
0x3248590> is not supported.

which does not even mention OFS.Image anywhere

I tried putting in

try:
    self.data = ZODB.blob.Blob(data)
except zExceptions.Unsupported:
    self.data = data

and this of course did not work since the error is not actually occurring 
here.

What I am trying to do is make is to that Blobs are used if blobs are 
supported and not used if they are not currently supported. For all of my 
systems this is not an issue since I only support blobs but for a patch to be 
accepeted it seems that it would need to work either way.

I considered putting in a configuration switch in zope.conf to say if blobs 
should be used or not so that it is up to the developer to set the switch and 
enable blob support and the system would just give errors if setup incorrectly 
but that does not seem like a good idea.


More information about the Zope-Dev mailing list