Call Zope objects using wget
Hi all. I need to call a Python script (that simply creates a new folder object with a unique name) via wget. When I manually invoke the command using via shell, wget -d --spider --http-user=myuser --http-passwd=mypassword http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm the folder object isn't created, while calling the script via Test tab from the ZMI works correctly. The thing that makes me dubious against this misbehaviour, is the server response "302 Moved Temporarily". This is the debug message generated by wget -d: DEBUG output created by Wget 1.9.1 on linux-gnu. --12:48:15-- http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm => `ZScriptHTML_tryForm' Resolving my.url.it... www.xxx.yyy.zzz Caching my.url.it => www.xxx.yyy.zzz Connecting to my.url.it[www.xxx.yyy.zzz]:80... connected. Created socket 3. Releasing 0x8083c10 (new refcount 1). ---request begin--- HEAD /intranet/reset_portal_content/ZScriptHTML_tryForm HTTP/1.0 User-Agent: Wget/1.9.1 Host: my.url.it Accept: */* Connection: Keep-Alive Authorization: Basic YWRtaW46a29hbG9uZQ== Pragma: no-cache ---request end--- HTTP request sent, awaiting response... HTTP/1.1 302 Moved Temporarily Date: Wed, 15 Sep 2004 10:42:09 GMT Server: Zope/(unreleased version, python 2.3.3, linux2) ZServer/1.1 CPS/3.0 Bobo-Exception-Line: 56 Bobo-Exception-Value: See the server error log for details Bobo-Exception-File: DT_Raise.py Bobo-Exception-Type: Redirect Etag: Location: http://my.url.it/intranet/reset_portal_content Content-Type: text/html;charset=iso-8859-1 Connection: close Location: http://my.url.it/intranet/reset_portal_content [following] Closing fd 3 --12:48:15-- http://my.url.it/intranet/reset_portal_content => `reset_portal_content' Found my.url.it in host_name_addresses_map (0x8083c10) Connecting to my.url.it[www.xxx.yyy.zzz]:80... connected. Created socket 3. Releasing 0x8083c10 (new refcount 1). ---request begin--- HEAD /intranet/reset_portal_content HTTP/1.0 User-Agent: Wget/1.9.1 Host: my.url.it Accept: */* Connection: Keep-Alive Authorization: Basic YWRtaW46a29hbG9uZQ== Pragma: no-cache ---request end--- HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Wed, 15 Sep 2004 10:42:10 GMT Server: Zope/(unreleased version, python 2.3.3, linux2) ZServer/1.1 CPS/3.0 Accept-Ranges: none Ms-Author-Via: DAV Last-Modified: Wed, 15 Sep 2004 06:51:45 GMT Etag: Content-Type: application/octet-stream Connection: close Length: unspecified [application/octet-stream] Closing fd 3 200 OK From Zope mailing lists I have seen that many Zope users have never had problems using wget with Zope.. even if someone has suggested to use zeo + wget in case of problems. Any pointer to solve this issue would be highly appreciated. TIA, Paolo
Paolo Dina wrote at 2004-9-15 12:59 +0200:
I need to call a Python script (that simply creates a new folder object with a unique name) via wget.
When I manually invoke the command using via shell,
wget -d --spider --http-user=myuser --http-passwd=mypassword http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm
the folder object isn't created,
Are you sure?
while calling the script via Test tab from the ZMI works correctly.
The thing that makes me dubious against this misbehaviour, is the server response "302 Moved Temporarily".
This is a redirect, performed by many ZMI actions after they are successful. Most management function do not perform a redirect when they are not called with REQUEST/RESPONSE. Otherwise, you can suppress the redirect with a following ...RESPONSE.setStatus(200) return 'done' -- Dieter
Dieter Maurer wrote:
Paolo Dina wrote at 2004-9-15 12:59 +0200:
I need to call a Python script (that simply creates a new folder object with a unique name) via wget.
When I manually invoke the command using via shell,
wget -d --spider --http-user=myuser --http-passwd=mypassword http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm
the folder object isn't created,
Are you sure?
while calling the script via Test tab
from the ZMI works correctly.
Well, digging with more time into the problem... I have found that almost surely the cause is the presence of CookieCrumbler (which I didn't even mention in the previous mail), used for authentication in that Zope site. Using lynx to invoke the script instead of wget solves the problem. This is because the user agent must be able to accept the cookie __ac, and Lynx fully supports cookies handling, so I have found this "workaround": /usr/bin/lynx --accept_all_cookies --auth=myuser:mypassword "http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm?__ac_name..." -dump > /dev/null Paolo
Hi Paolo
I need to call a Python script (that simply creates a new folder object with a unique name) via wget.
When I manually invoke the command using via shell,
wget -d --spider --http-user=myuser --http-passwd=mypassword http://my.url.it/intranet/reset_portal_content/ZScriptHTML_tryForm
the folder object isn't created,
Are you sure?
while calling the script via Test tab
from the ZMI works correctly.
Well, digging with more time into the problem... I have found that almost surely the cause is the presence of CookieCrumbler (which I didn't even mention in the previous mail), used for authentication in that Zope site. It is strange, I'm also using wget to do authentication, I have too a CookieCrumbler, and it works. The only thing I made different is the wget call. I use:
wget -q --delete-after https://myUrl.com Because I don't want somebody to see the password when doing a "ps -ef", I stored the user and password in a protected .wgetrc file (only my zope user can read it): http-user=myUser http-passwd=myPassword If you are running this command on a cron event, I suggest you to do the same. I think Lynx has also a rc file: ".lynxrc". Greetings, Josef
participants (3)
-
Dieter Maurer -
Josef Meile -
Paolo Dina