def reply(self): if not self.params: raise BadRequest("Missing parameter typename") # Disable CSRF protection if "IDisableCSRFProtection" in dir(plone.protect.interfaces): alsoProvides(self.request, plone.protect.interfaces.IDisableCSRFProtection) # Make sure we get the right dexterity-types adapter if IPloneRestapiLayer.providedBy(self.request): noLongerProvides(self.request, IPloneRestapiLayer) data = json_body(self.request) name = self.params.pop() dtypes = queryMultiAdapter((self.context, self.request), name="dexterity-types") ctype = dtypes.publishTraverse(self.request, name) self.update_layouts(name, data) self.remove_fields(ctype, data) self.remove_fieldsets(ctype, data) self.add_fields(ctype, data) self.add_fieldsets(ctype, data) self.update_fields(ctype, data) self.update_fieldsets(ctype, data) serializeSchema(ctype.schema) return self.reply_no_content()
def reply_for_fieldset(self, name, fieldset_name, data, create=False): context = queryMultiAdapter((self.context, self.request), name="dexterity-types") # Get content type SchemaContext context = context.publishTraverse(self.request, name) data["id"] = fieldset_name if create: info = get_info_for_type(context, self.request, name) existing = {f.get("id") for f in info.get("fieldsets", [])} if fieldset_name not in existing: add_fieldset(context, self.request, data) update_fieldset(context, self.request, data) serializeSchema(context.schema) return self.reply_no_content()