[Zope] newbie question - Adding properties during an import using fsimpo rt rt

STEVENS,JEFF (HP-FtCollins,ex1) jeff_stevens@hp.com
Fri, 7 Jan 2000 15:50:04 -0700


I am importing a large number of files into Zope using fsimport. I would
like to add a property 'foo' to each new DTMLDocument that is imported from
the file system.  I have tried to do this in the code immediately following
the call to manage_addDTMLDocument (name, '', data), but I have been
unsuccessful.

The problem I am having is that I don't understand how to get the
DTMLDocument object that was just added to the folder so I can call
manage_addProperty on it.  Below is a snippet of the fsimport.py code that I
was trying to do this in.

I have a feeling that the solution is pretty obvious, but so far it escapes
me.  Thanks for any help you could provide.

Jeff

def rcimport(fsdir, obdir):
    filenames=os.listdir(fsdir)
    for name in filenames:
        pathname=os.path.join(fsdir, name)
        
        if name[0] in ('.', '#', '_'):
            continue

        if name[-1] in ('~',):
            continue

        elif os.path.isfile(pathname):
            if _isdoc(pathname):
                file=open(pathname, 'r')
                data=file.read()
                file.close()
                obdir.manage_addDTMLDocument(name, '', data)
            elif _isimg(pathname):
                file=open(pathname, 'rb')
                data=file.read()
                file.close()
                obdir.manage_addImage(name, data)

            else:
                file=open(pathname, 'rb')
                data=file.read()
                file.close()
                fobj=File(name, '', data, content_type=_ftype(pathname))
                obdir._setObject(name, fobj)

        elif os.path.isdir(pathname):
            obdir.manage_addFolder(name)
            rcimport(pathname, getattr(obdir, name))

        else:
            __traceback_info__=(fsdir, obdir, name)
            raise ValueError, name