Skip to content

Personal tools
You are here: Home » CMFLinkChecker » Documentation » Developers HOWTO

Developers HOWTO

Howto write retrievers for CMFLinkChecker

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

Created by admin
Last modified 20.06.2005 15:54
 

Powered by Plone

This site conforms to the following standards: