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

Doyon, Jean-Francois Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Mon, 14 Jan 2002 13:51:47 -0500


Hello,

OK, I've figured out what the problem is, but have no idea WHY.

It looks like that 302 error occurs because Zope is redirecting the client
agent to the login form!

What I don't understand is why, since proper credentials were provided.

I tried writing a "load_site" using urllib2, and also in Perl, and I allways
end up with the same problem: redirected to the login page!

Does anybody know why this wouldn't work from urllib2 or LWP::UserAgent, but
works fine in the web browser?  I'm wondering if it might have something to
do with HTTP/1.0 versus 1.1 ... Or does POSTing handle Auth differently?

Any help would be greatly appreciated!

Thanks,
J.F.

-----Original Message-----
From: Doyon, Jean-Francois [mailto:Jean-Francois.Doyon@CCRS.NRCan.gc.ca]
Sent: Saturday, January 12, 2002 2:36 PM
To: 'zope-cmf@zope.org'
Subject: RE: [Zope-CMF] Publishing CMF Objects with ZPublisher.Client


Tres,

OK, thanks that helped some :)

Now i'm having an even stranger problem:

Traceback (most recent call last):
  File "load_site.py", line 159, 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.invokeFactory(type_name='Document', id=name) )
  File "/usr/local/Zope-2.4.3/lib/python/ZPublisher/Client.py", line 226, in
__call__
    self.handleError(query, ec, em, headers, response)
  File "/usr/local/Zope-2.4.3/lib/python/ZPublisher/Client.py", line 241, in
handleError
    raise t, RemoteException(t,v,f,l,self.url,query,ec,em,response)
bci.ServerError: 302 (File: Unknown Line: Unknown)
302 Moved Temporarily for
http://localhost/site/english/batchtest/invokeFactory


Why am I getting this? I'm pretty sure nothing moved! Might this be becayse
I'm using Zope through Apache?  The "Document" DOES get created, but my
"load_site" script dies in the process, and never goes any further.

Also, I need to populate the document. I tried:

	call( object.invokeFactory( type_name='Document', id=name,
text=body, text_format='html' ) )

since according to invokeFactory extra arguments are passed on to the
constructor, but that didn't work. How come? Is this a bug?

So now Iv'e got:

	call( object.invokeFactory(type_name='Document', id=name) )
                
	document=object.__class__(object.url+'/'+name,
username=object.username, password=object.password)
        
	call( document.manage_editDocument(text_format='html',text=body) )

But the script dies on the first line because of the 302, so the content
never gets put in!

Anyway I can work around the 302? Ignore it? Or even better, I'm pretty sure
a 302 should not be returned at all, why is this happening and how do I fix
it?

Thanks for all the help!

J.F.



-----Original Message-----
From: Tres Seaver [mailto:tseaver@zope.com]
Sent: Friday, January 11, 2002 8:10 PM
To: Doyon, Jean-Francois
Cc: 'zope-cmf@zope.org'
Subject: Re: [Zope-CMF] Publishing CMF Objects with ZPublisher.Client


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

_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests