/usr/share/pyshared/zope/app/applicationcontrol/browser/zodbcontrol.py is in python-zope.app.applicationcontrol 3.5.10-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Server Control View
$Id: zodbcontrol.py 121717 2011-05-18 19:23:30Z menesis $
"""
__docformat__ = 'restructuredtext'
from ZODB.FileStorage.FileStorage import FileStorageError
from zope.app.applicationcontrol.i18n import ZopeMessageFactory as _
from zope.size import byteDisplay
from ZODB.interfaces import IDatabase
from zope import component
class ZODBControlView(object):
status = None
@property
def databases(self):
res = []
for name, db in component.getUtilitiesFor(
IDatabase):
d = dict(
dbName = db.getName(),
utilName = str(name),
size = self._getSize(db),
)
res.append(d)
return res
def _getSize(self, db):
"""Get the database size in a human readable format."""
size = db.getSize()
if not isinstance(size, (int, long, float)):
return str(size)
return byteDisplay(size)
def update(self):
if self.status is not None:
return self.status
status = []
if 'PACK' in self.request.form:
dbs = self.request.form.get('dbs', [])
try:
days = int(self.request.form.get('days','').strip() or 0)
except ValueError:
status.append(_('Error: Invalid Number'))
self.status = status
return self.status
for dbName in dbs:
db = component.getUtility(IDatabase, name=dbName)
try:
db.pack(days=days)
status.append(_('ZODB "${name}" successfully packed.',
mapping=dict(name=str(dbName))))
except FileStorageError, err:
status.append(_('ERROR packing ZODB "${name}": ${err}',
mapping=dict(name=str(dbName), err=err)))
self.status = status
return self.status
|