"""Simple utility to help determine what's eating up your diskspace. It might just be old transactions, in which case a pack will do or it might be some big objects somewhere. To install, move this file to the Extensions folder and to the ZMI and an External Method called spaceman which is located in the module spaceman and the function spaceman. To run, just click on the test tab of the added External Method. This obviously doesn't work with objects that store some of their data outside of the main database, but who knows, maybe that'll be implemented later. :) Questions and comments can be sent to email@example.com """ class dummy_file: def __init__(self): self._len = 0 def write(self, data): self._len += len(data) def writelines(self, lines): for line in lines: self.write(line) def __len__(self): return self._len def get_id(id): if callable(id): return id() else: return id def pretty_size(size): if size < 1024: return "%s bytes" % size elif size < 1024*1024: return "%.2f KBs" % (size / 1024.0) elif size < 1024*1024*1024: return "%.2f MBs" % (size / (1024.0 * 1024.0)) else: return "%.2f GBs" % (size / (1024.0 * 1024.0 * 1024.0)) def get_space_usage(self): """Lists the storage space used.""" usage =  for object in self.objectValues(): dummy = dummy_file() object._p_jar.exportFile(object._p_oid, dummy) # File starts with ZEXP usage.append([get_id(object.id), len(dummy) - 4, object.objectIds()]) usage[-1].append(pretty_size(usage[-1])) return usage usage_template = """