Index: intagroup.canonicalurl/trunk/qg.canonicalurl-configure.zcml
===================================================================
--- /quintagroup.canonicalurl/trunk/qg.canonicalurl-configure.zcml	(revision 493)
+++ 	(revision )
@@ -1,1 +1,0 @@
-<include package="canonicalurl" />
Index: /quintagroup.canonicalurl/trunk/quintagroup.canonicalurl-configure.zcml
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup.canonicalurl-configure.zcml	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup.canonicalurl-configure.zcml	(revision 494)
@@ -0,0 +1,1 @@
+<include package="canonicalurl" />
Index: /quintagroup.canonicalurl/trunk/quintagroup/__init__.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/__init__.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/__init__.py	(revision 494)
@@ -0,0 +1,1 @@
+#
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/README.txt
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/README.txt	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/README.txt	(revision 494)
@@ -0,0 +1,14 @@
+quintagroup.canonicalurl Package Readme
+=========================
+
+Overview
+--------
+
+Calculate URL with Canonical URL property
+
+
+Your tests here
+---------------
+
+    >>> 1 + 1
+    3
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/__init__.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/__init__.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/__init__.py	(revision 494)
@@ -0,0 +1,29 @@
+#
+from ZPublisher.HTTPRequest import HTTPRequest
+from ZPublisher.BaseRequest import quote
+
+def physicalPathToURL(self, path, relative=0):
+    """ Convert a physical path into a URL in the current context """
+    url = self['SERVER_URL']
+    proto = url.split('://')[0]
+
+    if not type(path) == type(''):
+        path = '/'.join(path)
+
+    path_domain_map = getattr(self, 'path_domain_map', ())
+    for subpath, domain in path_domain_map:
+        if len(path) >= len(subpath) \
+           and (path == subpath \
+                or path.startswith(subpath+'/')):
+            url = "%s://%s" % (proto, domain)
+            path = path[len(subpath):]
+            break
+
+    path = self._script + map(quote, self.physicalPathToVirtualPath(path))
+    if relative:
+        path.insert(0, '')
+    else:
+        path.insert(0, url)
+    return '/'.join(path)
+
+HTTPRequest.physicalPathToURL = physicalPathToURL
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/adapters.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/adapters.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/adapters.py	(revision 494)
@@ -0,0 +1,61 @@
+from string import strip
+from time import time
+
+from zope.interface import implements
+from zope.component import adapts
+from plone.memoize import ram
+
+from Products.CMFCore.utils import getToolByName
+from Products.CMFPlone.interfaces import IPloneSiteRoot
+
+from interfaces import IDomainsMapExtractor
+
+
+def cache_key(*args, **kwargs):
+     return time() // (60 * 60)
+
+
+class DomainsMapExtractor(object):
+    implements(IDomainsMapExtractor)
+    adapts(IPloneSiteRoot)
+
+    def __init__(self, context):
+        self.context = context
+
+    def processData(self, value):
+        try:
+            pd_maps = map(lambda x: map(strip, x.split('::')), value)
+        except:
+            pd_maps = ()
+        else:
+            pd_maps.sort(lambda x,y: len(y[0])-len(x[0]))
+        return pd_maps
+
+
+    @ram.cache(cache_key)
+    def getDomainsMap(self):
+        """ Return sorted by sybpath length tupple
+            of (subpath, domain name) tuple.
+        """
+        portal = getToolByName(self.context, 'portal_url').getPortalObject()
+        pd_maps = portal.getProperty('path_domains_map', ())
+        return self.processData(pd_maps)
+
+    def setDomainsMap(self, value):
+        """ Set tupple of (subpath, domain name) tuples
+        """
+        if value:
+            prepared_value = self.processData(value)
+            portal = getToolByName(self.context, 'portal_url').getPortalObject()
+
+            if not portal.getPropertyType('path_domains_map') == 'lines':
+                if not portal.hasPropertyType('path_domains_map'):
+                    portal.manage_addProperty('path_domains_map', [], 'lines')
+                else:
+                    raise Exception("Wrong types of 'path_domains_map' " \
+                                    "portal property - should be list type")
+
+            update_value = ['::'.join(l) for l in prepared_value]
+            portal._updateProperty('path_domains_map', prepared_value)
+
+
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/config.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/config.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/config.py	(revision 494)
@@ -0,0 +1,1 @@
+DOES_PATCH_TRAVERSABLE = 1#True
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/configure.zcml
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/configure.zcml	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/configure.zcml	(revision 494)
@@ -0,0 +1,23 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:five="http://namespaces.zope.org/five"
+    xmlns:genericsetup="http://namespaces.zope.org/genericsetup">
+
+    <adapter factory=".adapters.DomainsMapExtractor" />
+
+    <subscriber
+        for="Products.CMFPlone.interfaces.IPloneSiteRoot
+             zope.app.publication.interfaces.IBeforeTraverseEvent"
+        handler=".subscribers.add_domains_map"
+        />
+
+    <genericsetup:registerProfile
+        name="default"
+        title="Canonical URL product registration"
+        directory="profiles/default"
+        description="Registers a quintagroup.canonicalurl product"
+        provides="Products.GenericSetup.interfaces.EXTENSION"
+        />
+
+
+</configure>
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/interfaces.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/interfaces.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/interfaces.py	(revision 494)
@@ -0,0 +1,11 @@
+from zope.interface import Interface
+
+class IDomainsMapExtractor(Interface):
+
+    def getDomainsMap():
+        """ Return sorted by sybpath length tupple
+            of (subpath, domain name) tuple.
+        """
+    def setDomainsMap():
+        """ Set tupple of (subpath, domain name) tuples
+        """
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/catalog.xml
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/catalog.xml	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/catalog.xml	(revision 494)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<object name="portal_catalog" meta_type="CMF Catalog">
+ <column value="getCanonicalURL"/>
+</object>
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/metadata.xml
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/metadata.xml	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/profiles/default/metadata.xml	(revision 494)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <version>0.1</version>
+</metadata>
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/subscribers.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/subscribers.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/subscribers.py	(revision 494)
@@ -0,0 +1,13 @@
+from interfaces import IDomainsMapExtractor
+
+def add_domains_map(context, event):
+    """Add to request PATH-DOMAIN map.
+    """
+    pd_map = None
+    extractor = IDomainsMapExtractor(context, None)
+    if extractor is not None:
+        pd_map = extractor.getDomainsMap()
+
+    if pd_map is not None:
+        event.request.set('path_domain_map', pd_map)
+
Index: /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/tests.py
===================================================================
--- /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/tests.py	(revision 494)
+++ /quintagroup.canonicalurl/trunk/quintagroup/canonicalurl/tests.py	(revision 494)
@@ -0,0 +1,30 @@
+import unittest
+
+from zope.testing import doctestunit
+from zope.component import testing
+from Testing import ZopeTestCase as ztc
+
+def test_suite():
+    return unittest.TestSuite([
+
+        # Unit tests for your API
+        doctestunit.DocFileSuite(
+            'README.txt', package='quintagroup.canonicalurl',
+            setUp=testing.setUp, tearDown=testing.tearDown),
+
+        #doctestunit.DocTestSuite(
+        #    module='quintagroup.canonicalurl.mymodule',
+        #    setUp=testing.setUp, tearDown=testing.tearDown),
+
+        # Integration tests that use ZopeTestCase
+        #ztc.ZopeDocFileSuite(
+        #    'README.txt', package='quintagroup.canonicalurl',
+        #    setUp=testing.setUp, tearDown=testing.tearDown),
+
+        #ztc.FunctionalDocFileSuite(
+        #    'browser.txt', package='quintagroup.canonicalurl'),
+
+        ])
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
Index: /quintagroup.canonicalurl/trunk/setup.py
===================================================================
--- /quintagroup.canonicalurl/trunk/setup.py	(revision 493)
+++ /quintagroup.canonicalurl/trunk/setup.py	(revision 494)
@@ -4,5 +4,5 @@
 version = '0.1'
 
-setup(name='qg.canonicalurl',
+setup(name='quintagroup.canonicalurl',
       version=version,
       description="Calculate URL with Canonical URL property",
@@ -20,5 +20,5 @@
       license='GPL',
       packages=find_packages(exclude=['ez_setup']),
-      namespace_packages=['qg'],
+      namespace_packages=['quintagroup'],
       include_package_data=True,
       zip_safe=False,
