def set_references_for_isheet(self, source, isheet: ISheet, references: dict, registry: Registry, send_event=True): """Set references of this source for one isheet. :param references: dictionary with the following content: key - isheet field name value - reference targets :param registry: Pyramid Registry with :class:`adhocracy_core.content.ResourceContentRegistry` attribute named `content`. """ sheet_meta = registry.content.sheets_meta[isheet] schema = sheet_meta.schema_class() for field_name, targets in references.items(): assert field_name in schema if targets is None: continue node = schema[field_name] reftype = getattr(node, 'reftype', None) if reftype is None: continue if IResource.providedBy(targets): targets = [targets] self.set_references(source, targets, reftype, registry, send_event=send_event)
def test_add_resource_type(self, config, resource_meta): config.include('adhocracy_core.content') self.make_one(resource_meta, config) resource = config.registry.content.create(IResource.__identifier__) assert IResource.providedBy(resource)