Ejemplo n.º 1
0
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)