[Zope-dev] Blob detection in the ZODB for bug 739692
David Glick
davidglick at groundwire.org
Tue Apr 26 11:30:27 EDT 2011
On 4/26/11 7:40 AM, William Heymann wrote:
> 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.
You can get (persistent object)._p_jar.db().storage and check if it
provides ZODB.interfaces.IBlobStorage.
----------
David Glick
Web Developer
davidglick at groundwire.org
206.286.1235x32
Groundwire: You Are Connected
http://groundwire.org
Online tools and strategies for the environmental movement. Sign up for Groundwire News!
http://groundwire.org/email-capture
More information about the Zope-Dev
mailing list