[ZODB-Dev] ZODB4 and DemoStorage

hazmat hazmat@objectrealms.net
Wed, 09 Apr 2003 00:00:49 +0200


Barry Warsaw wrote:

>On Tue, 2003-04-08 at 06:10, Marius Gedminas wrote:
>
>  
>
>>I'm trying to build a functional testing framework based on DemoStorage.
>>The docstring in demo.py suggests this is an intended use case:
>>    
>>
>
>Yes.  The other use case is fronting a read-only storage, say on a
>CDROM.
>
>  
>
>>Here's how I am trying to do it:
>>
>>  from zodb.db import DB
>>  from zodb.storage.mapping import MappingStorage
>>  from zodb.storage.demo import DemoStorage
>>
>>  base_storage = MappingStorage("Base")
>>     # maybe MemoryFullStorage would be a better choice?
>>    
>>
>
>MappingStorage is more like a MemoryMinimalStorage; neither supports
>undo or versions.  MemoryFullStorage as its name implies, supports the
>full storage interface.
>
>  
>
>>  db = DB(base_storage)
>>  ... bootstrap the DB (create root folder and essential services) ...
>>  db.close()
>>
>>  ... and for each functional test case do:
>>
>>    demo_storage = DemoStorage("Demo", base_storage)
>>    db = DB(demo_storage)
>>    ... do things with db ...
>>    db.close()
>>
>>I have some reservations about it.  Closing the DB also closes the
>>storage, 
>>    
>>
>
>Looking at the code, that's all db.close() does!
>
>  
>
>>and I am not sure you just pass the same storage to a new DB
>>instance as if nothing had happened.
>>    
>>
>
>Well, what if you just threw away the DB object without closing it?  I'm
>not 100% sure this is kosher, but it would be interesting to try. :)
>
i've done this, for setting up a temporary (memory) storage for sessions 
on a zeo server, for the same issue. just kept a reference to the 
storage, and let the db object go out of scope and get gc. works fine.

cheers,

-haz