Index: /quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py
===================================================================
--- /quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py	(revision 2102)
+++ /quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py	(revision 2103)
@@ -18,9 +18,10 @@
 
 
-class DefaultCanonicalPathAdapter(object):
-    """Adapts base content to canonical path.
+class DefaultCanonicalAdapter(object):
+    """Generic canonical adapter.
     """
     adapts(ITraversable)
-    implements(ICanonicalPath)
+
+    prop = None
 
     def __init__(self, context):
@@ -28,5 +29,5 @@
         self.purl = getToolByName(self.context,'portal_url')
 
-    def _validate_path(self, value):
+    def _validate(self, value):
         value.strip()
         if not _is_canonical(value):
@@ -34,73 +35,56 @@
         return value
 
-    def getCanonicalPath(self):
-        """ First of all return value from the PROPERTY_PATH,
-        if PROPERTY_PATH not exist - return default value
+    def getDefault(self):
+        """Return default value for the self.prop"""
+        raise NotImplementedError()
+
+    def getProp(self):
+        """ First of all return value from the self.prop,
+        if self.prop not exist - return default value
         """
-        if self.context.hasProperty(PROPERTY_PATH):
-            return self.context.getProperty(PROPERTY_PATH)
+        if self.context.hasProperty(self.prop):
+            return self.context.getProperty(self.prop)
 
+        return self.getDefault()
+
+    def setProp(self, value):
+        """ First validate value, than add/updater self.prop
+        """
+        value = self._validate(value)
+
+        if self.context.hasProperty(self.prop):
+            self.context._updateProperty(self.prop, value)
+        else:
+            self.context._setProperty(self.prop, value, type="string")
+
+    def delProp(self):
+        """ Delete self.prop customization
+        """
+        if self.context.hasProperty(self.prop):
+            self.context.manage_delProperties(ids=[self.prop,])
+
+
+class DefaultCanonicalPathAdapter(DefaultCanonicalAdapter):
+    """Adapts base content to canonical path.
+    """
+    implements(ICanonicalLink)
+
+    prop = PROPERTY_PATH
+
+    def getDefault(self):
         return '/'+'/'.join(self.purl.getRelativeContentPath(self.context))
 
-    def setCanonicalPath(self, value):
-        """ First validate value, than add/updater PROPERTY_PATH
-        """
-        value = self._validate_path(value)
-
-        if self.context.hasProperty(PROPERTY_PATH):
-            self.context._updateProperty(PROPERTY_PATH, value)
-        else:
-            self.context._setProperty(PROPERTY_PATH, value, type="string")
-
-    def delCanonicalPath(self):
-        """ Delete PROPERTY_PATH customization
-        """
-        if self.context.hasProperty(PROPERTY_PATH):
-            self.context.manage_delProperties(ids=[PROPERTY_PATH,])
-
-    canonical_path = property(getCanonicalPath, setCanonicalPath, delCanonicalPath)
+    canonical_path = property(getProp, setProp, delProp)
 
 
-class DefaultCanonicalLinkAdapter(object):
+class DefaultCanonicalLinkAdapter(DefaultCanonicalAdapter):
     """Adapts base content to canonical link.
     """
-    adapts(ITraversable)
     implements(ICanonicalLink)
 
-    def __init__(self, context):
-        self.context = context
-        self.purl = getToolByName(self.context,'portal_url')
+    prop = PROPERTY_LINK
 
-    def _validate_link(self, value):
-        value.strip()
-        if not _is_canonical(value):
-            raise InvalidValue(value)
-        return value
-        
-    def getCanonicalLink(self):
-        """ First of all return value from the PROPERTY_LINK,
-        if PROPERTY_LINK not exist - return default value
-        """
-        if self.context.hasProperty(PROPERTY_LINK):
-            return self.context.getProperty(PROPERTY_LINK)
-
+    def getDefault(self):
         return self.context.absolute_url()
 
-    def setCanonicalLink(self, value):
-        """ First validate value, than add/updater PROPERTY_LINK
-        """
-        value = self._validate_link(value)
-
-        if self.context.hasProperty(PROPERTY_LINK):
-            self.context._updateProperty(PROPERTY_LINK, value)
-        else:
-            self.context._setProperty(PROPERTY_LINK, value, type="string")
-
-    def delCanonicalLink(self):
-        """ Delete PROPERTY_LINK customization
-        """
-        if self.context.hasProperty(PROPERTY_LINK):
-            self.context.manage_delProperties(ids=[PROPERTY_LINK,])
-
-    canonical_link = property(getCanonicalLink, setCanonicalLink, delCanonicalLink)
-
+    canonical_link = property(getProp, setProp, delProp)
