[Zope3-checkins] CVS: Zope3/src/zope/app/applicationcontrol/browser - translationdomaincontrol.py:1.2

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 23 10:52:07 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/applicationcontrol/browser
In directory cvs.zope.org:/tmp/cvs-serv1820/src/zope/app/applicationcontrol/browser

Modified Files:
	translationdomaincontrol.py 
Log Message:


Get rid of useless adapter and do all the work in a view.




=== Zope3/src/zope/app/applicationcontrol/browser/translationdomaincontrol.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/applicationcontrol/browser/translationdomaincontrol.py:1.1	Mon Mar  8 18:33:39 2004
+++ Zope3/src/zope/app/applicationcontrol/browser/translationdomaincontrol.py	Tue Mar 23 10:52:06 2004
@@ -15,14 +15,22 @@
 
 $Id$
 """
-from zope.app.applicationcontrol.interfaces import ITranslationDomainControl
+from zope.i18n.interfaces import ITranslationDomain
+from zope.app import zapi
 from zope.app.i18n import ZopeMessageIDFactory as _
 
 class TranslationDomainControlView:
 
     def getCatalogsInfo(self):
-        control = ITranslationDomainControl(self.context)
-        return control.getCatalogsInfo()
+        info = []
+        for name, domain in zapi.getUtilitiesFor(None, ITranslationDomain):
+            if not hasattr(domain, 'getCatalogsInfo'):
+                continue
+            for language, fileNames in domain.getCatalogsInfo().items():
+                info.append({'domain': name,
+                             'language': language,
+                             'fileNames': fileNames})
+        return info
 
 
     def reloadCatalogs(self):
@@ -32,7 +40,12 @@
         if 'RELOAD' in self.request:
             language = self.request.get('language')
             domain = self.request.get('domain')
-            control = ITranslationDomainControl(self.context)
-            control.reloadCatalogs(domain, language)
+
+            domain = zapi.getUtility(None, ITranslationDomain, domain)
+            for lang, fileNames in domain.getCatalogsInfo().items():
+                if lang == language:
+                    domain.reloadCatalogs(fileNames)
+
             status = _('Message Catalog successfully reloaded.')
+
         return status




More information about the Zope3-Checkins mailing list