[ZODB-Dev] BTrees and Mutables, was Re: [IndexedCatalog] bug in default indexing

Casey Duncan casey@zope.com
Tue, 11 Feb 2003 15:03:45 -0500


An alternative which is perhaps more palatable is to just set the whole=20
mutable object into the btree again. Like:

l =3D tree['bar']
l.append(4)
tree['bar'] =3D l # Trigger list persistance

hth,

Casey

On Tuesday 11 February 2003 02:49 pm, Christian Reis wrote:
> Crossposting to ZODB-dev to try and get the Wizards<tm>' help!
>=20
> On Tue, Feb 11, 2003 at 02:12:10PM -0500, Nicholas Henke wrote:
> > Is it possible that the index._p_changed in index_item is not telling
> > index which is a Btree derivative that index[value] has changed. Woul=
d
> > it make more sense to set index[value]._p_changed =3D 1 instead, or i=
n
> > conjunction with index._p_changed =3D 1?
>=20
> I've had a look at these issues in the past and my limited understandin=
g
> *is* the following:
>=20
>     - BTrees themselves are mutable objects. However, since they are
>       first-class Python instances, and because they have "magic"
>       properties, there is no requirement to set _p_changed=3D1 with ho=
lding
>       a reference to a changed BTree. I.E.:
>=20
>         tree =3D BTree()
>         obj.tree =3D tree
>         tree['foo'] =3D 'foo'
>         # obj has _p_changed set *magically*
>=20
>     At least this is what I understand from
>     http://www.zope.org/Members/ajung/BTrees/FrontPage=20
>=20
>     Am I wrong?
>=20
>     - If a BTree holds a reference to a non-BTree *mutable* type such a=
s
>       a list, and that list changes, then the *BTree itself* needs to
>       have _p_changed set. I.E.:
>=20
>         # Continuing from the above example, with obj.tree =3D tree
>         tree['bar'] =3D [1,2,3]
>         tree['bar'].append(4)
>         tree._p_changed =3D 1
>=20
>     Now my question is, really, this: does obj, who holds the BTree
>     reference, also require _p_changed to be set, or does the BTree's
>     magic notify the ZODB that obj needs to be saved, too? IOW:
>=20
>         # Do we also need this?
>         obj._p_changed =3D 1=20
>=20
> Take care,
> --
> Christian Reis, Senior Engineer, Async Open Source, Brazil.
> http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
>=20
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>=20
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://mail.zope.org/mailman/listinfo/zodb-dev
>=20