[Zope] Best Class for Persistent, Ordered List

Chris McDonough chrism@zope.com
Sun, 28 Jul 2002 02:58:49 -0400


OOSet preserves order.

Here's a trick that will come in handy when you want to test this kind
of thing:

- cd to your Zope's lib/python directory
- invoke python (the version that you compiled Zope with)
- at the interactive prompt type "import Zope"

All the magic that happens at startup happens when you "import Zope",
so at that point you can try things interactively.  We'll do OOSet as
an example:

$ python
Python 2.2 (#1, May 12 2002, 22:12:18)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Zope
>>> from BTrees.OOBTree import OOSet
>>> set = OOSet()
>>> set.insert(1)
1
>>> set.insert(2)
1
>>> set.insert(10)
1
>>> set.insert(5)
1
>>> set
OOSet([1, 2, 5, 10])
>>> set.keys()
[1, 2, 5, 10]

See the Interfaces.py file in the BTrees package for BTrees
documentation.

HTH,

- C


----- Original Message -----
From: "Ross Boylan" <RossBoylan@stanfordalumni.org>
To: <zope@zope.org>
Cc: "Ross Boylan" <RossBoylan@stanfordalumni.org>
Sent: Sunday, July 28, 2002 1:02 AM
Subject: [Zope] Best Class for Persistent, Ordered List


> I want the semantics of python lists with persistence; in
particular,
> I want to be sure that if I put objects in the list I will later get
> them out in the same order.
>
> I have been using PersistentList, borrowed from somewhere, that is
> basically a regular list with a little persistence machinery
tickling
> added.
>
> I notice that there are BTree classes and related set classes, in
> particular OOSet.  Does anyone know if that preserves order?  From
the
> name and the test suite it looks as if it doesn't, even though it
has
> sequence semantics.  I've looked at the c source only enough to see
> the answer is not immediately obvious there!
>
> So will OOSet do what I want?  If not, is something else
appropriate?
>
> Thanks.
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>