diff options
author | Jim Fulton <jim@zope.com> | 2006-04-27 00:54:03 +0000 |
---|---|---|
committer | Jim Fulton <jim@zope.com> | 2006-04-27 00:54:03 +0000 |
commit | 3836031490e1cb3c20b1d9b2c8fd8dc876ece12c (patch) | |
tree | 1b75c3561cc202d0255d069f2ec98f9702ace673 | |
parent | 5726caca207c338db30e117d14c74873c850eb1f (diff) | |
download | zope-tal-3836031490e1cb3c20b1d9b2c8fd8dc876ece12c.tar.gz |
Merge of jim-adapter branch:
This branch has three major refactorings on it:
- A redesign of the adapter registration machinery
- A major simplification of local component management
See zope.component.interfaces.IComponentRegistry.
- A flexible system for combining component registries.
- A beginning of the migration of packages out of zope.app.
- A new package for doing deferred imports. This allows you
to make names available at the package level without creating
circular imports. See zope.deferredimport and see
zope.component.__init__ for examples of it's use. This package
also provides a way to deprecate names in a module.
- Deprecation of zope. i18nmessageid.MessageID
I should have created checkin messages for individual sets of related
changes, but there were just too many for the time allowed.
-rw-r--r-- | dummyengine.py | 13 | ||||
-rw-r--r-- | talinterpreter.py | 9 | ||||
-rw-r--r-- | tests/test_talinterpreter.py | 28 |
3 files changed, 10 insertions, 40 deletions
diff --git a/dummyengine.py b/dummyengine.py index 26db23d..2a35d84 100644 --- a/dummyengine.py +++ b/dummyengine.py @@ -20,14 +20,9 @@ import re from zope.interface import implements from zope.tal.taldefs import NAME_RE, TALExpressionError, ErrorInfo from zope.tal.interfaces import ITALExpressionCompiler, ITALExpressionEngine +from zope.i18nmessageid import Message from zope.i18n.interfaces import ITranslationDomain -# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3 -import zope.deprecation -zope.deprecation.__show__.off() -from zope.i18nmessageid import MessageID, Message -zope.deprecation.__show__.on() - Default = object() name_match = re.compile(r"(?s)(%s):(.*)\Z" % NAME_RE).match @@ -142,7 +137,7 @@ class DummyEngine(object): def evaluateText(self, expr): text = self.evaluate(expr) - if isinstance(text, (str, unicode, MessageID, Message)): + if isinstance(text, (str, unicode, Message)): return text if text is not None and text is not Default: text = str(text) @@ -298,7 +293,7 @@ class DummyTranslationDomain(object): # by calling that method. # MessageID attributes override arguments - if isinstance(msgid, (MessageID, Message)): + if isinstance(msgid, Message): domain = msgid.domain mapping = msgid.mapping default = msgid.default @@ -325,7 +320,7 @@ class MultipleDomainsDummyEngine(DummyEngine): def translate(self, msgid, domain=None, mapping=None, default=None): - if isinstance(msgid, (MessageID, Message)): + if isinstance(msgid, Message): domain = msgid.domain if domain == 'a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine': diff --git a/talinterpreter.py b/talinterpreter.py index 9690c49..e4646f7 100644 --- a/talinterpreter.py +++ b/talinterpreter.py @@ -23,12 +23,7 @@ import warnings # Do not use cStringIO here! It's not unicode aware. :( from StringIO import StringIO -# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3 -import zope.deprecation -zope.deprecation.__show__.off() -from zope.i18nmessageid import MessageID, Message -zope.deprecation.__show__.on() - +from zope.i18nmessageid import Message from zope.tal.taldefs import quote, TAL_VERSION, METALError from zope.tal.taldefs import isCurrentVersion from zope.tal.taldefs import getProgramVersion, getProgramMode @@ -37,7 +32,7 @@ from zope.tal.translationcontext import TranslationContext # Avoid constructing this tuple over and over -I18nMessageTypes = (MessageID, Message) +I18nMessageTypes = (Message,) TypesToTranslate = I18nMessageTypes + (str, unicode) diff --git a/tests/test_talinterpreter.py b/tests/test_talinterpreter.py index adf8166..b00e3a0 100644 --- a/tests/test_talinterpreter.py +++ b/tests/test_talinterpreter.py @@ -30,12 +30,7 @@ from zope.tal.dummyengine import DummyEngine from zope.tal.dummyengine import MultipleDomainsDummyEngine from zope.tal.dummyengine import DummyTranslationDomain from zope.tal.tests import utils - -# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3 -import zope.deprecation -zope.deprecation.__show__.off() -from zope.i18nmessageid import MessageID, Message -zope.deprecation.__show__.on() +from zope.i18nmessageid import Message class TestCaseBase(unittest.TestCase): @@ -455,21 +450,12 @@ class I18NCornerTestCaseBase(TestCaseBase): "Foo <span tal:replace='bar' i18n:name='bar' /></div>") self._check(program, u"<div>FOO \u00C0</div>\n") - -class I18NCornerTestCaseMessageID(I18NCornerTestCaseBase): +class I18NCornerTestCaseMessage(I18NCornerTestCaseBase): def factory(self, msgid, default=None, mapping={}, domain=None): - m = MessageID(msgid, default=default) - m.mapping = mapping - return m - -class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessageID): - - def factory(self, msgid, default=None, mapping={}, domain=None): - m = MessageID(msgid, default=default, domain=domain) - m.mapping = mapping - return m + return Message(msgid, domain=domain, default=default, mapping=mapping) +class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessage): def setUp(self): # MultipleDomainsDummyEngine is a Engine @@ -538,11 +524,6 @@ class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessageID): ' tal:content="baz" />') self._check(program, '<div>BAZVALUE</div>\n') -class I18NCornerTestCaseMessage(I18NCornerTestCaseBase): - - def factory(self, msgid, default=None, mapping={}): - return Message(msgid, default=default, mapping=mapping) - class ScriptTestCase(TestCaseBase): def setUp(self): @@ -762,7 +743,6 @@ def test_suite(): suite.addTest(unittest.makeSuite(MacroExtendTestCase)) suite.addTest(unittest.makeSuite(OutputPresentationTestCase)) suite.addTest(unittest.makeSuite(ScriptTestCase)) - suite.addTest(unittest.makeSuite(I18NCornerTestCaseMessageID)) suite.addTest(unittest.makeSuite(I18NCornerTestCaseMessage)) suite.addTest(unittest.makeSuite(UnusedExplicitDomainTestCase)) suite.addTest(unittest.makeSuite(TestSourceAnnotations)) |