[Zodb-checkins] [Checkins] SVN: ZODB/trunk/src/ZODB/ As a small convenience (mainly for tests), you can now specify

Christian Theune ct at gocept.com
Fri Dec 19 02:29:44 EST 2008


On Thu, 2008-12-18 at 14:08 -0500, Jim Fulton wrote:
> Log message for revision 94174:
>   As a small convenience (mainly for tests), you can now specify
>   initial data as a string argument to the Blob constructor.
>   
> 
> Changed:
>   U   ZODB/trunk/src/ZODB/blob.py
>   U   ZODB/trunk/src/ZODB/tests/blob_basic.txt
> 
> -=-
> Modified: ZODB/trunk/src/ZODB/blob.py
> ===================================================================
> --- ZODB/trunk/src/ZODB/blob.py	2008-12-18 19:08:07 UTC (rev 94173)
> +++ ZODB/trunk/src/ZODB/blob.py	2008-12-18 19:08:08 UTC (rev 94174)
> @@ -63,12 +63,14 @@
>  
>      readers = writers = None
>  
> -    def __init__(self):
> +    def __init__(self, data=None):
>          # Raise exception if Blobs are getting subclassed
>          # refer to ZODB-Bug No.127182 by Jim Fulton on 2007-07-20
>          if (self.__class__ is not Blob):
>              raise TypeError('Blobs do not support subclassing.')
>          self.__setstate__()
> +        if data is not None:
> +            self.open('w').write(data)

Something I'm never sure about: how long will this leave the file handle
open and let the blob stay in 'already opened' mode?

I wonder whether closing the file explicitly would be a good idea here.


-- 
Christian Theune · ct at gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1
Zope and Plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zodb-checkins/attachments/20081219/0063dd5d/attachment.bin 


More information about the Zodb-checkins mailing list