[Zope3-checkins] CVS: Zope3/src/zope/app/services/translation -
translationservice.py:1.14
Jim Fulton
jim at zope.com
Sun Sep 21 13:33:58 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/services/translation
In directory cvs.zope.org:/tmp/cvs-serv15331/src/zope/app/services/translation
Modified Files:
translationservice.py
Log Message:
No-longer use context wrappers.
Changed to use __setitem__ rather than setObject
=== Zope3/src/zope/app/services/translation/translationservice.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/services/translation/translationservice.py:1.13 Wed Aug 20 15:19:40 2003
+++ Zope3/src/zope/app/services/translation/translationservice.py Sun Sep 21 13:33:27 2003
@@ -27,9 +27,10 @@
from zope.i18n.negotiator import negotiator
from zope.i18n.simpletranslationservice import SimpleTranslationService
from zope.interface import implements
+from zope.app.container.contained import Contained
-class TranslationService(BTreeContainer, SimpleTranslationService):
+class TranslationService(BTreeContainer, SimpleTranslationService, Contained):
implements(ILocalTranslationService, ISimpleService)
@@ -46,17 +47,15 @@
mc = self._catalogs[(language, domain)]
mc.append(catalog_name)
-
def _unregisterMessageCatalog(self, language, domain, catalog_name):
self._catalogs[(language, domain)].remove(catalog_name)
- def setObject(self, name, object):
+ def __setitem__(self, name, object):
'See IWriteContainer'
- super(TranslationService, self).setObject(name, object)
+ super(TranslationService, self).__setitem__(name, object)
self._registerMessageCatalog(object.getLanguage(), object.getDomain(),
name)
- return name
def __delitem__(self, name):
'See IWriteContainer'
@@ -81,8 +80,7 @@
catalog_names = self._catalogs.get((target_language, domain), [])
for name in catalog_names:
- catalog = zapi.ContextSuper(
- TranslationService, self).__getitem__(name)
+ catalog = super(TranslationService, self).__getitem__(name)
text = catalog.queryMessage(msgid)
if text is not None:
break
@@ -95,7 +93,6 @@
# Now we need to do the interpolation
return self.interpolate(text, mapping)
- translate = zapi.ContextMethod(translate)
def getMessageIdsOfDomain(self, domain, filter='%'):
'See IWriteTranslationService'
@@ -199,7 +196,7 @@
for domain in domains:
catalog = zapi.createObject(self, 'Message Catalog',
language, domain)
- self.setObject('%s-%s' %(domain, language), catalog)
+ self['%s-%s' % (domain, language)] = catalog
def addDomain(self, domain):
@@ -211,7 +208,7 @@
for language in languages:
catalog = zapi.createObject(self, 'Message Catalog',
language, domain)
- self.setObject('%s-%s' %(domain, language), catalog)
+ self['%s-%s' % (domain, language)] = catalog
def deleteLanguage(self, language):
More information about the Zope3-Checkins
mailing list