adhocracy3
adhocracy3 copied to clipboard
incomplete detection of references on deepPost (batch API)
The batch API allows to send a sequence of virtual requests in a single physical request. deepPost
is an abstraction in the frontend that allows to post an arbitrarily ordered list of resources. The algorithm determines the order in which the resources need to be posted by looking at its references.
Unfortunately, it is not trivial to determine which fields are references. The frontend currently does this by checking whether the valuetype
in the meta API is "adhocracy_core.schema.AbsolutePath"
. However, there are some other valuetypes that also constitute references, e.g. "adhocracy_core.schema.Reference"
or "adhocracy_core.schema.PostPool"
.
@pallix proposed to check for the existence of a targetsheet
in the meta API. @joka do you think this would work?
Note: I did never experience any issue with this in practice. I found the issue while refactoring the code.
We should fix the meta api to make this more simple. At the moment we have the following Meta Api Field types with References:
Resource:
data format: resource url (or path)
valuetype: adhocracy.core.schema.Resource
should always be readonly
Resources:
valuetype: adhocracy.core.schema.Resource
containeertype: list
should always be readonly
Reference:
data format: resource url (or path)
valuetype: adhocracy.core.schema.Reference
targetsheet: ISheetXY
may be readonly and backreference
may be readonly
References:
valuetype: adhocracy.core.schema.Reference
containertype: list
valuetype: adhocracy.core.schema.AbsolutePath
may be readonly
[NOTE AbsolutePath wrong, Reference is right]
PostPool
data format: resource url (or path)
valuetype: adhocracy.core.schema.PostPool
targetsheet: ISheet
should always be readonly
I propose we:
- reduce Reference fields to Reference and References
- Fix: References valuetype should be
Reference
To figure out what are References the Frontend has to:
- check valuetype == Reference
- check if not readonly (editable or createable is True)
Its also handy if we not only reference sheet type but also resource types. For this we would have to change the metaapi. What do you think?
Its also handy if we not only reference sheet type but also resource types. For this we would have to change the metaapi. What do you think?
We have to mind: the targetsheet of reference fields is used to create the corresponding backreference field
Thanks for the breakdown! I did not think about containertypes before.
It sounds like yet another task on the long refactoring list. We have not seen any issues in the wild yet, so IMHO this tasks does not need to be highly prioritized.
@joka but for the short term, is checking for targetsheet okay? It seems to me that it is created for all sheet having a 'reftype', thus for all references?