[Zope] Traversal Issue (brain fart)

Paul Winkler pw_lists at slinkp.com
Wed Sep 17 12:51:28 EDT 2003


On Wed, Sep 17, 2003 at 12:08:41PM -0400, Richard Shebora wrote:
(snip)
> #02 CREATES INBOUND FOLDER IF NEEDED.
> folderid='INbound'
> foldertitle='Inbound Documents'
> try:
> 
> container.manage_addProduct['PropertyFolder'].manage_addPropertyFolder(folderid,
> foldertitle,'')

hmm, the indentation is screwy. I assume that is just an email cut/paste 
problem, or this script would never run at all.

>  print 'Inbox Folder '+folderid+' Created'
> except:
>  print 'Inbox Folder '+folderid+' Already Exists'

Note that this is very risky. YOu should find out what error
happens when the folder already exists, and catch only that error.
If anything else goes wrong you will hide it behind a misleading 
"Already exists" message.

(snip)
> #08 CREATES DOCUMENTS IN CURRENT TRADING PARTNER'S DOCUMENT FOLDER
>   if fields[0]=='ST':
>      DOCid=DOCtype+'-'+DOCindex
>      DOClocation = TPdocs[DOCtype]     # sets current folder
>      try:
> 
> DOClocation.manage_addProduct['PropertyFolder'].manage_addPropertyFolder(DOCid,DOCtitle,'')
>         print DOCid+' '+DOCtitle+' Created'
>      except:
>         print DOCid+' '+DOCtitle+' Already Exists'
> 
> 09 CREATE DOCUMENT SEGMENTS   # This is the goofy section that fails.
>   SEGlocation=context.DOCid          # sets current folder

Look at that last line. DOCid is a variable. 
You are asking context for something literally named "DOCid", 
when I think you want to ask for something whose name is the
value of DOCid. Be sure you understand the difference.

You already know one way to do this correctly in zope, 
since you do it numerous times elsewhere in the script ;-)

Also I doubt that context is where you want to look. Since
you just created the DOCid-named item in DOClocation, 
maybe that's where you should look for it.

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's HATEFUL RASPUTIN!
(random hero from isometric.spaceninja.com)



More information about the Zope mailing list