link integrity on Rich Text tile references #35

Closed
hvelarde opened this Issue Jun 26, 2012 · 7 comments

Projects

None yet

3 participants

@hvelarde
Member

when a user deletes an object referenced by a tile we need to show a warning message like this: "This item is used by xxxxxxxx frontage. Delete it anyway?"

@jpgimenez jpgimenez was assigned Sep 18, 2012
@runyaga
runyaga commented Aug 29, 2013

FWIW: Any issue like this which can cause a catastrophic failure (collective cover breaking because of missing reference) should be considered not only a bug but something more catastrophic (maybe "hardfail" ;-); in that a user will report a broken page

@jpgimenez
Member

First some things should be clarified and defined before implement this.
p.a.linkintegrity work this way: every time an object is created, modified, removed, it tries to find TextField or dexterity RichText field to extract the links inside it... then it uses those links, the internal ones, to create relations between the target object and the object than fired the event.

p.a.linkintegrity and tiles: tiles aren't objects, they don't fire any event on modification because even persistent tiles just modify annotations on the parent object, in out case the cover, and modifications to annotations on the parent cover doesn't fire a modified event neither.

I think than the following should be done:

  • Tile's data manager should fire an zope.lifecycleevent.interfaces.IObjectModifiedEvent for the context of the tile. This could be implemented into our datamanager or, even better, into plone.tiles.
  • We need a handler for that event than understand how to extract relations over the annotated data. I'm thinking than here maybe we need an adapter, nor a handler, because archetypes and dexterity objects could be the context objects of persistent tiles. This code should be implemented into p.a.linkintegrity
@jpgimenez jpgimenez closed this Aug 30, 2013
@jpgimenez jpgimenez reopened this Aug 30, 2013
@hvelarde
Member

collective.cover tiles fire ObjectModifiedEvent every time a tile is modified, as you can see here:

https://github.com/collective/collective.cover/blob/master/src/collective/cover/tiles/base.py#L124

for the other stuff, I would love to wait for @runyaga comments, but I don't think putting stuff for tiles inside p.a.linkintegrity is a good idea...

@runyaga
runyaga commented Aug 30, 2013

maybe cover tiles need to grow link integrity feature? and there is a cover utility which subscribes to IObjectRemovedEvent to compare if an item pending removal has a UUID that cover references. It is only the REmoveEvent that should be cared about -- iirc

@jpgimenez
Member

@hvelarde you are right, base class is firing events in several places, but I think than that could be better handled by data manager... that way every tile will have linkintegrity support...

@jpgimenez
Member

@runyaga we don't need to listen to IObjectRemovedEvent because that its already handled by linkintegrity, we only need to add the references... that could be done into the datamanager or into linkintegrity... we have now a really specific code to get the references (https://github.com/plone/plone.app.linkintegrity/blob/master/plone/app/linkintegrity/handlers.py#L174)... we can have that kind of handler for tiles... an then we store the references between the target of the link and the parent object of the tile, because the tile isn't an object, in our case the parent is the cover... doing that its simple, just try to remove the target and Plone will warn you about the broken link...

@hvelarde hvelarde referenced this issue Sep 17, 2013
Merged

Link integrity #289

@hvelarde
Member

we need to implement this for any tile referencing an object, not only on RichText tiles; according to @ericof there could be a potential issue on p.a.blocks: if a user just deletes the object ignoring the message we could have a broken cover.

@hvelarde hvelarde closed this in #289 Sep 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment