Oh, server, where art thou?

by John Samuel Anderson last modified Jan 15, 2009 09:31 PM
Using a pdb.set_trace() with a ZEO server.

Find a specific run-time object with a set_trace

In lib/python/ZEO/ClientStorage.py, I've added a set_trace:
    def pack(self, t=None, referencesf=None, wait=1, days=0):
        """Storage API: pack the storage.

        Deviations from the Storage API: the referencesf argument is
        ignored; two additional optional arguments wait and days are
        provided:

        wait -- a flag indicating whether to wait for the pack to
            complete; defaults to true.

        days -- a number of days to subtract from the pack time;
            defaults to zero.
        """
        # TODO: Is it okay that read-only connections allow pack()?
        # rf argument ignored; server will provide its own implementation
        if t is None:
            t = time.time()
        t = t - (days * 86400)
        import pdb; pdb.set_trace()
        return self._server.pack(t, wait)

However, this time, the set_trace code is in the ZEO server code, not the Zope instance code.  That means, we're going to have to run ZEO in the foreground, as well as Zope.  (I hope you brought enough terminal windows!)

Running ZEO in the foreground

This is basically the same thing as running Zope in the foreground, although the actual command is somewhat different:

$ /var/Plone/bin/zeoserver fg

Watching ZEO in the foreground

Now, we're ready to restart both the ZEO server and the Zope instance, then issue the "pack" command via the ZMI.

What I found is that the ZEO server runs silently, even in the foreground.

OK, so this bit didn't work. I'm leaving it in here, so that you can see what I tried. Also, it's a good lesson that you can't always get what you want.