[Checkins] SVN: zope.app.appsetup/trunk/ Finally deprecate the "asObject" argument to the bootstrap helper functions.
Dan Korostelev
nadako at gmail.com
Wed Mar 4 16:24:01 EST 2009
Log message for revision 97496:
Finally deprecate the "asObject" argument to the bootstrap helper functions.
Remove deprecated bootstrap function (I forgot its name though:)).
Changed:
U zope.app.appsetup/trunk/CHANGES.txt
U zope.app.appsetup/trunk/buildout.cfg
U zope.app.appsetup/trunk/src/zope/app/appsetup/bootstrap.py
U zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py
U zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py
-=-
Modified: zope.app.appsetup/trunk/CHANGES.txt
===================================================================
--- zope.app.appsetup/trunk/CHANGES.txt 2009-03-04 21:20:50 UTC (rev 97495)
+++ zope.app.appsetup/trunk/CHANGES.txt 2009-03-04 21:24:00 UTC (rev 97496)
@@ -5,8 +5,14 @@
Version 3.9.1 (unreleased)
--------------------------
-- ...
+- Finally deprecate the "asObject" argument of helper functions in the
+ ``zope.app.appsetup.bootstrap`` module. If your code uses any of these
+ functions, please remove the "asObject=True" argument passing anywhere,
+ because the support for that argument will be dropped soon.
+- Remove one more deprecated function.
+
+
Version 3.9.0 (2009-01-31)
--------------------------
Modified: zope.app.appsetup/trunk/buildout.cfg
===================================================================
--- zope.app.appsetup/trunk/buildout.cfg 2009-03-04 21:20:50 UTC (rev 97495)
+++ zope.app.appsetup/trunk/buildout.cfg 2009-03-04 21:24:00 UTC (rev 97496)
@@ -1,7 +1,6 @@
[buildout]
develop = .
parts = test python tags
-find-links = http://download.zope.org/distribution/
[test]
recipe = zc.recipe.testrunner
Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/bootstrap.py
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/bootstrap.py 2009-03-04 21:20:50 UTC (rev 97495)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/bootstrap.py 2009-03-04 21:24:00 UTC (rev 97496)
@@ -25,7 +25,6 @@
import logging
import warnings
-import zope.deprecation
import zope.event
import zope.lifecycleevent
@@ -39,16 +38,18 @@
from zope.site.folder import rootFolder
from zope.traversing.api import traverse
+_marker = object()
def ensureObject(root_folder, object_name, object_type, object_factory,
- asObject=False):
+ asObject=_marker):
"""Check that there's a basic object in the site
manager. If not, add one.
Return the name abdded, if we added an object, otherwise None.
"""
- if not asObject:
- warnings.warn("asObject=False is deprecated", DeprecationWarning, 2)
+ if asObject is not _marker:
+ warnings.warn("asObject argument is deprecated and will be "
+ "removed in Zope 3.6", DeprecationWarning, 2)
package = getSiteManagerDefault(root_folder)
valid_objects = [ name
@@ -59,22 +60,18 @@
name = object_name
obj = object_factory()
package[name] = obj
- if asObject:
- return obj
- else:
- return name
+ return obj
def ensureUtility(root_folder, interface, utility_type,
- utility_factory, name='', asObject=False, **kw):
+ utility_factory, name='', asObject=_marker, **kw):
"""Add a utility to the top site manager
Returns the name added or ``None`` if nothing was added.
"""
- if not asObject:
- warnings.warn("asObject=False is deprecated and will not be "
- "supported after Zope 3.5",
- DeprecationWarning, 2)
+ if asObject is not _marker:
+ warnings.warn("asObject argument is deprecated and will be "
+ "removed in Zope 3.6", DeprecationWarning, 2)
sm = root_folder.getSiteManager()
utils = [reg for reg in sm.registeredUtilities()
@@ -90,31 +87,27 @@
def addConfigureUtility(
root_folder, interface, utility_type, utility_factory, name='',
- asObject=False, **kw):
+ asObject=_marker, **kw):
"""Add and configure a utility to the root folder."""
- if not asObject:
- warnings.warn("asObject=False is deprecated and will not be "
- "supported after Zope 3.5", DeprecationWarning, 2)
+ if asObject is not _marker:
+ warnings.warn("asObject argument is deprecated and will be "
+ "removed in Zope 3.6", DeprecationWarning, 2)
utility = addUtility(root_folder, utility_type, utility_factory, True,
**kw)
root_folder.getSiteManager().registerUtility(utility, interface, name)
+ return utility
- if asObject:
- return utility
- else:
- return utility.__name__
-
def addUtility(root_folder, utility_type, utility_factory,
- asObject=False, **kw):
+ asObject=_marker, **kw):
""" Add a Utility to the root folder's site manager.
The utility is added to the default package and activated.
"""
- if not asObject:
- warnings.warn("asObject=False is deprecated and will not be "
- "supported after Zope 3.5", DeprecationWarning, 2)
+ if asObject is not _marker:
+ warnings.warn("asObject argument is deprecated and will be "
+ "removed in Zope 3.6", DeprecationWarning, 2)
package = getSiteManagerDefault(root_folder)
chooser = INameChooser(package)
@@ -130,29 +123,9 @@
# Set additional attributes on the utility
for k, v in kw.iteritems():
setattr(utility, k, v)
- if asObject:
- return utility
- else:
- return name
+ return utility
- at zope.deprecation.deprecate(
- 'configureUtility is deprecated and will be removed in Zope 3.5. '
- 'The registration APIs are simple enough now that this just makes things '
- 'mor complicated,')
-def configureUtility(
- root_folder, interface, utility_type, name, folder_name,
- initial_status=u'Active'):
- """Configure a utility in the root folder."""
- # folder name is the name of the utility in the default folder. Sheesh
- assert initial_status == u'Active'
- package = getSiteManagerDefault(root_folder)
- root_folder.getSiteManager().registerUtility(
- package[folder_name],
- interface, name,
- )
-
-
def getSiteManagerDefault(root_folder):
package = traverse(root_folder.getSiteManager(), 'default')
return package
Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py 2009-03-04 21:20:50 UTC (rev 97495)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/errorlog.py 2009-03-04 21:24:00 UTC (rev 97496)
@@ -32,7 +32,7 @@
db, connection, root, root_folder = getInformationFromEvent(event)
ensureUtility(root_folder, IErrorReportingUtility, '',
- RootErrorReportingUtility, copy_to_zlog=False, asObject=True)
+ RootErrorReportingUtility, copy_to_zlog=False)
transaction.commit()
connection.close()
Modified: zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py
===================================================================
--- zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py 2009-03-04 21:20:50 UTC (rev 97495)
+++ zope.app.appsetup/trunk/src/zope/app/appsetup/tests.py 2009-03-04 21:24:00 UTC (rev 97496)
@@ -110,7 +110,7 @@
sub_folder = root_folder['sub_folder']
ensureUtility(sub_folder, IErrorReportingUtility,
'ErrorReporting', ErrorReportingUtility,
- 'ErrorReporting', asObject=True)
+ 'ErrorReporting')
# Make sure it was created on the sub folder, not the root folder
got_utility = zope.component.getUtility(IErrorReportingUtility,
@@ -131,10 +131,10 @@
cx = self.db.open()
utility = ensureUtility(root_folder, IErrorReportingUtility,
'ErrorReporting', ErrorReportingUtility,
- 'ErrorReporting', asObject=True)
+ 'ErrorReporting')
utility2 = ensureUtility(root_folder, IErrorReportingUtility,
'ErrorReporting2', ErrorReportingUtility,
- 'ErrorReporting2', asObject=True)
+ 'ErrorReporting2')
if utility != None:
name = utility.__name__
name2 = utility2.__name__
More information about the Checkins
mailing list