[Zope-CMF] Publishing CMF Objects with ZPublisher.Client

Tres Seaver tseaver@zope.com
Fri, 11 Jan 2002 20:09:51 -0500


Doyon, Jean-Francois wrote:

> Hello,
> 
> I'm trying to modify the load_site.py script in order to batch upload CMF
> content using CMFDefault object-types, and am having some trouble.
> 
> Right now I have a line that says:
> 
> call(object.manage_addProduct['CMFDefault'].manage_addContent(type='Document
> ', id=name))
> 
> And it dies with the following:
> 
> Traceback (most recent call last):
>   File "load_site.py", line 153, in ?
>     if __name__=='__main__': main()
>   File "load_site.py", line 64, in main
>     for f in files: upload_file(object, f)
>   File "load_site.py", line 87, in upload_file
>     return globals()['upload_'+ext](object, f)
>   File "load_site.py", line 119, in upload_html
>  
> call(object.manage_addProduct['CMFDefault'].manage_addContent(type='Document
> ', id=name))
> AttributeError: Function instance has no attribute '__getitem__'
> 
> 
> I tried tracking down why this occurs, but I have to admit I think this is a
> bit over my head, I get lost at the Function part in Client.py :)  I have
> load_site working great with non-CMF content however.
> 
> I also tried:
> 
> call(object.manage_addProduct['CMFDefault'].manage_addContent,type='Document
> ', id=name)
> 
> and
> 
> object.manage_addProduct['CMFDefault'].manage_addContent(type='Document',
> id=name)
> 
> With no luck ...
> 
> Has anybody tried this before? It's pretty crucial to me that I be able to
> do this! What am I missing?


The ZMI add list methods are really not the preferred way
to add content;  your report makes me suspect that they are,
in fact, broken.

Try instead::

   call( object.invokeFactory( type_name='Document', id=name ) )

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com