Hi, im trying to generate a default value for a field provided by a dx content schema on instance creation, which takes part of the value from a parents folder field ('kennung').
I follow the following docs:
Default values for fields on add forms
This is my DefaultFactory implementation:
> @provider(IContextAwareDefaultFactory)
> def getDefaultKennung(context):
> kennung = getattr(context, 'kennung')
> if not kennung:
> context = aq_parent(aq_inner(context))
> kennung = context.kennung
> if not kennung:
> context = aq_parent(aq_inner(context))
> kennung = context.kennung
> if not kennung:
> kennung = '<kennung>'
> else:
> kennung = kennung + '-<Nummer>'
> return unicode(kennung)
When i add an instance, it works:
But when it tries to display the created content later on after saving in its standard view, the following recursion error occurs:
Traceback (innermost last): Module ZPublisher.Publish, line 138, in publish Module ZPublisher.mapply, line 77, in mapply Module ZPublisher.Publish, line 48, in call_object Module plone.autoform.view, line 45, in __call__ Module plone.autoform.view, line 55, in _update Module z3c.form.form, line 136, in updateWidgets Module z3c.form.field, line 277, in update Module z3c.form.browser.text, line 36, in update Module z3c.form.browser.widget, line 171, in update Module Products.CMFPlone.patches.z3c_form, line 46, in _wrapped Module z3c.form.widget, line 106, in update Module z3c.form.datamanager, line 76, in query Module z3c.form.datamanager, line 71, in get Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ Module plone.dexterity.content, line 65, in _default_from_schema ... Module vhd.artikeltypen.base, line 11, in getDefaultKennung Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ Module plone.dexterity.content, line 65, in _default_from_schema Module zope.schema._bootstrapfields, line 71, in __get__ Module vhd.artikeltypen.base, line 11, in getDefaultKennung Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ Module plone.dexterity.content, line 65, in _default_from_schema Module zope.schema._bootstrapfields, line 71, in __get__ Module vhd.artikeltypen.base, line 11, in getDefaultKennung Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ Module plone.dexterity.content, line 65, in _default_from_schema Module zope.schema._bootstrapfields, line 71, in __get__ Module vhd.artikeltypen.base, line 11, in getDefaultKennung Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ Module plone.dexterity.content, line 65, in _default_from_schema Module zope.schema._bootstrapfields, line 71, in __get__ Module vhd.artikeltypen.base, line 11, in getDefaultKennung Module plone.dexterity.content, line 669, in __getattr__ Module plone.dexterity.content, line 324, in __getattr__ RuntimeError: maximum recursion depth exceeded while calling a Python object
I had a look into the plone.dexterity.content file mentioned, only to see that is tries to load a default value when access to the attribute is triggered via the getattr call in my defaultFactory causing the infinite loop.
How do i solve this Problem ? Is there another approach for my task ? Thank you very much for any advice.
System is Plone 4.3.19 with dexterity content developed on the filesystem.