[Zope-dev] Re: How to delete an object given a path in Zope
Max M
maxm at mxm.dk
Wed Mar 15 15:26:28 EST 2006
Tres Seaver wrote:
> Takahashi, Michael wrote:
>>
>>I've actually tried that. The problem I run into is that the folder in
>>my path contains a dash. When I call manage_delObjects on the following:
>>
>>
>>obj = context.restrictedTraverse('webcasts/courses/2005-2006/temp')
>
> You need to get a reference to the container, and call
> 'manage_delObject' on it, e.g.:
>
> container = context.restrictedTraverse('webcasts/courses/2005-2006')
> container.manage_delObject('temp')
I usually just call aq_parent
obj = context.restrictedTraverse('webcasts/courses/2005-2006/temp')
container = obj.aq_parent
container.manage_delObject('temp')
If you are deleting a list of objects in different folders you need to
do a bit of tapdancing not to delete parents first. Like reverse sorting
on the length of the physical path.
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
Phone: +45 66 11 84 94
Mobile: +45 29 93 42 96
More information about the Zope-Dev
mailing list