You are not logged in Log in Join
You are here: Home » Members » Toby Dickenson » howto » VersionFTPServer

Log in
Name

Password

 

VersionFTPServer

Note: These instructions are out of date for recent versions of Zope. The same technique should still work, but you will have to develop your own code changes. If anyone does this, please write a new howto.

Overview

A Zope Version provides a provide view of the database. Any changes you make are not visible in the public view until the version is committed.

Using FTP is a good way to edit content, however Zope's standard FTP does not support Versions.

Maybe a future revision of Zope's FTP support will include full support for Versions. Until then, here is a quick and dirty solution. The following changes provide a new FTP server on a different port, permanently tied into one specific version. You still need to use HTTP to create the version, and commit its changes. However you can use FTP to create and edit content.

Warning: This change will work exactly as described in Zope 2.2.x, but since then some other things have changed. I think the principles behind this change are still sound, however there are some details that you will have to work out for yourself if you want to use a recent version of Zope.

Changes

Create a file named version_servers.py in the Zope directory (the directory that contains z2.py) with the following content:

from ZServer import FTPServer

c_c = FTPServer.ftp_channel_class

class version_ftp_channel(c_c):
    def __init__ (self, server, conn, addr, module):
        c_c.__init__(self, server, conn, addr, module)
        self.cookies['Zope-Version'] = server._version


class VersionFTPServer(FTPServer):
    ftp_channel_class = version_ftp_channel
    _version = ''

    def __init__(self,version,**kw):
        self._version = version
        apply(FTPServer.__init__, (self,), kw)

Secondly, edit z2.py. Find the section that is commented # FTP Server, around line 522. Change it to something like the following.

if FTP_PORT:
    zftp = FTPServer(
        module=MODULE,
        port=FTP_PORT,
        resolver=rs,
        logger_object=lg)

    import version_servers
    zftp2 = version_servers.VersionFTPServer(
        module=MODULE,
        version='path/to/your/version',
        port=8121,
        resolver=rs,
        logger_object=lg)

This creates an extra FTP server, on port 8121. This FTP server is permanently tied to the version object at 'path/to/your/version'. If necessary you can create multiple VersionFTPServers, for different versions, on different ports.