[Zope] ftp connection to remote Zope-Server

Elena Schulz elena.schulz@gmx.net
Tue, 12 Nov 2002 17:05:21 +0100


Hi,

I want to connect my local Zope (win98, Zope 2.5.1) to a remote Zope-Server
only by ftp-access.
The following external method from zopelabs seems to connect somehow but
doesn work (no files are sent):

1. How can I log the info from the remote Server to see where the problem
is?
2. Is "_ftp.set_pasv(1)" ok to enable passive mode for operating from behind
a firewall?

Has anybody positive experience with this or other methods of ftp-connection
between 2 Zope-server?
Thanks for any help and replies,

Elena

The external-script:

""" sendfiles from ZOPE to another machine ftp
 by runyaga @ zopelabs
"""

import ftplib
from string import split, lower
from StringIO import StringIO

host='localhost'
login='runyaga'
password='^%$^@5@#$S'
port=21

def ftp(obj, host=host, login=login, password=password, port=port):
    _ftp = ftplib.FTP()
    _ftp.set_pasv(1)  #for firewall < ######## 2 ############
    #_ftp.connect(host, port)
    _ftp.connect(host) # with default port
    _ftp.login(login, password)

    if lower(obj.meta_type)=='file':
        binary=1
        if obj.content_type[:4]=='text': binary=0
        ftp_file(_ftp, obj, binary)

    if lower(obj.meta_type)=='image':
        ftp_file(_ftp, obj, 1)

    _ftp.quit()

def ftp_file(ftpCon, fileObj, binary):
    if binary:
        ftpCon.storbinary("STOR " + fileObj.getId(), StringIO(fileObj.data),
1024)
    else:
        f = StringIO()
        f.readlines(split(fileObj.data, '\n'))
        f.seek(0)
        ftpCon.storlines("STOR " + fileObj.getId(), f)