a clear method for grok.Container

Bug #315775 reported by Martijn Faassen
4
Affects Status Importance Assigned to Milestone
grok
Status tracked in 1.3
1.3
Confirmed
Low
trollfot

Bug Description

It'd be nice if grok.Container (or rather its Zope 3 base class) had a clear() method like Python dictionaries do. It'd also be nice if this was a reasonably efficient method, possibly by exposing the functionality on the underlying BTree that containers use.

Changed in grok:
assignee: nobody → faassen
importance: Undecided → Low
milestone: none → 1.1
Changed in grok:
status: New → Confirmed
Revision history for this message
trollfot (trollfot) wrote :

zope.app.container.btree.BTreeContainer is not inheriting from ZODB BTrees directly. In order to access the real btree data container, we have to go through the data container attribute (_SampleContainer__data). The BTree data container is a pure C object, it doesn't provide/implement anything, therefore it's impossible to test it against an interface.

I have a code working, with tests, for the "clear" method. The problem is : we would rely purely on the zope.container implementation and it's not good. Even more, zope.container.btree doesn't provide an object implementing a Btrees.Interfaces interface. Maybe we should make zope.container at least implementing Btrees.Interfaces.ICollection ? If not, we could, in Grok, provide a clean implementation that does really provide what we are expecting : a real BTrees.IBTree.

Revision history for this message
Martijn Faassen (faassen) wrote : Re: [Bug 315775] Re: a clear method for grok.Container

I'm not sure whether we are really expecting a real BTrees.IBTree? Is
IBTree an interface?

If there are improvements to the container to be done we should
explore doing so in zope.container. The _SampleContainer__data stuff
is ugly, so that'd be one more item for the wishlist. I'd also be very
nice to have a container that allowed people to override its __init__
without having to do a super call, if this can be done without too
much magic.

Revision history for this message
trollfot (trollfot) wrote :

yes, IBtree is an interface defines in BTrees.Interfaces.

Fixing the _SampleContainer__data would be great, though I'm unsure about its current status. It's still marked as being there for a backward compatibility.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.