[Zope] Programmatically deleting objects

Horak, Karl KEHORAK at sandia.gov
Wed Mar 24 17:47:09 EST 2004


Chris,

I've given up on using the ZMI's system of checkboxes named with object ids
and calling the manage_delObjects:method from a submit button.  Instead I'm
now simply generating a URL that passes a querystring with the path to the
item and the item name:  

<A HREF="goDelete?item=<dtml-var id>&delPath=<dtml-var
expr="aq_parent.aq_parent.id">.<dtml-var expr="aq_parent.id">">

Thus, I have two variables, delPath = 'ORDlibrary.BC' (or whichever
subfolder) is the container of the item to be deleted, item =
'filename.ext', which is the object's id.  

The goDelete method is some variation on:

<dtml-call expr="REQUEST.delPath.manage_delObjects([REQUEST.item])">
(This generates an AttributeError stating 'str' object has no attribute
'manage_delObjects')

Or:

<dtml-call
expr="_.getitem(REQUEST.delPath).manage_delObjects([REQUEST.item])">
(This generates a KeyError with an Error Value of 'ORDlibrary.BC')

The odd thing is that using explicit strings as you pointed out in your
suggestion works fine:
<dtml-call expr="ORDlibrary.BC.manage_delObjects([REQUEST.item])">

Why are literals working but not variables with string values?  

Finally, I've tried building the HREF as <A HREF="req?item=<dtml-var
id>&delPathA=<dtml-var expr="aq_parent.aq_parent.id">&delPathB=<dtml-var
expr="aq_parent.id">">, where goDelete now looks like:

<dtml-call
expr="_.getitem(REQUEST.delPathA)._.getitem(REQUEST.delPathB).manage_delObje
cts([REQUEST.item])">

This repeatedly asks for user ID and password (BTW, goDelete has its proxy
value set to Manager).  This is the equivalent of the "spinning Zope" in my
initial message.  When my server admin captured the 8080 packets, we saw
that the system was sending nothing acceptable for user ID/password and then
generating a 401 error and repeating this process infinitely.  Since this
occurs on my standalone development machine as well as the firewall-Zope
server production environment, it doesn't appear to be a virtual host/proxy
passing problem.  

That said, I find that calls to SquishDot management functions and Zope
manage_editProperties work on my testbed but not when they are moved onto
the firewalled system.  But that problem is for another day.  

Thanks in advance,

Karl

-----Original Message-----
From: Chris Withers [mailto:lists at simplistix.co.uk] 
Sent: Wednesday, March 24, 2004 6:32 AM
To: Horak, Karl; zope at zope.org
Subject: Re: [Zope] Programmatically deleting objects


(keep replies on the list)

Horak, Karl wrote:

> I think that Zope isn't correctly finding my target item and keeps calling
> manage_delObjects until the parameter list is empty, which never happens.


What's your evidence for this?

> For an item that is not in the same folder as my method for deletion, is
the
> correct syntax:
> 
> /ORDweb/ORDlibrary/BC.manage_delObjects(ids)
> (where ids is a list of a single object id)
> or
> /ORDweb/ORDlibrary/BC.manage_delObjects(/ORDweb/ORDlibrary/BC/ids) 
> or
> something else?

if ids contains the ids of items you want to delete, and those items are 
contained in BC, then you want:

ORDweb.ORDlibrary.BC.manage_delObjects(ids)

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk





More information about the Zope mailing list