[Zope3-checkins] SVN: Zope3/branches/philikon-reduce-zcml/src/z
Deprecate the modulealias directive and replace its usage by
a simple
Philipp von Weitershausen
philikon at philikon.de
Wed Mar 15 10:28:20 EST 2006
Log message for revision 66038:
Deprecate the modulealias directive and replace its usage by a simple
sys.modules hack.
Changed:
U Zope3/branches/philikon-reduce-zcml/src/zope/app/error/__init__.py
U Zope3/branches/philikon-reduce-zcml/src/zope/app/error/configure.zcml
U Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/metaconfigure.py
U Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/tests/test_modulealias.py
U Zope3/branches/philikon-reduce-zcml/src/zwiki/__init__.py
U Zope3/branches/philikon-reduce-zcml/src/zwiki/configure.zcml
-=-
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/error/__init__.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/error/__init__.py 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/error/__init__.py 2006-03-15 15:28:19 UTC (rev 66038)
@@ -1,12 +1,29 @@
-# Make directory a package.
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation 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.
+#
+##############################################################################
+"""Error logging utility
+$Id$
+"""
+from zope.app.error.error import RootErrorReportingUtility
+from zope.app.error.error import ErrorReportingUtility
+from zope.app.error.error import globalErrorReportingUtility
+
###############################################################################
# BBB: 12/14/2004
+import sys
+sys.modules['zope.app.errorservice'] = sys.modules[__name__]
-from error import RootErrorReportingUtility
-from error import ErrorReportingUtility
-from error import globalErrorReportingUtility
-
RootErrorReportingService = RootErrorReportingUtility
ErrorReportingService = ErrorReportingUtility
globalErrorReportingService = globalErrorReportingUtility
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/error/configure.zcml
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/error/configure.zcml 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/error/configure.zcml 2006-03-15 15:28:19 UTC (rev 66038)
@@ -1,12 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope">
- <!-- BBB: 12/15/2004 -->
- <modulealias
- module="zope.app.error"
- alias="zope.app.errorservice" />
-
-
<localUtility class=".error.ErrorReportingUtility">
<factory
id="zope.app.ErrorLogging"
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/metaconfigure.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/metaconfigure.py 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/metaconfigure.py 2006-03-15 15:28:19 UTC (rev 66038)
@@ -25,11 +25,16 @@
__docformat__ = 'restructuredtext'
import sys
import types
+import warnings
class ModuleAliasException(Exception):
pass
def define_module_alias(_context, module, alias):
+ warnings.warn_explicit(
+ "The 'modulealais' directive has been deprecated and will be "
+ "removed in Zope 3.5. Manipulate sys.modules manually instead.",
+ DeprecationWarning, _context.info.file, _context.info.line)
_context.action(
discriminator = None,
callable = alias_module,
@@ -49,4 +54,3 @@
'"alias" module %s already exists in sys.modules' % alias)
sys.modules[alias] = module_ob
-
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/tests/test_modulealias.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/tests/test_modulealias.py 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/modulealias/tests/test_modulealias.py 2006-03-15 15:28:19 UTC (rev 66038)
@@ -17,6 +17,7 @@
"""
import unittest
import sys
+import warnings
from zope.configuration import xmlconfig
from zope.configuration.config import ConfigurationContext
# math is imported as an example module to test with
@@ -37,15 +38,22 @@
class Test(unittest.TestCase):
+
def setUp(self):
self.keys = sys.modules.keys()
+ def ignorewarning(message, category, filename, lineno, file=None):
+ pass
+ warnings.showwarning = ignorewarning
+
def tearDown(self):
keys = sys.modules.keys()
for key in keys:
if key not in self.keys:
del sys.modules[key]
-
+
+ warnings.resetwarnings()
+
def test_definemodulealias(self):
context = ConfigurationContext()
from zope.modulealias.metaconfigure import alias_module
Modified: Zope3/branches/philikon-reduce-zcml/src/zwiki/__init__.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zwiki/__init__.py 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zwiki/__init__.py 2006-03-15 15:28:19 UTC (rev 66038)
@@ -17,3 +17,7 @@
"""
from zope.i18nmessageid import MessageFactory
ZWikiMessageFactory = MessageFactory("zwiki")
+
+# BBB
+import sys
+sys.modules['zope.app.wiki'] = sys.modules[__name__]
Modified: Zope3/branches/philikon-reduce-zcml/src/zwiki/configure.zcml
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zwiki/configure.zcml 2006-03-15 15:08:07 UTC (rev 66037)
+++ Zope3/branches/philikon-reduce-zcml/src/zwiki/configure.zcml 2006-03-15 15:28:19 UTC (rev 66038)
@@ -7,9 +7,6 @@
i18n_domain="zwiki"
>
- <!-- Backward compatibility -->
- <modulealias module="zwiki" alias="zope.app.wiki" />
-
<!-- Security definitions -->
<role
More information about the Zope3-Checkins
mailing list