We are in the process of preparing a Plone Classic addon to work in Volto. However, after testing several times, we were unable to figure out why the computed fields and defaultFactory works fine in Plone Classic but gives the following error in Volto:
TypeError: compute_employeeID() takes 0 positional arguments but 1 was given
We were using the following code in Plone Classic:
Start your instance in foreground and when the PDB shell opens type w.
Than compare the two stacks.
Chances are that in volto it is trying to use a "context aware default factory"
It might as well be that this can be a fix valid for both classic and Volto:
from zope.interface import provider
from zope.schema.interfaces import IContextAwareDefaultFactory
@provider(IContextAwareDefaultFactory)
def compute_employeeID():
user = api.user.get_current()
property = user.getProperty('employeeID')
return str(property)