Changeset 48059

Show
Ignore:
Timestamp:
08/07/06 14:27:12 (2 years ago)
Author:
gracinet
Message:

#1714: put l10n titles info in trees

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • CPS3/products/CPSCore/trunk/CHANGES

    r48031 r48059  
    99- Event Subscriber importer did not check properly prior existence, leading 
    1010  to errors in trees tool when notification was made twice 
     11- #1714: put l10n titles info in trees 
    1112New internal features: 
    1213~~~~~~~~~~~~~~~~~~~~~~ 
  • CPS3/products/CPSCore/trunk/TreesTool.py

    r47964 r48059  
    5353from zope.app.container.interfaces import IContainerModifiedEvent 
    5454from OFS.interfaces import IObjectWillBeMovedEvent 
     55from interfaces import ICPSProxy 
    5556 
    5657def intersects(a, b): 
     
    262263            'portal_type': ob.portal_type, 
    263264            }) 
     265        if ICPSProxy.providedBy(ob): 
     266            info['l10_titles'] = ob.getL10nTitles() 
    264267        info.update(self.getNodeSecurityInfo(ob)) 
    265268        return info 
  • CPS3/products/CPSCore/trunk/tests/test_treestool.py

    r46883 r48059  
    2929from OFS.OrderedFolder import OrderedFolder 
    3030from Products.CMFCore.tests.base.testcase import SecurityRequestTest 
    31 from Products.CPSCore.TreesTool import TreesTool, TreeCache 
     31from Products.CPSCore.TreesTool import TreesTool, TreeCache, TreeCacheUpdater 
    3232from Products.CPSCore.treemodification import ADD, REMOVE, MODIFY 
    3333 
     
    497497            'visible': False, 
    498498            }) 
     499 
     500    def test_getNodeInfo(self): 
     501        self.makeInfrastructure() 
     502        cmf = self.app.cmf 
     503        tool = cmf.portal_trees 
     504        cache = tool.cache 
     505        cache_upd = TreeCacheUpdater(cache) 
     506 
     507        # test on ordinary object 
     508        info = cache_upd.getNodeInfo(cmf.root.foo) 
     509        self.assertEquals(info, 
     510                          {'allowed_roles_and_users': ['Manager'], 
     511                           'title': 'Foo', 
     512                           'local_roles': {'user:Anonymous User': ('Owner',)}, 
     513                           'rpath': 'root/foo', 
     514                           'portal_type': 'ThePortalType', 
     515                           'id': 'foo'}) 
     516 
     517        # test on proxy 
     518        from Products.CPSCore.ProxyBase import ProxyFolder 
     519        cmf.root._setObject('bar', ProxyFolder('bar')) 
     520 
     521        class DummyObjectTitle(DummyObject): 
     522            # subclass was preferd to adding the method to DummyObject 
     523            # in order to be sure not to void tests of info_method system 
     524 
     525            def Title(self): 
     526                return self.title 
     527 
     528        cmf.root._setObject('bar_en', DummyObjectTitle('bar_en', 
     529                                                  title='English title')) 
     530        cmf.root._setObject('bar_fr', DummyObjectTitle('bar_fr', 
     531                                                  title='French title')) 
     532        cmf.root.bar.portal_type = cmf.root.bar_en.portal_type 
     533 
     534        # monkey patch of bar's getContent to avoid proxy and repo tool faking 
     535        def getContent(lang='default', **kw): 
     536            if lang in ['default', 'en']: 
     537                return cmf.root.bar_en 
     538            elif lang == 'fr': 
     539                return cmf.root.bar_fr 
     540 
     541        def getProxyLanguages(): 
     542            return ['fr', 'en'] 
     543 
     544        bar = cmf.root.bar 
     545        bar.getContent = getContent 
     546        bar.getProxyLanguages = getProxyLanguages 
     547 
     548        info = cache_upd.getNodeInfo(cmf.root.bar) 
     549        self.assertEquals(info, {'allowed_roles_and_users': ['Manager'], 
     550                                 'local_roles': { 
     551            'user:Anonymous User': ('Owner',)}, 
     552                                 'title': 'English title', 
     553                                 'l10_titles': {'fr': 'French title', 
     554                                                'en': 'English title'}, 
     555                                 'rpath': 'root/bar', 
     556                                 'portal_type': 'ThePortalType', 
     557                                 'id': 'bar'}) 
    499558 
    500559    def makeDeepStructure(self):