Skip to content

References to certain content items are not stored if they've had the ReferencableBehaviour applied after creation #24

@neilferreira

Description

@neilferreira

I've got some dexterity content items that did not have the referencable behaviour applied to them at the time of creation. As a result some of the references are being stored, but then coming back as "None" as the referencable class is unable to load the related content via its uid.

Perhaps plone.app.linkintegrity should check that an item exists inside the uid_catalog (and throw an error/warning) if the relationship would be broken.

I've taken some code adapted from this link and added it to my indexer: https://groups.google.com/forum/#!msg/dexterity-development/wUd5lEWtrFg/IqCnQOUdsdkJ

def fix_missing_uid_catalog_object(obj):
    ''' From https://groups.google.com/d/msg/dexterity-development/wUd5lEWtrFg/IqCnQOUdsdkJ

        Existing content items created before the referencable behaviour was added
        are not present in the uid_catalog and therefore can not be indexed.
    '''
    uid_catalog = getToolByName(obj, 'uid_catalog')
    path = '/'.join(obj.getPhysicalPath())
    rids = uid_catalog._catalog.indexes['UID']._index.get(obj.UID(), None)
    if rids is None:
        uid_catalog.catalog_object(obj, path)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions