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

abhishek dastidar abhi at littlewiki.in
Sun Nov 30 15:03:53 EST 2008


OK, Since my object is just another object in the zodb. I can access
the object via aq. I implemented methods to add and delete items in my
OOBTree.That solved my problem for now.

That was pretty obvious! Any suggestions?

Regards,
Abhi

On 12/1/08, abhishek dastidar <abhi at littlewiki.in> wrote:
> 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
>


More information about the Zope-Dev mailing list