#236 — strange setTranslationImage in generatedMutator

State Resolved
Version: 3.x
Area Process
Issue type Bug
Severity Important
Submitted by Fabien Moret
Submitted on Feb 15, 2010
Target release: 3.x
No way to add a new image in a plone site 3.3.4
we're having this error:

Request URL[…]/atct_edit
Exception Type AttributeError
Exception Value setTranslationImage

Traceback (innermost last):

    * Module ZPublisher.Publish, line 119, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 42, in call_object
    * Module Products.CMFPlone.FactoryTool, line 371, in __call__
    * Module Products.CMFPlone.FactoryTool, line 155, in __getitem__
    * Module Products.CMFPlone.PloneFolder, line 348, in invokeFactory
    * Module Products.CMFCore.TypesTool, line 716, in constructContent
    * Module Products.CMFCore.TypesTool, line 276, in constructInstance
    * Module Products.CMFCore.TypesTool, line 450, in _constructInstance
    * Module Products.ATContentTypes.content.image, line 10, in addATImage
    * Module Products.ATContentTypes.content.base, line 134, in initializeArchetype
    * Module Products.Archetypes.BaseObject, line 440, in setDefaults
    * Module Products.Archetypes.Schema, line 504, in setDefaults
    * Module Products.Archetypes.utils, line 160, in mapply
    * Module Products.LinguaPlone.utils, line 143, in generatedMutator

AttributeError: setTranslationImage
Steps to reproduce:
we don't know how to reproduce
Added by Fabien Moret on Feb 22, 2010 09:44 AM
I solved the problem:

It came from a schemaextender that I use which added a field name 'image' for all content and also for ATImage content. I renamed my field in the schemaextender and it solved the problem!

issue closed.
Added by Daniel Kraft on Mar 10, 2010 04:10 PM
The reason is:
The generated mutator looks for all the translations. For this it uses getCanonical which looks them up via getTranslationReferences(). This again uses self.UID() for searching through the reference catalog.

As self.UID() is None when we're in the factory, all objects are found. getCanonical uses item[0] from that list to find the referenced objects. item[0] in our case was a folder, so we got several folders (item[0]'s translations) back. The generatedMutator searched in these fields. This leads to the above exception.

The fix is this:

> diff -C10 old new
*** old 2010-03-10 17:11:05.000000000 +0100
--- new 2010-03-10 17:10:30.000000000 +0100
*** 473,508 ****
--- 473,514 ----
          ti = DynamicType.getTypeInfo(self)
          if ti is not None and not self.isCanonical():
              return TypeInfoWrapper(ti)
          return ti

      security.declareProtected(permissions.View, 'getTranslationReferences')
      def getTranslationReferences(self, objects=False):
          """Get all translation references for this object"""
          sID = self.UID()
+ if not sID:
+ # We're in the factory maybe.
+ return []
          tool = getToolByName(self, REFERENCE_CATALOG)
          brains = tool._queryFor(sid=sID, relationship=config.RELATIONSHIP)
          if brains:
              if objects:
                  return [
                      for brain in brains
                  return brains
          return []

      security.declareProtected(permissions.View, 'getTranslationBackReferences')
      def getTranslationBackReferences(self, objects=False):
          """Get all translation back references for this object"""
          tID = self.UID()
+ if not tID:
+ # we're in the factory
+ return []
          tool = getToolByName(self, REFERENCE_CATALOG)
          brains = tool._queryFor(tid=tID, relationship=config.RELATIONSHIP)
          if brains:
              if objects:
                  return [
                      for brain in brains
                  return brains
Added by Hanno Schlichting on Mar 29, 2010 12:35 PM
Issue state: UnconfirmedConfirmed
Severity: MediumImportant
Target release: None3.x
There's been other reports of this with slightly different symptoms.
Added by Hanno Schlichting on Mar 29, 2010 01:11 PM
Issue state: ConfirmedResolved
Thanks for the patch, applied with tests to SVN. This will be released in 3.1a2.
Added by Graham Perrin on Mar 31, 2010 08:10 PM
referred to this #236 from #237 via #239

No responses can be added.