def handle_modified(self, content): fieldmanager = ILanguageIndependentFieldsManager(content) if not fieldmanager.has_independent_fields(): return sm = getSecurityManager() try: # Do we have permission to sync language independent fields? if self.bypass_security_checks(): # Clone the current user and assign a new editor role to # allow edition of all translated objects even if the # current user whould not have permission to do that. tmp_user = UnrestrictedUser( sm.getUser().getId(), '', ['Editor', ], '') # Wrap the user in the acquisition context of the portal # and finally switch the user to our new editor acl_users = getToolByName(content, 'acl_users') tmp_user = tmp_user.__of__(acl_users) newSecurityManager(None, tmp_user) # Copy over all language independent fields transmanager = ITranslationManager(content) for translation in self.get_all_translations(content): # PATCHED CODE HERE trans_obj = transmanager.get_restricted_translation(translation) if trans_obj: if fieldmanager.copy_fields(trans_obj): self.reindex_translation(trans_obj) # END PATCHED CODE finally: # Restore the old security manager setSecurityManager(sm)
def handle_modified(self, content): canonical = ITranslationManager(content).query_canonical() if canonical in self.stack: return else: self.stack.append(canonical) # Copy over all language independent fields translations = self.get_all_translations(content) manager = ILanguageIndependentFieldsManager(content) for translation in translations: manager.copy_fields(translation) schema = content.Schema() descriptions = Attributes(schema) self.reindex_translations(translations, descriptions) self.stack.remove(canonical)
def handle_modified(self, content): canonical = ITranslationManager(content).query_canonical() if canonical in self.stack: return else: self.stack.append(canonical) # Copy over all language independent fields translations = self.get_all_translations(content) manager = ILanguageIndependentFieldsManager(content) for translation in translations: manager.copy_fields(translation) # fti = getUtility(IDexterityFTI, name=content.portal_type) # schema = fti.lookupSchema() schema = content.Schema() descriptions = Attributes(schema) self.reindex_translations(translations, descriptions) self.stack.remove(canonical)
def __call__(self, obj): li_clonner = ILanguageIndependentFieldsManager(self.context) li_clonner.copy_fields(obj)