[Zope-dev] Editing an item stored inside a BTreeFolder

abhishek dastidar abhi at littlewiki.in
Sun Nov 30 13:59:44 EST 2008


Hi All,

I have until now learnt how to play around with BTreeFolder2.I have one
remaining doubt left.How do I edit an item that is stored inside a
BtreeFolder2? I added my own OOBTree objects inside and I would like to
manipulate the data inside the OOBTree. The only way I see is fetch the obj,
delete it and store the new one again. Any other way?

This is what I did:

...
            if self.userFolder in self.aq_parent.objectIds():
                pass
            else:


self.manage_addProduct['BTreeFolder2'].manage_addBTreeFolder(self.userFolder,'btf2
folder ')

            try:

                btf = self.userFolder
                uniq_id =  getattr(self.aq_parent, btf).generateId()

                obT = OOBStuff(uniq_id,{'a':1,'b':2})         #This is the
object I would like to edit later.
                getattr(self.aq_parent,btf)._setObject(uniq_id, obT)

                obtuff = getattr(self.aq_parent,
btf)._getOb('item399638579')
                testy = obtuff.return_Tree()

                ...

            finally:
                pass


class OOBStuff(BTreeFolder2):
      meta_type ='OOBStuff'
      def __init__(self, oid,dict_to_add):
         super(OOBStuff, self).__init__(oid)
         self.item = OOBTree()
         self.item['Auth'] = dict_to_add
      def return_Tree(self):
          return self.item


Here,I would like to edit(add more key:value pairs) to the OOBStuff object
that I had stored in the BTF2.

Regards,
Abhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-dev/attachments/20081201/98ff208a/attachment.html 


More information about the Zope-Dev mailing list