Back to index

plone3  3.1.7
relation.py
Go to the documentation of this file.
00001 ##########################################################
00002 #
00003 # Licensed under the terms of the GNU Public License
00004 # (see docs/LICENSE.GPL)
00005 #
00006 # Copyright (c) 2005:
00007 #   - The Open Planning Project (http://www.openplans.org/)
00008 #   - Whit Morriss <whit@kalistra.com>
00009 #   - and contributors
00010 #
00011 ##########################################################
00012 
00013 """
00014 BackLink
00015 ~~~~~~~~
00016 
00017 A type of reference that can be used/extended to provide smarter
00018 inter-document linking. With the support of an editor this can be
00019 quite useful.
00020 """
00021 from Products.Archetypes.references import Reference
00022 from wicked import config
00023 from wicked.interfaces import IWickedBacklink
00024 from zope.interface import implements
00025 
00026 class Backlink(Reference):
00027     """
00028     A backlink is a reference set on an object when it is targetted
00029     by a resolved wicked-link
00030     """
00031     implements(IWickedBacklink)
00032     relationship = config.BACKLINK_RELATIONSHIP
00033     def __repr__(self):
00034         return "<Backlink sid:%s tid:%s rel:%s>" %(self.sourceUID, self.targetUID, self.relationship)
00035 
00036     def targetURL(self):
00037         """
00038         let's stick this in the catalog this to keep things light
00039         """
00040         target = self.getTargetObject()
00041         if target:
00042             return target.absolute_url()
00043         return '#'
00044 
00045 
00046