You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently only links within RichText fields are being added as references.
I've currently got an updated method used in a project which could be a good starting point:
def build_deps(referenced_content, value):
logger = logging.getLogger(__name__)
if not value:
return
if (isinstance(value, bool) or isinstance(value, int) or
isinstance(value, NamedBlobFile) or isinstance(value, date) or
isinstance(value, NamedFile)):
# We can't do anything with these
return
elif (isinstance(value, RichTextValue) or isinstance(value, str) or
isinstance(value, unicode)):
if isinstance(value, RichTextValue):
value = value.raw
links = extractLinks(value)
for content in getObjectsFromLinks(obj, links):
referenced_content.append(getattr(content, 'context', content))
elif isinstance(value, Structure):
if value.hasContentObject:
referenced_content.append(value.getContentObject())
elif isinstance(value, dict):
for key in value:
build_deps(referenced_content, value[key])
elif isinstance(value, list) or isinstance(value, set) or isinstance(value, tuple):
for row in value:
build_deps(referenced_content, row)
elif isinstance(value, RelationValue):
referenced_content.append(value.to_object)
else:
logger.error('Could not do anything with %s (type %s)' % (value, type(value)))
The "Structure" object is a custom widget type that we've created, ideally we could just check for a 'content object' on a specific attribute so support for this can be implemented by anyone wanting their custom schema types to include referenced content.
The text was updated successfully, but these errors were encountered:
idea: use named adapters, register an adapter for each case, iterate over all adapters and let them do their work. so its easy to provide a custom adapter with an custom widget.
Currently only links within RichText fields are being added as references.
I've currently got an updated method used in a project which could be a good starting point:
The "Structure" object is a custom widget type that we've created, ideally we could just check for a 'content object' on a specific attribute so support for this can be implemented by anyone wanting their custom schema types to include referenced content.
The text was updated successfully, but these errors were encountered: