products/CPSRSS

view RSSTool.py @ 275:8d5e075097d7

hgbundler made release tag
author Georges Racinet on ishtar.racinet.fr <georges@racinet.fr>
date Wed, 04 May 2011 18:45:58 +0200
parents ff458a7963b3
children
line source
1 # (C) Copyright 2003 Nuxeo SARL <http://nuxeo.com>
2 # Author: Emmanuel Pietriga (ep@nuxeo.com)
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 2 as published
6 # by the Free Software Foundation.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16 # 02111-1307, USA.
17 #
18 # $Id$
19 """The RSS tool manages RSS channels and refreshes them.
20 """
22 import logging
23 from Globals import InitializeClass, DTMLFile
24 from AccessControl import ClassSecurityInfo
26 from Products.CMFCore.permissions import View, ManagePortal
27 from Products.CMFCore.utils import UniqueObject
29 from RSSChannelContainer import RSSChannelContainer
30 from RSSChannel import addRSSChannel, RSSChannel_meta_type
32 from zope.interface import implements
34 from Products.CPSRSS.interfaces import IRSSTool
36 logger = logging.getLogger(__name__)
38 class RSSTool(UniqueObject, RSSChannelContainer):
40 """RSS tool, a container for RSS channels that can refresh them."""
42 implements(IRSSTool)
44 id = 'portal_rss'
45 meta_type = 'RSS Tool'
47 security = ClassSecurityInfo()
48 security.declareObjectProtected(View)
50 def __init__(self):
51 super(self.__class__, self).__init__(self.id)
53 #
54 # CMF views
55 #
56 def __call__(self, REQUEST=None, **kw):
57 """Default view."""
58 return self.view(REQUEST=REQUEST, **kw)
60 index_html = None # This special value informs ZPublisher to use __call__
62 security.declareProtected(View, 'view')
63 def view(self, REQUEST=None, **kw):
64 """Default view."""
65 # FIXME rsstool_view doesn't exist
66 return self.rsstool_view(REQUEST=REQUEST, **kw)
68 #
69 # ZMI
70 #
71 _properties = (
72 {'id': 'title', 'type': 'string', 'mode': 'w',
73 'label': 'Title'},
74 {'id': 'refresh_delay', 'type': 'int', 'mode': 'w',
75 'label': 'Refresh Delay'},
76 {'id': 'lazy_refresh', 'type': 'boolean', 'mode': 'w',
77 'label': 'Lazy Refresh'},
78 )
79 title = ''
80 refresh_delay = 1200 # 20 minutes
81 lazy_refresh = 1
83 all_meta_types = (
84 {'name': RSSChannel_meta_type,
85 'action': 'manage_addRSSChannelForm',
86 'permission': ManagePortal,
87 },
88 )
90 manage_addRSSChannelForm = DTMLFile('zmi/addRSSChannelForm', globals())
92 security.declareProtected(ManagePortal, 'manage_addRSSChannel')
93 def manage_addRSSChannel(self, id, channel_url, REQUEST=None, **kw):
94 """Add a RSS Channel from the ZMI."""
95 if REQUEST:
96 kw.update(REQUEST.form)
97 del kw['id']
98 container = self
99 addRSSChannel(container, id, channel_url)
100 if REQUEST:
101 REQUEST.RESPONSE.redirect('%s/%s/manage_workspace'
102 % (container.absolute_url(), id))
104 InitializeClass(RSSTool)