From: David B. <d.b...@bi...> - 2005-11-03 15:32:54
|
Hello, In trying to add multi-language support to a product which imports OWL files into a keyword/relation-structure implemented with AT Schema ContentTypes and AT References, I am running into an infinite loop in LinguaPlone.I18NBaseObject.addTranslation(). My Environment: Python 2.3.5, Zope 2.8, Plone 2.1, LinguaPlone 0.8.5 1. The setTitle mutator of the keyword type tries to add a translation, if it is passed a language code as parameter, for which there currently is no translation for the keyword instance: def setTitle(self, title, language=""): if language: if not self.hasTranslation(language): self.addTranslation(language) self.getTranslation(language).title = title else: self.title = title 2. The unit test for the keyword content passes successfully: def testKeywordModifyTitle(self): kw = self.ctool.addKeyword('test') kw.setTitle('test_title_en') kw.setTitle('test_title_de', 'de') self.assertEqual('test_title_en', kw.title) self.assertEqual('test_title_en', kw.getTranslation('en').title) self.assertEqual('test_title_de', kw.getTranslation('de').title) 3. Calling the mutator in the import context (method importClass in my OWL importer class) with a new language ('de' in my case) results in an infinite loop in addTranslation(): kid = cl.getAttribute('rdf:ID') if kid: try: kw = ct.getKeyword(kid) except KeyError: kw = ct.addKeyword(kid) langno = 0 for label in cl.getElementsByTagName('rdfs:label'): if label.firstChild: if label.hasAttribute('xml:lang'): lang = label.getAttribute('xml:lang') else: langno += 1 lang = str(langno) kw.setTitle(label.firstChild.data.strip(), lang) 4. The expected result would be a simple addition of a new translation for the keyword with the translated title. 5. The actual result is an infinite loop in LinguaPlone.I18NBaseObject.addTranslation(): (From the importer unit test error message) Installing CMFCore ... done (0.035s) Installing CMFDefault ... done (0.060s) Installing CMFCalendar ... done (0.090s) Installing CMFTopic ... done (0.020s) Installing DCWorkflow ... done (0.047s) Installing CMFActionIcons ... done (0.041s) Installing CMFQuickInstallerTool ... done (0.188s) Installing CMFFormController ... done (0.363s) Installing ResourceRegistries ... done (0.157s) Installing GroupUserFolder ... done (0.132s) Installing ZCTextIndex ... done (0.016s) Installing ExtendedPathIndex ... done (0.050s) Installing SecureMailHost ... done (0.033s) Installing ExternalEditor ... done (0.082s) Installing CMFPlone ... done (0.766s) Installing Archetypes ... done (0.284s) Installing ATContentTypes ... done (1.849s) Installing ATReferenceBrowserWidget ... done (0.027s) Adding Plone Site ... done (11.810s) Installing PloneLanguageTool ... done (0.252s) Installing LinguaPlone ... done (0.125s) Installing Relations ... done (0.360s) Installing PloneOntology ... done (0.089s) Traceback (most recent call last): File "/usr/local/Zope-2.7/bin/test.py", line 918, in ? process_args() File "/usr/local/Zope-2.7/bin/test.py", line 908, in process_args bad = main(module_filter, test_filter, libdir) File "/usr/local/Zope-2.7/bin/test.py", line 698, in main runner(files, test_filter, debug) File "/usr/local/Zope-2.7/bin/test.py", line 599, in runner r = runner.run(suite) File "/usr/local/Zope-2.7/bin/test.py", line 366, in run return unittest.TextTestRunner.run(self, test) File "/usr/local/python235/lib/python2.3/unittest.py", line 658, in run test(result) File "/usr/local/python235/lib/python2.3/unittest.py", line 389, in __call__ test(result) File "/usr/local/python235/lib/python2.3/unittest.py", line 389, in __call__ test(result) File "/usr/local/python235/lib/python2.3/unittest.py", line 389, in __call__ test(result) File "/usr/local/Zope-2.7/lib/python/Testing/ZopeTestCase/profiler.py", line 80, in __call__ testMethod() File "/extra1/baehrens-zope/Products/PloneOntology/tests/testKeywordStorage.py", line 110, in testOWLImport message = self.st.importOWL(owl_file) File "/extra1/baehrens-zope/Products/PloneOntology/ontology.py", line 280, in importOWL error_string = importer.importClasses() File "/extra1/baehrens-zope/Products/PloneOntology/owl.py", line 311, in importClasses error_string = error_string + \ File "/extra1/baehrens-zope/Products/PloneOntology/owl.py", line 336, in importClass kw.setTitle(label.firstChild.data.strip(), lang) File "/extra1/baehrens-zope/Products/PloneOntology/keyword.py", line 114, in setTitle self.addTranslation(language) File "/extra1/baehrens-zope/Products/LinguaPlone/I18NBaseObject.py", line 80, in addTranslation while not parent.checkIdAvailable(id): File "/extra1/baehrens-zope/Products/CMFCore/PortalFolder.py", line 413, in checkIdAvailable self._checkId(id) File "/extra1/baehrens-zope/Products/CMFCore/CMFBTreeFolder.py", line 65, in _checkId PortalFolderBase._checkId(self, id, allow_dup) File "/extra1/baehrens-zope/Products/CMFCore/PortalFolder.py", line 426, in _checkId PortalFolderBase.inheritedAttribute('_checkId')(self, id, allow_dup) File "/usr/local/Zope-2.7/lib/python/OFS/ObjectManager.py", line 59, in checkValidId if isinstance(id, UnicodeType): id = escape(id) File "/usr/local/python235/lib/python2.3/cgi.py", line 1033, in escape s = s.replace("&", "&") # Must be done first! KeyboardInterrupt The last lines depend on when I break the infinite loop, but the problem seems to be, that parent.checkIdAvailable(id) never becomes true. The id of the keyword for which a 'de' title is added in the above unit test is 'abdominal_ganglion', so I don't see what is wrong with 'abdominal_ganglion-de'. Anyone having an idea of what is going wrong here? Thank you for your help, David Baehrens |