__doc__ = 'RSSFeed product main classes'
__version__ = '0.1'

from Globals import HTMLFile         # fakes a method from a DTML file
from Globals import MessageDialog    # provid
from Globals import Persistent       # makes an object stick in the ZODB
from Globals import InitializeClass

import Acquisition
import AccessControl
import OFS.SimpleItem

manage_addRSSForm = HTMLFile( 'rssAdd', globals() ) 

def manage_addRSS( self, id, title='', REQUEST=None ):
    """Add RSSFeed to a folder"""
    self._setObject( id, RSSFeed( id, title ) )
    if REQUEST is not None:
        return self.manage_main( self, REQUEST )


class RSSFeed( OFS.SimpleItem.SimpleItem,         # A simple Principia object. Not Folderish. 
               Persistent,                        # Make us persistent.
               Acquisition.Implicit,              # Uh, whatever. 
               AccessControl.Role.RoleManager     # Security manager. 
               ):
    
    meta_type = 'RSSFeed'
    security = AccessControl.ClassSecurityInfo()
    manage_options = ( {'label': 'Edit',       'action': 'manage_main'},
                       {'label': 'View',       'action': ''}, # defaults to index_html
                       {'label': 'Security',   'action': 'manage_access'} ) 

    index_html = HTMLFile( 'index', globals() )       # View Interface
    manage_main = HTMLFile( 'rssEdit', globals() )    # Management Interface

    def __init__( self, id, title='' ): 
        self.id = id
        self.title = title
        
    security.declareProtected('Change RSSFeed', 'manage_edit')
    def manage_edit( self, title, REQUEST=None ): 
        self.title = title
        if REQUEST is not None:
            return MessageDialog( title = 'Edited',
                                  message = "Properties for %s changed." % self.id,
                                  action = 'http://www.pugo.org/', )

InitializeClass( RSSFeed )
