Tobias
Tobias

Reputation: 2561

Auto-renaming of new Archetypes objects (Plone 4) stopped to work

I have a Plone 4 site which stopped to rename new Archetypes objects; after creation (as something like /temp/portaltype.2015-04-23.1234567890) and saving the first changes, including giving it a title, it should be renamed to something nicer (/temp/an-object-with-a-meaningful-name), but this doesn't happen anymore.

Perhaps the problem arose when I applied some changes to update Plone from 4.3.3 to 4.3.4 (to make one step at a time); but I have inherited a long versions.cfg which is solely sorted by package names and doesn't include any hints why certain versions were chosen ...

I'm able to go back two months and have a version which does the renaming, but without more knowledge about what to look for, it will be a very time-consuming process of re-applying every single change, rebuilding, starting and testing; but there have not been any changes to my schema definitions. I have a temp browser which is involved in delivering the primary edit form. but this doesn't seem to be the case for the saving action.

Sadly I don't fully understand yet the mechanisms of the base_edit action which should - as far as I understand - call Archetypes.BaseObject.processForm and implicitly ._renameAfterCreation, so I'd be grateful for some pointers how to debug this. Thank you!

Update: I have a few triggers in my product's configure.zcml, e.g.:

<subscriber
    for=".content.portaltype.PortalType
         Products.Archetypes.interfaces.IObjectInitializedEvent"
    handler=".events.onInitPortalType"/>

… with, in events.py:

def onInitPortalType(self, event):
    """
    Called after first edit of new objects?
    """
    print '/// onInitPortalType(%(self)r, %(event)r)' % locals()
    setInitialOwner(self, event)
    setStateToPrivate(self, event)

However, the event doesn't seem to be triggered, since I couldn't find the output in an instance fg session.

Update 2: I noticed that zope.event had been pinned to a quite old version (3.5.2), so I'm trying to update to 4.3.4 more seriously now (following this how-to). This got me zope.event v4.0.3, but I have a version conflict now:

There is a version conflict.
We already have: zc.recipe.egg 1.3.2.
While:
  Installing.
  Getting section test.
  Initializing section test.
  Installing recipe zc.recipe.testrunner.

There seems to be a requirement for zc.recipe.egg < 2dev somewhere, but I can't find it.

Upvotes: 1

Views: 75

Answers (1)

Mathias
Mathias

Reputation: 6839

Nothing significant changed between Plone 4.3.3 and 4.3.4 on Archetypes. Products.Archetypes changed from 1.9.7 to 1.9.8 and Products.ATContentTypes remains on the same version.

Pointers could be:

  • There's a _at_rename_after_creation flag, which is True by default. This can be changed on the content type class.
  • Is your type still activated in portal_factorytool? (Afaik this should have no impact on renaming after creation - but who knows :-))
  • Any Products.Archetypes.interfaces.IObjectInitializedEvent subscriber?
  • Issue I had once was, that the tmp id portaltype.2015-04-23.1234567890 had the wrong format and AT did no recognise it as tmp id and therefore it did not rename it after creation. The method AT uses to check if the id is autogenerated --> https://github.com/plone/Products.CMFPlone/blob/4.3.4/Products/CMFPlone/utils.py#L111 AFAIK the problem was, that the meta_type and portal_type was not the same anymore.

Upvotes: 2

Related Questions