products/CPSRSS

changeset 235:46f0fc29b4e8

closer to PEP8 compliance
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Sun, 05 Dec 2010 02:08:22 +0100
parents 483df375f3a1
children 245fa28df4da
files browser/__init__.py tests/CPSRSSTestCase.py tests/basetests.py tests/testRSS.py tests/test_rss.py
diffstat 3 files changed, 36 insertions(+), 0 deletions(-) [+]
line diff
     1.1 new file mode 100644
     1.2 --- /dev/null
     1.3 +++ b/browser/__init__.py
     1.4 @@ -0,0 +1,36 @@
     1.5 +# python package
     1.6 +
     1.7 +from Products.Five import BrowserView
     1.8 +from Products.CMFCore.utils import getToolByName
     1.9 +from Products.CPSonFive.browser import AqSafeBrowserView
    1.10 +
    1.11 +class LocalRSSChannelsManagement(AqSafeBrowserView):
    1.12 +
    1.13 +    def __init__(self, *args, **kwargs):
    1.14 +        AqSafeBrowserView.__init__(self, *args, *kwargs)
    1.15 +        self.aqSafeSet('container', self.lookupContainer())
    1.16 +
    1.17 +    def lookupContainer(self):
    1.18 +        """Lookup the relevant container and set it up on self."""
    1.19 +        folder = self.context.aq_inner
    1.20 +
    1.21 +        if cont_id is not None:
    1.22 +            try:
    1.23 +                cont = folder[cont_id]
    1.24 +            except KeyError:
    1.25 +                return None
    1.26 +            if not IRSSChannelContainer.providedBy(cont):
    1.27 +                return None
    1.28 +
    1.29 +        # coding style that works if objectValues turns out to be a generator
    1.30 +        for cont in folder.objectValues([RSSChannelContainer.meta_type]):
    1.31 +            return cont
    1.32 +
    1.33 +    def has_container(self):
    1.34 +        return self.aqSafeGet('container') is not None
    1.35 +
    1.36 +    def channels(self):
    1.37 +        cont = self.aqSafeGet('container')
    1.38 +        if cont is None:
    1.39 +            return ()
    1.40 +        return cont.objectValues([RSSChannel.meta_type])
     2.1 rename from tests/CPSRSSTestCase.py
     2.2 rename to tests/basetests.py
     3.1 rename from tests/testRSS.py
     3.2 rename to tests/test_rss.py