How to delete an object given a path in Zope
- From: Tres Seaver <tseaver (at) palladion.com>
- Date: Wed, 15 Mar 2006 11:47:56 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Takahashi, Michael wrote:
> Hi Suresh,
>
> 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')
> id = obj.getId()
> context.webcasts.courses.2005-2006.manage_delObjects(id)
>
> Python complains about the '-' in 2005-2006 on the third line. So my
> thought was that if you had the object reference you could somehow
> delete that reference like so:
>
>
> obj = context.restrictedTraverse('webcasts/courses/2005-2006/temp')
> id = obj.getId()
> obj.manage_delObjects(id)
>
>
> This however does not work. It gives the following error:
>
> Error Type
> AttributeError
> Error Value
> 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')
Tres.
- --
===================================================================
Tres Seaver +1 202-558-7113 tseaver (at) palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEGEU8+gerLs4ltQ4RAqdkAJ98DJYKXeQShR9b/4wIDzo87+b8OACePtFV
JL7HFDOImAsY981oadBlxys=
=HQZA
-----END PGP SIGNATURE-----
_______________________________________________
Zope-Dev maillist - Zope-Dev (at) zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )