[Zope] Let Zope chec a internal / external link

Tino Wildenhain tino at wildenhain.de
Tue Sep 21 16:56:04 EDT 2004


Hi,

Am Di, den 21.09.2004 schrieb Martin Koekenberg um 18:32:
> Hello,
>  
> Is is possible tolet Zope check if a link is correct. 
>  
> Example: 
> I've a Photoalbum an news items. These are connected with a link. But
> whem i move a news item to a archive, the link becomes broken. How can
> I prevent this error ? 
>  
> Is it also possible to check external links ? 'If a link doesn't exist
> anymore there stilis a broken link on the website. Question Can I
> preven zop displaying broken links ? 
>  
> I know this feature from tridion CMS (my seccond love ;-)
>  
> Thanks for the help.

Yes it is. You need a basic html parser (at least a regular
expression), some scripts, and /or a derived document object
(from ZPT for examle), ZCatalog and a crontab entry (
for regular check of external links). Depending on
skills and experience it should take you from 1 to 5 days.

Replace all links on upload/document change with a call to
your internal link checker like this:

<a href="http://foo.bar.com/foo/bar">Foobar</a>
becomes:
<a tal:condition="here/check/12345" 
   href="http://foo.bar.com/foo/bar">Foobar</a>

Where check must be an object which knows 12345 
is the key for entry http://foo.bar.com/foo/bar
looks it up in the ZCatalog (see "catalog almost
everything" howto) and returns true or false
depending on the state in catalog in a method
__getitem__ on this check object.

Ideally all your documents are catalogaware
so you can check their existence when you
change something. External links have to be 
checked via cronjob and urllib I'd say.

Regards
Tino





More information about the Zope mailing list