Package: plone.app.linkintegrity
plone.app.linkintegrityOverviewThis package implement link integrity checking in Plone.  It makes use of the
zope3 event system in order to modify Plone itself as little as possible.FeaturesThis package handles deleting an item in the Plone-User-interface (i.e.
deleting items in the viewfolder_contentsvia Actions / Delete).Whenever an object that is referred to by another one via an<a>or<img>tag is going to be deleted, a confirmation form is presented to the user.
The same applies to content referenced via a relation field and indexed in thezc.relationcatalog, like via the related items behavior.
They can then decide to indeed delete the object, breaching link
integrity of the site or first edit the objects that link to the item in
question.For relations set in a textfield, theisRelatedreference is used.
For these references, plone.app.linkintegrity also handles modifications, if a content related viaisRelatedis modified.
For all other related content, other mechanisms handle updates.
One such handler can be found inplone.app.relationfield.Changes in 3.0Linkintegrity-relations are no longer stored in reference_catalog of
Products.Archetypes. Instead it used zc.relation.No longer intercept the request onmanage_deleteObjects.
This means that deleting with other methods (like manage_deleteObjects,
plone.api.content.delete, ttw in the ZMI) no longer warns about
linkintegrity-breaches. It now simply adds information about
linkintegrity-breaches in the user-interface.LinkIntegrityNotificationException is not longer thrown anywhere.Refresh the linkintegrity site statusIn the case you’ll need to update/refresh the linkintegrity status of the
whole site, you can call the@@updateLinkIntegrityInformationview.It can be really slow operation.CustomizationOn object created, added, modified events themodifiedContenthandler
is called. This handler adapts anIRetrieverobject if found.
The package comes with one general adapter for Dexterity content.
You can easily write custom adapters implementing theIRetrieverinterface for your content type. Look at theretrievermodule in this
package for examples.APITo check if there would be breaches when deleting one or more objects
you can use the following code:fromploneimportapiportal=api.portal.get()view=api.content.get_view('delete_confirmation_info',portal,self.request)breaches=view.get_breaches([obj1,obj2])get_breachesignores breaches originating from any items that would also be
deleted by deleting the items (and their children if an item is a folder).Each breach inbreachesis a dictionary with atarget(a dict with some
info on the object to be deleted) and a list ofsources.
Each source is again a dict withuid,title,urlandaccessible(a boolean telling you if the user can access that source).To check items for links in html-fields you can use the methods inplone.app.linkintegrity.utils:utils.hasIncomingLinks(obj)Test if an object is linked to by other objects.utils.hasOutgoingLinks(obj)Test if an object links to other objects.utils.getIncomingLinks(obj, from_attribute)Return a generator of incoming relations.from_attributeis optional and defaults toplone.app.linkintegrity.utils.referencedRelationship.
Is set to None, all references pointing to the object are searched.utils.getOutgoingLinks(obj, from_attribute)Return a generator of outgoing relations.from_attributeis optional and defaults toplone.app.linkintegrity.utils.referencedRelationship.
Is set to None, all references pointing from the object are searched.utils.linkintegrity_enabled()Test if linkintegrity-feature is enables for users.Changelog4.0.3 (2023-09-29)Bug fixes:Report sources once per breach in delete_confirmation_info.
[jaroel] (#95)4.0.2 (2023-08-31)Bug fixes:Remove outgoing ‘isReferencing’ RelationValues from catalog on deleting content item.
[ksuess] (#93)Internal:Update configuration files.
[plone devs] (7723aeaf)4.0.1 (2023-04-14)Internal:Update configuration files.
[plone devs] (5623f8b3)4.0.0 (2023-03-13)Breaking changes:Drop compatibility for Plone 5.2.  Support Plone 6 only.
[maurits] (#60)Bug fixes:Fixed test layer setup.
Created content was bleeding into layers from other packages.
[maurits] (#846)3.6.1 (2022-04-28)Bug fixes:Test fix: only load plone.app.contenttypes migration layer on Python 2.
[maurits] (#641)3.6.0 (2022-02-23)New features:Track link integrity of referenced PDFs and other site objects in IFRAME SRC references. (#84)3.5.0 (2021-12-29)New features:Track integrity of video and audio files in HTML source tags. (#77)3.4.1 (2021-03-02)Bug fixes:Use base64.decodebytes instead of decodestring when possible.
Fixes Python 3.9 compatibility in the tests.
[maurits] (#81)3.4.0 (2021-02-23)New features:Drop Plone 5.1 support, due to possible incompatibility with older plone.app.uuid.
[maurits] (#79)Bug fixes:Fix Unauthorized exception when you edit a page that links to another page that you are not allowed to see.
Fixesissue 79.
[maurits] (#79)3.3.14 (2020-09-07)Bug fixes:Fixed deprecation warning for ComponentLookupError.
[maurits] (#3130)3.3.13 (2020-04-20)Bug fixes:Minor packaging updates. (#1)3.3.12 (2019-10-12)Bug fixes:Explicitly load zcml of dependencies, instead of usingincludeDependencies.
[maurits] (#2952)3.3.11 (2019-06-27)Bug fixes:Add missing i18n:translate calls
[erral] (#73)3.3.10 (2019-06-19)Bug fixes:Accept to have a broken object w/o aq_parent in test.
[jensens] (#72)3.3.9 (2019-05-01)Bug fixes:Fix wrong i18n:translate to avoid ${DYNAMIC_CONTENT} in translation files
[erral] (#69)3.3.8 (2019-02-08)No significant changes.3.3.7 (2018-09-23)Bug fixes:Fix tests in Python 3
[pbauer]3.3.6 (2018-06-19)Bug fixes:Fix test to work with merged plone.login.
[jensens]Python 3 compatibility.
[pbauer]3.3.5 (2018-04-04)Bug fixes:Mark strings in delete confirmation screen translatable
[erral]3.3.4 (2018-02-04)Bug fixes:Optimize migration of old Archetypes references.
[davisagli]Prepare for Python 2 / 3 compatibility.
[ale-rt, pbauer]3.3.3 (2017-10-02)New features:Prevent linkintegrity-handler from doing anything when it is switched of in the registry.
This change also prevents some issues in migration from AT to DX since linkintegrity is disabled during the migration.
[pbauer]Bug fixes:Fix a missing tal condition indelete_confirmation_info.ptthat caused a
paragraph to be always visible, even without link breaches.
[arsenico13]Fix view @@updateLinkIntegrityInformation after Language=’all’ no longer works.
[pbauer]3.3.2 (2017-08-14)Bug fixes:Do not fail on invalid objects in reference_catalog.
Fixesissue 32and48.
[pbauer]Fix undeclared hard dependency on Archetypes
[tomgross]3.3.1 (2017-06-01)Bug fixes:Improved code quality.  [gforcada]removed unittest2 dependency
[kakshay21]3.3 (2017-04-20)New features:Support for anyzc.relationrefercences being checked bydelete_confirmation_infodialog,
not only references linked in text.
[thet]Bug fixes:PEP8.
[thet]Update code to follow Plone styleguide.
[gforcada]3.2.2 (2017-04-02)New features:Use plone.namedfile for testing images
[didrix]Bug fixes:Fix typo in logging method
[tomgross]3.2.1 (2017-02-20)Bug fixes:Show breakage info even if catalog is out of sync
[tomgross]3.2.0 (2017-02-12)New features:Compatibility with ZCatalog 4 (upgrade steps)
[pbauer, jensens]3.1 (2016-12-30)New features:Information about contents within a selected folder for deletion.
This information contains number of deleted objects,
number of subfolders and number of published objects.
[karalics]3.0.8 (2016-11-09)Bug fixes:Add coding headers on python files.
[gforcada]Remove hard dependency on Archetypes (again).
[davisagli]3.0.7 (2016-09-16)Bug fixes:Use transaction savepoints while calling @@updateLinkIntegrityInformation
to keep memory usage under control.
[ale-rt]3.0.6 (2016-08-17)Bug fixes:Fix object url in delete confirmation
[vangheem]Use zope.interface decorator.
[gforcada]3.0.5 (2016-04-15)Fixes:Fix test isolation problems: if a test calls transaction.commit() directly or
indirectly it can not be an integration test, either avoid the commit or
change the layer into a functional one.
Fixes:https://github.com/plone/plone.app.linkintegrity/issues/36[gforcada]3.0.4 (2016-02-02)Fixes:Handle links that do not have an intid yet. Should help with
upgrade issues.
[vangheem]make handler.findObject() work when the webserver rewrites the portal name
[tschorr]3.0.3 (2015-11-26)New:Introduce IRetriever adapter for customization flexibility.
[tomgross]3.0.2 (2015-09-27)Remove xml:lang and wrong xmlns from delete_confirmation_info.pt.
[vincentfrentin]3.0.1 (2015-09-11)Don’t show delete_confirmation_info twice in delete_confirmation. Fixes #27
[pbauer]3.0 (2015-09-08)Drop the Archetypes-dependency by switching to use zc.relation instead of
reference_catalog (Products.Archetypes).
[bloodbare, pbauer, vangheem]No longer intercept the request on manage_deleteObjects. Instead only
inject a warning in delete_confirmation. This means that deleting with
other methods (like manage_deleteObjects, plone.api.content.delete, ttw
in the ZMI) no longer warns about linkintegrity-breaches.
[bloodbare, pbauer, vangheem]LinkIntegrityNotificationException is not longer thrown anywhere.
[bloodbare, pbauer, vangheem]2.1.2 (2015-05-04)Fix html structure in confirmation.pt
[vincentfretin]2.1.1 (2015-03-13)When using the update view for dexterity objects, only call the method if
object provides IReferenceable
[frapell]Removed Zope 2.10 compatibility from publisher monkey patch.
[davisagli]2.1.0 (2014-10-23)Read the enable_link_integrity_checks setting from plone.app.registry
instead of from the portal_properties.
[timo]Restructure package to fully support dexterity framework. Use two different
test layers inplone.app.testing, migrate all doctests into real
TestCases.
[saily, do3cc]2.0.0 (2014-04-13)Adapt tests for removal of DT, DD and DL elements.
Remove DL’s from portal message in templates.https://github.com/plone/Products.CMFPlone/issues/153[khink, mrtango]1.5.6 (2015-08-13)Backport improvements to@@updateLinkIntegrityInformationfrom
plone5 branch.
[pbauer]1.5.4 (2014-01-27)Added support for sub path after uid of resolveuid
[hoka]1.5.3 (2013-08-13)Set a maxsize when decompressing request data.
[davisagli]Fixed dexterity referenceablebehavior integration.
[maurits]Fix #13681, documents referencing each other will now also trigger a link
integrity warning.
[do3cc]1.5.2 (2013-05-23)Exceptions now return the repr() and not the str() of the object. This way
we avoid, for File content types, loading the whole object data into memory.
This closeshttps://dev.plone.org/ticket/13519[ericof]1.5.1 (2013-03-05)unicode links should not raise errors. Fixeshttps://dev.plone.org/ticket/13468[vangheem]Dexterity: use zope.lifecycleevent instead of zope.app.container
interfaces for Plone 4.3 support.
[jone]Avoid a bug during link integrity check when a source or target of the
reference has been already removed during the deletion process.
This can happen during large delete processes.
[thomasdesvenain]Monkey patch the Zope HTTPResponse status_code to include a mapping for
linkintegritynotificationexception, to return a 200 code.
[thepjot]1.5.0 (2013-01-17)Fix a remove confirmation view bug.
Displays the portal type title rather than the portal type name.
This change also broke some tests that were checking for the name
rather than the title, but I just fixed those.
[jianaijun]Added support for Dexterity content types.  Link integrity
support for Dexterity requires the plone.app.referenceablebehavior
behavior to be enabled so that the Dexterity item can be used
with Archetypes references.
[jpgimenez]1.4.7 (2012-10-03)Fixes UnicodeDecodeError on extractLinks
This closeshttps://dev.plone.org/ticket/13168[ericof]1.4.6 (2012-07-02)No more zope.app dependencies.
[hannosch]Remove hard dependency on Archetypes.
[davisagli]1.4.5 - 2012-02-24Fix an error in handling absolute links to objects within the portal,
which prevented references from being created based on those links.
This closeshttps://dev.plone.org/ticket/12402[davisagli]Stabilize the sort order of breach sources returned for the
confirmation view.
[davisagli]Use thegetmethod to retrieve the field value if the instance
does not provide an accessor method. This is the case for instance
for fields which have been added via schema extension.
[malthe]Support resolveuid/UID references explicitly, by parsing and resolving
these ourselves instead of relying on a view or script (which doesn’t work).
This fixes linkintegrity for sites with link-by-uid turned on.
This closeshttps://dev.plone.org/ticket/12104[mj]1.4.4 - 2011-10-04Add integrity references for cloned content items.
This fixeshttp://dev.plone.org/plone/ticket/12254.
[gotcha]Skip events subscribers during copy&paste of content items.
This fixeshttp://dev.plone.org/plone/ticket/12206.
[gotcha]Provide Archetypes-only fallback ifplone.uuidis not available,
restoring compatibility with Plone 4.0.x.
[witsch]1.4.3 - 2011-09-14Fix integrity reference generation for content not accessible by the editor.
[witsch]Fix handling of relative links instead of relying on Acquisition.
[witsch]1.4.2 - 2011-07-04Objects that don’t have a UUID cannot cause linkintegrity-breaches.
This fixeshttp://dev.plone.org/plone/ticket/11904.
[WouterVH]Adjust tests to the changed URL used for thefolder_contentsview.
This refshttp://dev.plone.org/plone/ticket/10122.
[gotcha]Add new tests to proveisLinkedcan now be used safely.
This refshttp://dev.plone.org/plone/ticket/7784.
[gotcha]1.4.1 - 2011-05-12Fix decoding of colon-delimited list of confirmed oids in the request
when one of the oids contains a colon.
[davisagli]Add MANIFEST.in.
[WouterVH]1.4.0 - 2011-01-03Useplone.uuidto look up content UUIDs.
[toutpt, davisagli]1.3.3 - 2011-07-05Add new tests to proveisLinkedcan now be used safely.
This refshttp://dev.plone.org/plone/ticket/7784.
[gotcha]1.3.2 - 2011-05-12Fix decoding of colon-delimited list of confirmed oids in the request
when one of the oids contains a colon.
[davisagli]1.3.1 - 2010-08-08Adjusted tests to no longer rely on sub-collections.
[hannosch]Use the officialaq_getAPI to acquire the request from a context.
[hannosch]1.3.0 - 2010-07-18Update license to GPL version 2 only.
[hannosch]1.3b2 - 2010-06-13Avoid using the deprecated five:implements directive.
[hannosch]1.3b1 - 2010-06-03Fix findObject to also catch the ZTK NotFound exception which may be
raised by request.traverseName. Fixeshttp://dev.plone.org/plone/ticket/10549[davisagli]1.3a5 - 2010-05-01Properly handle retry exception instead of getting the special-casing of
exception handling when publishing with debug=1
[davisagli]1.3a4 - 2010-03-06Do not abort if a text field isNone. In that case the HTML parser
raises aTypeErrorinstead of anHTMLParseError.
[wichert]1.3a3 - 2010-02-18Updated templates to match recent markup conventions.
Referenceshttp://dev.plone.org/plone/ticket/9981[spliter]Convert test setup tocollective.testcaselayer.
[witsch]Updated tests to not rely on specific CSS classes or ids.
Refshttp://dev.plone.org/plone/ticket/10231[limi, witsch]1.3a2 - 2009-12-02Fix issue with the final submission of the delete confirmation page in
Zope 2.12. This closeshttp://dev.plone.org/plone/ticket/9699.
[davisagli]1.3a1 - 2009-11-17Access the subtopics page directly since the tab is now hidden by default.
[davisagli]Partially disable the test regarding the undo log as the outcome differs
between Plone 3 and 4, probably due to changes in the test setup.
Refshttp://dev.plone.org/plone/ticket/7784[witsch]Add test to verify undo log entries are not longer missing after removing
items via the “delete” action.  Refshttp://dev.plone.org/plone/ticket/7784[witsch]1.2 - 2009-10-10Also catchNotFoundexceptions when trying to resolve linked objects.
[optilude]1.1 - 2009-08-31Make compatible with repoze.zope2. See README.txt for notes on how to
deploy.
[optilude]Don’t use id() to record confirmed items. It can change on request
boundaries. Use an encoded _p_oid instead.
[optilude]Also regard traversal adapters when trying to resolve links into their
corresponding objects.
[witsch]Fix some tests to make sure that text values are treated as text/html
in Zope 2.12, whose zope.contenttype is stricter when guessing the
mimetype.
[davisagli]Don’t install the exception hook in Zope 2.12 where it is no longer
needed and breaks exception handling.
[davisagli]1.0.12 - 2009-06-03Compare UIDs instead of objects during cleanup of breach information in
order to avoid expensive hashing in “… in …” expressions.  This
makes removing linked objects much faster.
[regebro]1.0.11 - 2008-11-15Fix code to not silently swallowConflictErrors.
[witsch]Fix issue with dangling references to already removed objects.
Fixeshttp://dev.plone.org/plone/ticket/8349andhttp://dev.plone.org/plone/ticket/8390.
[witsch]1.0.10 - 2008-07-07Fixed the recognizing of links to files (or any object) with a
space in the id.  Fixeshttp://dev.plone.org/plone/ticket/8167.
[maurits]Updated tests to work with LinguaPlone by unmarking the creation
flag on new objects.
[maurits]1.0.9 - 2008-05-08Use acquisition API to support the “philikon-aq” branch.
[witsch]Fix a problem with updating link integrity references during a
request which trying to delete multiple other objects.
[witsch]1.0.8 - 2008-04-21Added missing i18n markup toconfirmation.pt, also fixinghttp://dev.plone.org/plone/ticket/7995.
[witsch]1.0.7 - 2008-03-27Fixed accidental removal of references not related to link integrity.
[dunny]1.0.6 - 2008-03-08Added missing namespace declaration to avoid the warning about it.
[wiggy]1.0.5 - 2008-02-13Added missing i18n markup to confirmation.pt. This closeshttp://dev.plone.org/plone/ticket/7688.
[hannosch]1.0.4 - 2008-01-03HandleIObjectRemovedEventswith no attached request object.
[witsch]Updated tests to work with Plone 4.0.
[hannosch]Referencing items are now listed in alphabetical order
[witsch]1.0.3 - 2007-12-05Fixed setting up the test layer after GenericSetup update
[witsch]1.0.2 - 2007-11-07Fixed parser error when handling malformed HTML
[witsch]Fixed security issue due to using pickles (see CVE-2007-5741)
[witsch]1.0.1 - 2007-09-10Added view for updating link integrity information for all site content
[witsch]Made code in info.py more tolerant when encountering missing property
sheets.
[hannosch]1.0 - 2007-08-16Minor bug fixes and enhancements
[witsch]1.0rc1.1 - 2007-07-12Bug and test fixes after upgrade to Zope 2.10.4
[witsch]1.0rc1 - 2007-07-08Bugfixes & additional tests
[witsch]1.0b3 - 2007-05-04No changes.1.0b2 - 2007-04-30Integration of Plone’s “delete confirmation” page
[witsch]1.0b1 - 2007-03-03Fix tests in regard to changedfolder_contentsand unicode issues
[witsch]Updates to the monkey patch needed for five exceptions
[wiggy]1.0a2 - 2007-02-07Bugfixes & other minor enhancements
[witsch]Eggification and move into plone.app namespace
[optilude]Proof of concept & initial version
[witsch]Initial package structure.
[zopeskel]