Developers HOWTO
Meta
Copyright (c) 2003-2005 gocept gmbh & co. kg See also LICENSE.txt
| Valid for: | CMFLinkChecker 1.9 |
|---|---|
| Author: | Christian Zagrodnick <cz@gocept.com> |
| CVS: | $Id: HOWTO-Developers.txt,v 1.3 2005/04/11 11:01:57 zagy Exp $ |
CMFLinkchecker and Custom Content Types
Imagine you built a content type to manage a simple link list and you want those links to be checked. Here's some explanatory code for the link list:
class LinkList(...):
portal_type = 'LinkList'
...
def addLink(self, link):
self._links.append(link)
def listLinks(self):
return self._links
...
What you need to support CMFLinkChecker is a retriever. A retriever a kind of adapter between your content object and CMFLinkChecker. A retriever must implement the IRetriever interface (see also interfaces.py):
class IRetriever(Interface):
"""A class that implements a routine to find all links from a given
object."""
name = Attribute("Name of the retriever, suitable to identify it.")
defaults = Attribute("A list of portal_types this retriever is a "
"default for.")
def __call__(self, object):
"""Finds all links from the object and return them.
Returns a list of URLs.
"""
A retriever for the LinkList class might look like this:
from Products.CMFLinkChecker.interfaces import IRetriever
from Products.CMFLinkChecker.retrievemanager import GlobalRegistry
class LinkListRetriever(object):
"""linklist retriever"""
__implements__ = (IRetriever,)
name = "MyNiceLinkListRetriever"
defaults = ["LinkList"]
def __call__(self, object):
return object.listLinks()
GlobalRegistry.register(LinkListRetriever())
What you might need to do now is to set the portal_type retriever mapping in the 'Link Management'-Portlet