[Zope-Checkins] CVS: Zope/lib/python/OFS - Folder.py:1.97.34.1 ObjectManager.py:1.147.18.3
Casey Duncan
c.duncan@nlada.org
Tue, 12 Mar 2002 17:29:59 -0500
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv2657
Modified Files:
Tag: casey-death_to_index_html-branch
Folder.py ObjectManager.py
Log Message:
Added the ZMI ui for setting the browser_default on folderish beasts, added
some support API and tests in OM.
=== Zope/lib/python/OFS/Folder.py 1.97 => 1.97.34.1 ===
manage_options=(
- (ObjectManager.ObjectManager.manage_options[0],)+
+ ObjectManager.ObjectManager.manage_options+
(
- {'label':'View', 'action':'index_html',
+ {'label':'View', 'action':'',
'help':('OFSP','Folder_View.stx')},
)+
PropertyManager.PropertyManager.manage_options+
=== Zope/lib/python/OFS/ObjectManager.py 1.147.18.2 => 1.147.18.3 ===
),
('Manage folderish settings',
- ('manage_settings', 'setBrowserDefaultId', 'getBrowserDefaultId')
+ ('manage_settings', 'setBrowserDefaultId',
+ 'getBrowserDefaultId', 'isBrowserDefaultAcquired')
),
)
@@ -151,10 +152,12 @@
manage_main=DTMLFile('dtml/main', globals())
manage_index_main=DTMLFile('dtml/index_main', globals())
+ manage_settings=DTMLFile('dtml/objectManagerSettings', globals())
manage_options=(
{'label':'Contents', 'action':'manage_main',
'help':('OFSP','ObjectManager_Contents.stx')},
+ {'label':'Settings', 'action':'manage_settings'},
)
isAnObjectManager=1
@@ -673,18 +676,27 @@
# normally HTTPRequest.traverse does not acquire it
browser_default = Acquisition.Acquired
- def setBrowserDefaultId(self, id='', acquire=0):
+ def setBrowserDefaultId(self, id='', acquire=0, REQUEST=None):
"""Set the id of the browser_default method. If acquire is true
then the local browser_default is cleared and the setting is
acquired
"""
+ if self.hasCustomBrowserDefault():
+ # If a custom browser default is installed, don't override it
+ raise BadRequestException, \
+ 'Cannot override custom browser default'
+
if acquire:
- if aq_base(self).browser_default is not Acquisition.Acquired:
+ if not self.isBrowserDefaultAcquired():
del self.browser_default
else:
self._checkId(id, allow_dup=1)
self.browser_default = BrowserDefault(id)
+ if REQUEST:
+ REQUEST.RESPONSE.redirect(REQUEST.URL1 +
+ '/manage_settings?manage_tabs_message=Settings+Changed')
+
def getBrowserDefaultId(self, acquire=0):
"""Get the id of the browser_default method. If acquire is true
then the acquired value is returned if there is no local setting,
@@ -692,12 +704,24 @@
browser_default has been overidden in this (or a higher) instance
using a custom callable.
"""
- if (acquire
- or aq_base(self).browser_default is not Acquisition.Acquired
- and isinstance(aq_base(self.browser_default), BrowserDefault)):
+ if self.hasCustomBrowserDefault():
+ return None
+ elif acquire or not self.isBrowserDefaultAcquired():
return self.browser_default.getDefaultId()
else:
return None
+
+ def isBrowserDefaultAcquired(self):
+ """Return true if the current browser default is being acquired"""
+ return aq_base(self).browser_default is Acquisition.Acquired
+
+ def hasCustomBrowserDefault(self):
+ """Return true if a custom browser_default object has been
+ installed
+ """
+ return not (self.isBrowserDefaultAcquired()
+ or getattr(self.browser_default, '__class__', None)
+ is BrowserDefault)
def findChilds(obj,dirname=''):
""" recursive walk through the object hierarchy to