Changeset 3599 in products for quintagroup.canonicalpath


Ignore:
Timestamp:
Oct 24, 2012 2:57:02 PM (11 years ago)
Author:
vmaksymiv
Message:

PPP fixes

Location:
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py

    r3145 r3599  
    1515PROPERTY_LINK = "canonical_link" 
    1616 
    17 _is_canonical = re.compile( 
    18     r"\S*$"               # non space and no new line(should be pickier) 
    19     ).match 
     17_is_canonical = re.compile(r"\S*$").match  # non space and no new line(should be pickier) 
    2018 
    2119 
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/interfaces.py

    r3145 r3599  
    66    """ 
    77 
    8     canonical_path = Attribute("canonical_path", 
     8    canonical_path = Attribute( 
     9        "canonical_path", 
    910        "canonical_path - for the object. Adapter must implement " 
    1011        "*setter* and *getter* for the attribute") 
     
    1516    """ 
    1617 
    17     canonical_link = Attribute("canonical_link", 
     18    canonical_link = Attribute( 
     19        "canonical_link", 
    1820        "canonical_link - for the object. Adapter must implement " 
    1921        "*setter* and *getter* for the attribute") 
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/tests.py

    r3146 r3599  
    8989        wrapper = self.get_indexable_wrapper(self.my_doc) 
    9090        self.assertTrue(hasattr(wrapper, 'canonical_path'), 
    91                         "'canonical_path' attribute not accessible with "\ 
     91                        "'canonical_path' attribute not accessible with " 
    9292                        "indexer wrapper for Document object") 
    9393 
     
    9595        wrapper = self.get_indexable_wrapper(self.my_doc) 
    9696        self.assertTrue(hasattr(wrapper, 'canonical_link'), 
    97                         "'canonical_link' attribute not accessible with "\ 
     97                        "'canonical_link' attribute not accessible with " 
    9898                        "indexer wrapper for Document object") 
    9999 
     
    109109 
    110110        self.mydoc_cp = '/' + '/'.join(self.purl.getRelativeContentPath( 
    111                                             self.my_doc)) 
     111            self.my_doc)) 
    112112        self.portal_cp = '/' + '/'.join(self.purl.getRelativeContentPath( 
    113                                             self.portal)) 
     113            self.portal)) 
    114114 
    115115    def testRegistration4Portal(self): 
    116116        cpadapter = queryAdapter(self.portal, ICanonicalPath) 
    117117        self.assertFalse(cpadapter is None, 
    118             "Can't get canonical path adapter for the plone site object") 
     118                         "Can't get canonical path adapter for the plone" 
     119                         " site object") 
    119120 
    120121    def testRegistration4AT(self): 
    121122        cpadapter = queryAdapter(self.my_doc, ICanonicalPath) 
    122123        self.assertFalse(cpadapter is None, 
    123             "Can't get canonical path adapter for the Document object") 
     124                         "Can't get canonical path adapter for the Document" 
     125                         " object") 
    124126 
    125127    def testGetDefault4Portal(self): 
    126128        cpadapter = queryAdapter(self.portal, ICanonicalPath) 
    127129        self.assertTrue(cpadapter.canonical_path == self.portal_cp, 
    128             "Canonical path adapter return '%s' for portal, must be: '%s'" % ( 
    129             cpadapter.canonical_path, self.portal_cp)) 
     130                        "Canonical path adapter return '%s' for portal," 
     131                        " must be: '%s'" % (cpadapter.canonical_path, 
     132                                            self.portal_cp)) 
    130133 
    131134    def testGetDefault4AT(self): 
    132135        cpadapter = queryAdapter(self.my_doc, ICanonicalPath) 
    133136        self.assertTrue(cpadapter.canonical_path == self.mydoc_cp, 
    134             "Canonical path adapter return '%s' for document, "\ 
    135             "must be: '%s'" % (cpadapter.canonical_path, self.mydoc_cp)) 
     137                        "Canonical path adapter return '%s' for document, " 
     138                        "must be: '%s'" % (cpadapter.canonical_path, 
     139                                           self.mydoc_cp)) 
    136140 
    137141    def testSet4Portal(self): 
     
    142146        prop = self.portal.getProperty(PROPERTY_PATH, None) 
    143147        self.assertTrue(prop == newcp, 
    144             "Canonical path adapter setter NOT SET new '%s' value to '%s' " \ 
    145             "propery for the portal" % (newcp, PROPERTY_PATH)) 
     148                        "Canonical path adapter setter NOT SET new '%s' value" 
     149                        " to '%s' propery for the portal" % (newcp, 
     150                                                             PROPERTY_PATH)) 
    146151 
    147152        self.assertTrue(cpadapter.canonical_path == newcp, 
    148             "Canonical path adapter GET '%s' canonical_path, for portal, " \ 
    149             "must be: '%s'" % (cpadapter.canonical_path, newcp)) 
     153                        "Canonical path adapter GET '%s' canonical_path, for" 
     154                        " portal, must be: '%s'" % (cpadapter.canonical_path, 
     155                                                    newcp)) 
    150156 
    151157    def testSet4AT(self): 
     
    156162        prop = self.my_doc.getProperty(PROPERTY_PATH, None) 
    157163        self.assertTrue(prop == newcp, 
    158             "Canonical path adapter setter NOT SET new '%s' value to '%s' " \ 
    159             "propery for the Document" % (newcp, PROPERTY_PATH)) 
     164                        "Canonical path adapter setter NOT SET new '%s' value" 
     165                        " to '%s' propery for the Document" % (newcp, 
     166                                                               PROPERTY_PATH)) 
    160167 
    161168        self.assertTrue(cpadapter.canonical_path == newcp, 
    162             "Canonical path adapter GET '%s' canonical_path, for Document, " \ 
    163             "must be: '%s'" % (cpadapter.canonical_path, newcp)) 
     169                        "Canonical path adapter GET '%s' canonical_path, for " 
     170                        "Document, must be: '%s'" % (cpadapter.canonical_path, 
     171                                                     newcp)) 
    164172 
    165173    def testValidationWrong(self): 
     
    172180            else: 
    173181                raise self.failureException, "InvalidValue not raised when " \ 
    174                       "'%s' wrong value try to set" % wrong 
     182                    "'%s' wrong value try to set" % wrong 
    175183 
    176184    def testValidationGood(self): 
     
    187195        del cpadapter.canonical_path 
    188196        self.assertFalse(hasprop(PROPERTY_PATH), 
    189             "Not deleted Canonical path customization property for the portal") 
     197                         "Not deleted Canonical path customization property " 
     198                         "for the portal") 
    190199 
    191200    def testDelCustomization(self): 
     
    196205        del cpadapter.canonical_path 
    197206        self.assertTrue(cpadapter.canonical_path == self.portal_cp, 
    198             "After deleted Canonical path customization property not set to " 
    199             "default value for the portal") 
     207                        "After deleted Canonical path customization property " 
     208                        "not set to default value for the portal") 
    200209 
    201210 
     
    214223        cladapter = queryAdapter(self.portal, ICanonicalLink) 
    215224        self.assertFalse(cladapter is None, 
    216             "Can't get canonical link adapter for the plone site object") 
     225                         "Can't get canonical link adapter for the plone site " 
     226                         "object") 
    217227 
    218228    def testRegistration4AT(self): 
    219229        cladapter = queryAdapter(self.my_doc, ICanonicalLink) 
    220230        self.assertFalse(cladapter is None, 
    221             "Can't get canonical link adapter for the Document object") 
     231                         "Can't get canonical link adapter for the Document " 
     232                         " object") 
    222233 
    223234    def testGetDefault4Portal(self): 
    224235        cladapter = queryAdapter(self.portal, ICanonicalLink) 
    225236        self.assertTrue(cladapter.canonical_link == self.purl(), 
    226             "Canonical link adapter return '%s' for portal, must be: '%s'" % ( 
    227             cladapter.canonical_link, self.purl())) 
     237                        "Canonical link adapter return '%s' for portal, must " 
     238                        "be: '%s'" % (cladapter.canonical_link, self.purl())) 
    228239 
    229240    def testGetDefault4AT(self): 
    230241        cladapter = queryAdapter(self.my_doc, ICanonicalLink) 
    231242        self.assertTrue(cladapter.canonical_link == self.mydoc_cl, 
    232             "Canonical link adapter return '%s' for document, "\ 
    233             "must be: '%s'" % (cladapter.canonical_link, self.mydoc_cl)) 
     243                        "Canonical link adapter return '%s' for document, " 
     244                        "must be: '%s'" % (cladapter.canonical_link, 
     245                                           self.mydoc_cl)) 
    234246 
    235247    def testSet4Portal(self): 
     
    240252        prop = self.portal.getProperty(PROPERTY_LINK, None) 
    241253        self.assertTrue(prop == newcl, 
    242             "Canonical link adapter setter NOT SET new '%s' value to '%s' " \ 
    243             "propery for the portal" % (newcl, PROPERTY_LINK)) 
     254                        "Canonical link adapter setter NOT SET new '%s' value " 
     255                        "to '%s' propery for the portal" % (newcl, 
     256                                                            PROPERTY_LINK)) 
    244257 
    245258        self.assertTrue(cladapter.canonical_link == newcl, 
    246             "Canonical link adapter GET '%s' canonical_link, for portal, " \ 
    247             "must be: '%s'" % (cladapter.canonical_link, newcl)) 
     259                        "Canonical link adapter GET '%s' canonical_link, for " 
     260                        "portal, must be: '%s'" % (cladapter.canonical_link, 
     261                                                   newcl)) 
    248262 
    249263    def testSet4AT(self): 
     
    254268        prop = self.my_doc.getProperty(PROPERTY_LINK, None) 
    255269        self.assertTrue(prop == newcl, 
    256             "Canonical link adapter setter NOT SET new '%s' value to '%s' " \ 
    257             "propery for the Document" % (newcl, PROPERTY_LINK)) 
     270                        "Canonical link adapter setter NOT SET new '%s' value " 
     271                        "to '%s' propery for the Document" % (newcl, 
     272                                                              PROPERTY_LINK)) 
    258273 
    259274        self.assertTrue(cladapter.canonical_link == newcl, 
    260             "Canonical link adapter GET '%s' canonical_link, for Document, " \ 
    261             "must be: '%s'" % (cladapter.canonical_link, newcl)) 
     275                        "Canonical link adapter GET '%s' canonical_link, for " 
     276                        "Document, must be: '%s'" % (cladapter.canonical_link, 
     277                                                     newcl)) 
    262278 
    263279    def testValidationWrong(self): 
     
    285301        del cladapter.canonical_link 
    286302        self.assertFalse(hasprop(PROPERTY_LINK), 
    287             "Not deleted Canonical link customization property for the portal") 
     303                         "Not deleted Canonical link customization property " 
     304                         "for the portal") 
    288305 
    289306    def test_DelCustomization(self): 
     
    294311        del cladapter.canonical_link 
    295312        self.assertTrue(cladapter.canonical_link == self.purl(), 
    296             "After deleted Canonical link customization property not set to " 
    297             "default value for the portal") 
     313                        "After deleted Canonical link customization property " 
     314                        "not set to default value for the portal") 
    298315 
    299316## 
     
    348365        result = ICanonicalLink(item).canonical_link 
    349366        expect = "http://domain.com/www/some/path" 
    350         self.assertEqual(result, expect, "Got %s canonical link, " \ 
     367        self.assertEqual(result, expect, "Got %s canonical link, " 
    351368                         "expect: %s" % (result, expect)) 
    352369        # 2. canonical path propery mast be delete from the object 
     
    361378        result = ICanonicalLink(item).canonical_link 
    362379        expect = "http://domain.com/www/some/path" 
    363         self.assertEqual(result, expect, "Got %s canonical link, " \ 
     380        self.assertEqual(result, expect, "Got %s canonical link, " 
    364381                         "expect: %s" % (result, expect)) 
    365382        # 2. custom_property mast be deleted from the object 
     
    397414        assert logs != "" 
    398415        self.assertEqual(logs == logs2, True, 
    399              "logs not equal: \"%s\" != \"%s\"" % (logs, logs2)) 
     416                         "logs not equal: \"%s\" != \"%s\"" % (logs, logs2)) 
    400417        self.convertor.convertIPathToLink(bad) 
    401418        logs3 = self.convertor.getLogs() 
    402         self.assertEqual(logs3 > logs2, True, 
    403              "Log was not updated - last: \"%s\", previous: \"%s\"" % (logs3, 
    404                                                                        logs2)) 
     419        self.assertEqual(logs3 > logs2, True, "Log was not updated - " 
     420                         "last: \"%s\", previous: \"%s\"" % (logs3, logs2)) 
    405421 
    406422    def test_loggingCleanup(self): 
     
    427443        item = ProperyAndTraverseProvider("test") 
    428444        self.assertNotEqual(queryAdapter(item, ICanonicalLink), None, 
    429             self.cant % ICanonicalLink.__name__ + "IPropertyManager and "\ 
    430                                                   "ITraversable.") 
     445                            self.cant % ICanonicalLink.__name__ + 
     446                            "IPropertyManager and " 
     447                            "ITraversable.") 
    431448        self.assertNotEqual(queryAdapter(item, ICanonicalPath), None, 
    432             self.cant % ICanonicalPath.__name__ + "IPropertyManager and "\ 
    433                                                   "ITraversable.") 
     449                            self.cant % ICanonicalPath.__name__ + 
     450                            "IPropertyManager and " 
     451                            "ITraversable.") 
    434452 
    435453    def test_Traversable(self): 
     
    439457        item = TraverseProvider("test") 
    440458        self.assertNotEqual(queryAdapter(item, ICanonicalLink), None, 
    441            self.cant % ICanonicalLink.__name__ + "only ITraversable.") 
     459                            self.cant % ICanonicalLink.__name__ + 
     460                            "only ITraversable.") 
    442461        self.assertNotEqual(queryAdapter(item, ICanonicalPath), None, 
    443            self.cant % ICanonicalPath.__name__ + "only ITraversable.") 
     462                            self.cant % ICanonicalPath.__name__ + 
     463                            "only ITraversable.") 
    444464 
    445465    def test_PropertyManager(self): 
     
    451471        item = PropertyManagerProvider("test") 
    452472        self.assertEqual(queryAdapter(item, ICanonicalLink), None, 
    453            self.doget % ICanonicalLink.__name__ + "only IPropertyManager.") 
     473                         self.doget % ICanonicalLink.__name__ + 
     474                         "only IPropertyManager.") 
    454475        self.assertEqual(queryAdapter(item, ICanonicalPath), None, 
    455            self.doget % ICanonicalPath.__name__ + "only IPropertyManager.") 
     476                         self.doget % ICanonicalPath.__name__ + 
     477                         "only IPropertyManager.") 
    456478 
    457479    def test_NotProvider(self): 
     
    460482        item = NotProvider("test") 
    461483        self.assertEqual(queryAdapter(item, ICanonicalLink), None, 
    462            self.doget % ICanonicalLink.__name__ + "nor ITraversabe not "\ 
    463                                                   "IPropertyManager.") 
     484                         self.doget % ICanonicalLink.__name__ + 
     485                         "nor ITraversabe not " 
     486                         "IPropertyManager.") 
    464487        self.assertEqual(queryAdapter(item, ICanonicalPath), None, 
    465            self.doget % ICanonicalPath.__name__ + "nor ITraversabe not "\ 
    466                                                   "IPropertyManager.") 
     488                         self.doget % ICanonicalPath.__name__ + 
     489                         "nor ITraversabe not " 
     490                         "IPropertyManager.") 
    467491 
    468492 
     
    474498        unittest.makeSuite(TestConvertor), 
    475499        unittest.makeSuite(TestAdaptersRegistration), 
    476         ]) 
     500    ]) 
    477501 
    478502if __name__ == '__main__': 
  • quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/upgrades.py

    r3146 r3599  
    66from Acquisition import aq_base, aq_inner 
    77 
    8 from quintagroup.canonicalpath.interfaces  import ICanonicalPath 
    9 from quintagroup.canonicalpath.interfaces  import ICanonicalLink 
     8from quintagroup.canonicalpath.interfaces import ICanonicalPath 
     9from quintagroup.canonicalpath.interfaces import ICanonicalLink 
    1010from quintagroup.canonicalpath.adapters import PROPERTY_LINK 
    1111from quintagroup.canonicalpath.adapters import PROPERTY_PATH 
     
    6666        """ 
    6767        src_msg = type(src_iface) in StringTypes and src_iface \ 
    68                                                  or src_iface.__name__ 
     68            or src_iface.__name__ 
    6969        msg = "Migrate %s into %s for %s object: " \ 
    70                % (src_msg, dst_iface.__name__, obj.absolute_url()) 
     70            % (src_msg, dst_iface.__name__, obj.absolute_url()) 
    7171        try: 
    7272            src = self._getOrMakeAdapter(obj, src_iface) 
     
    117117        handler.setLevel(DEBUG) 
    118118        formatter = Formatter(fmt="[%(asctime)s]: %(message)s", 
    119                                       datefmt="%H:%M:%S") 
     119                              datefmt="%H:%M:%S") 
    120120        handler.setFormatter(formatter) 
    121121        self._logger = Logger("quintagroup.canonicalpath", NOTSET) 
Note: See TracChangeset for help on using the changeset viewer.