[Zope-Checkins] CVS: Zope/lib/python/App - ApplicationManager.py:1.89 Undo.py:1.33
Chris McDonough
chrism@zope.com
Sat, 19 Jul 2003 22:56:27 -0400
Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv5583/lib/python/App
Modified Files:
ApplicationManager.py Undo.py
Log Message:
Integrate DBTab into HEAD.
DBTab now obtains all values related to storages and databases from zope.conf. It is also now just a package rather than a product.
A new product named ZODBMountPoint exposes the mount point functionality to the ZMI.
=== Zope/lib/python/App/ApplicationManager.py 1.88 => 1.89 ===
--- Zope/lib/python/App/ApplicationManager.py:1.88 Sat Apr 12 21:56:07 2003
+++ Zope/lib/python/App/ApplicationManager.py Sat Jul 19 22:55:51 2003
@@ -28,6 +28,7 @@
from version_txt import version_txt
from cStringIO import StringIO
from AccessControl import getSecurityManager
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
import zLOG
import Lifetime
@@ -39,7 +40,7 @@
def locked_in_version(self): return 0
class DatabaseManager(Fake, SimpleItem.Item, Acquisition.Implicit):
- """Database management"""
+ """Database management (legacy) """
manage=manage_main=DTMLFile('dtml/dbMain', globals())
manage_main._setName('manage_main')
id ='DatabaseManagement'
@@ -69,6 +70,70 @@
Globals.default__class_init__(DatabaseManager)
+class FakeConnection:
+ # Supports the methods of Connection that CacheManager needs
+
+ def __init__(self, db, parent_jar):
+ self._db = db
+ self.version = parent_jar.getVersion()
+
+ def db(self):
+ return self._db
+
+ def getVersion(self):
+ return self.version
+
+class DatabaseChooser (SimpleItem.SimpleItem):
+ """Lets you choose which database to view
+ """
+ meta_type = 'Database Management'
+ name = title = 'Database Management'
+ icon = 'p_/DatabaseManagement_icon'
+ isPrincipiaFolderish = 1
+
+ manage_options=(
+ {'label':'Databases', 'action':'manage_main'},
+ )
+
+ manage_main = PageTemplateFile('www/chooseDatabase.pt', globals())
+
+ def __init__(self, id):
+ self.id = id
+
+ def getDatabaseNames(self):
+ configuration = getConfiguration()
+ names = configuration.dbtab.listDatabaseNames()
+ names.sort()
+ return names
+
+ def __getitem__(self, name):
+ configuration = getConfiguration()
+ db = configuration.dbtab.getDatabase(name=name)
+ m = AltDatabaseManager()
+ m.id = name
+ m._p_jar = FakeConnection(db, self.getPhysicalRoot()._p_jar)
+ return m.__of__(self)
+
+ def __bobo_traverse__(self, request, name):
+ configuration = getConfiguration()
+ if configuration.dbtab.hasDatabase(name):
+ return self[name]
+ return getattr(self, name)
+
+ def tpValues(self):
+ names = self.getDatabaseNames()
+ res = []
+ for name in names:
+ m = AltDatabaseManager()
+ m.id = name
+ # Avoid opening the database just for the tree widget.
+ m._p_jar = None
+ res.append(m.__of__(self))
+ return res
+
+Globals.InitializeClass(DatabaseChooser)
+
+
class VersionManager(Fake, SimpleItem.Item, Acquisition.Implicit):
"""Version management"""
manage=manage_main=DTMLFile('dtml/versionManager', globals())
@@ -207,7 +272,7 @@
__roles__=('Manager',)
isPrincipiaFolderish=1
- Database= DatabaseManager()
+ Database= DatabaseChooser('Database') #DatabaseManager()
Versions= VersionManager()
DebugInfo=DebugManager()
DavLocks = DavLockManager()
@@ -465,3 +530,11 @@
self._objects = tuple(lst)
return Folder.objectIds(self, spec)
+
+class AltDatabaseManager(DatabaseManager, CacheManager):
+ """Database management DBTab-style
+ """
+ db_name = ApplicationManager.db_name
+ db_size = ApplicationManager.db_size
+ manage_pack = ApplicationManager.manage_pack
+
=== Zope/lib/python/App/Undo.py 1.32 => 1.33 ===
--- Zope/lib/python/App/Undo.py:1.32 Thu Oct 3 14:28:54 2002
+++ Zope/lib/python/App/Undo.py Sat Jul 19 22:55:51 2003
@@ -16,6 +16,7 @@
import base64
+from Acquisition import aq_base, aq_parent, aq_inner
from AccessControl import getSecurityManager
from DateTime import DateTime
import Globals, ExtensionClass
@@ -86,11 +87,17 @@
path=''
if path: spec['user_name']=Prefix(path)
- # We also only want to undo things done here
- opath='/'.join(self.getPhysicalPath())
+ if getattr(aq_parent(aq_inner(self)), '_p_jar', None) == self._p_jar:
+ # We only want to undo things done here (and not in mounted
+ # databases)
+ opath='/'.join(self.getPhysicalPath())
+ else:
+ # Special case: at the root of a database,
+ # allow undo of any path.
+ opath = None
if opath: spec['description']=Prefix(opath)
- r=Globals.UndoManager.undoInfo(
+ r = self._p_jar.db().undoInfo(
first_transaction, last_transaction, spec)
encode = base64.encodestring
@@ -114,7 +121,8 @@
def manage_undo_transactions(self, transaction_info=(), REQUEST=None):
"""
"""
- undo=Globals.UndoManager.undo
+ undo=self._p_jar.db().undo
+
for tid in transaction_info:
tid=tid.split()
if tid: