[Zope-CVS] CVS: Products/OSCOM/NOTSite - content.py:1.1 permissions.py:1.1 __init__.py:1.3 setup.py:1.3

Tres Seaver tseaver@zope.com
Mon, 26 May 2003 00:38:53 -0400


Update of /cvs-repository/Products/OSCOM/NOTSite
In directory cvs.zope.org:/tmp/cvs-serv9783

Modified Files:
	__init__.py setup.py 
Added Files:
	content.py permissions.py 
Log Message:


  - Add subclasses for NOT-specific content types.

  - Add permissions module.

  - Add setup of 'portal_actionicons' tool.


=== Added File Products/OSCOM/NOTSite/content.py ===
""" NOTSite Content classes:  NewsStory, StoryTease, NewsSection

$Id: content.py,v 1.1 2003/05/26 04:38:52 tseaver Exp $
"""
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo

from Products.CMFDefault.Document import Document
from Products.CMFDefault.Favorite import Favorite
from Products.CMFDefault.SkinnedFolder import SkinnedFolder

from permissions import View
from permissions import ModifyNewsStories
from permissions import ModifyNewsSections

#
#   NewsStory declarations
#

class NewsStory( Document ):

    """ Handle news-specific extensions to Document.
    """
    meta_type = 'News Story'
    security = ClassSecurityInfo()

InitializeClass( NewsStory )

def addNewsStory( self
                , id
                , title=''
                , description=''
                , text_format=''
                , text=''
                ):
    """ Add a NewsStory to self.
    """
    story = NewsStory( id, title, description, text_format, text )
    self._setObject( id, story )

NewsStory_FTI = \
( { 'id'                : 'News Story'
  , 'meta_type'         : 'News Story'
  , 'description'       : 'News Stories.'
  , 'icon'              : 'document_icon.gif'
  , 'product'           : 'NOTSite'
  , 'factory'           : 'addNewsStory'
  , 'immediate_view'    : 'story_edit_form'
  , 'actions'           :
    ( { 'id'            : 'view' 
      , 'name'          : 'View'
      , 'action'        : 'story_view'
      , 'visible'       : 0
      , 'permissions'   : ( View, )
      }
    , { 'id'            : 'preview'
      , 'name'          : 'Preview'
      , 'action'        : 'story_preview'
      , 'permissions'   : ( ModifyNewsStories, )
      }
    , { 'id'            : 'edit'
      , 'name'          : 'Edit'
      , 'action'        : 'story_edit_form'
      , 'permissions'   : ( ModifyNewsStories, )
      }
    )
  }
,
)



#
#   StoryTease declarations
#

class StoryTease( Favorite ):

    """ Handle news-specific extensions to Favorite.
    """
    meta_type = 'Story Tease'
    security = ClassSecurityInfo()

InitializeClass( StoryTease )

def addStoryTease( self
                , id
                , title=''
                , remote_url=''
                , description=''
                ):
    """ Add a StoryTease to self.
    """
    story = StoryTease( id, title, remote_url, description )
    self._setObject( id, story )

StoryTease_FTI = \
( { 'id'                : 'Story Tease'
  , 'meta_type'         : 'Story Tease'
  , 'description'       : 'Pointers to news stories.'
  , 'icon'              : 'link_icon.gif'
  , 'product'           : 'NOTSite'
  , 'factory'           : 'addStoryTease'
  , 'immediate_view'    : 'tease_edit_form'
  , 'actions'           :
    ( { 'id'            : 'view' 
      , 'name'          : 'View'
      , 'action'        : 'tease_view'
      , 'visible'       : 0
      , 'permissions'   : ( View, )
      }
    , { 'id'            : 'preview'
      , 'name'          : 'Preview'
      , 'action'        : 'tease_preview'
      , 'permissions'   : ( ModifyNewsStories, )
      }
    , { 'id'            : 'edit'
      , 'name'          : 'Edit'
      , 'action'        : 'tease_edit_form'
      , 'permissions'   : ( ModifyNewsStories, )
      }
    )
  }
,
)



#
#   NewsSection declarations
#

class NewsSection( SkinnedFolder ):

    """ Holds news stories, other sub-sections.
    """
    meta_type = 'News Section'
    security = ClassSecurityInfo()

InitializeClass( NewsSection )

def addNewsSection( self, id, title='' ):

    """ Add a NewsSection to self.
    """
    section = NewsSection( id, title )
    self._setObject( id, section )

NewsSection_FTI = \
( { 'id'                : 'News Section'
  , 'meta_type'         : 'News Section'
  , 'description'       : 'News Stories.'
  , 'icon'              : 'document_icon.gif'
  , 'product'           : 'NOTSite'
  , 'factory'           : 'addNewsSection'
  , 'immediate_view'    : 'section_edit_form'
  , 'actions'           :
    ( { 'id'            : 'view' 
      , 'name'          : 'View'
      , 'action'        : 'section_view'
      , 'visible'       : 0
      , 'permissions'   : ( View, )
      }
    , { 'id'            : 'preview'
      , 'name'          : 'Preview'
      , 'action'        : 'section_preview'
      , 'permissions'   : ( ModifyNewsSections, )
      }
    , { 'id'            : 'edit'
      , 'name'          : 'Edit'
      , 'action'        : 'section_edit_form'
      , 'permissions'   : ( ModifyNewsSections, )
      }
    )
  }
,
)




=== Added File Products/OSCOM/NOTSite/permissions.py ===
""" NOTSite permissions

$Id: permissions.py,v 1.1 2003/05/26 04:38:52 tseaver Exp $
"""

from AccessControl.Permissions import view as View
from AccessControl.Permissions \
    import access_contents_information as AccessContentsInformation

ManageSite = 'Manage site'

CreateNewsSections = 'Create news sections'
ModifyNewsSections = 'Modify news sections'

CreateNewsStories = 'Create news stories'
ModifyNewsStories = 'Modify news stories'



=== Products/OSCOM/NOTSite/__init__.py 1.2 => 1.3 ===
--- Products/OSCOM/NOTSite/__init__.py:1.2	Tue May 13 12:09:51 2003
+++ Products/OSCOM/NOTSite/__init__.py	Mon May 26 00:38:52 2003
@@ -8,8 +8,12 @@
 """
 from Products.CMFCore.DirectoryView import registerDirectory
 
-import utils
-import setup
+from setup import NOTSite, addNOTSiteForm, addNOTSite
+from content import NewsStory, addNewsStory
+from content import StoryTease, addStoryTease
+from content import NewsSection, addNewsSection
+from permissions import CreateNewsStories
+from permissions import CreateNewsSections
 
 registerDirectory( 'skins', globals() )
 
@@ -21,10 +25,22 @@
 
     #  Register content types.
 
-    context.registerClass( meta_type='NOT Site'
-                         , constructors=( setup.addNOTSiteForm
-                                        , setup.addNOTSite
-                                        )
+    context.registerClass( meta_type=NOTSite.meta_type
+                         , constructors=( addNOTSiteForm, addNOTSite )
                          , icon='images/site.gif'
                          )
 
+    context.registerClass( meta_type=NewsStory.meta_type
+                         , constructors=( addNewsStory, )
+                         , permission=CreateNewsStories
+                         )
+
+    context.registerClass( meta_type=StoryTease.meta_type
+                         , constructors=( addStoryTease, )
+                         , permission=CreateNewsStories
+                         )
+
+    context.registerClass( meta_type=NewsSection.meta_type
+                         , constructors=( addNewsSection, )
+                         , permission=CreateNewsSections
+                         )


=== Products/OSCOM/NOTSite/setup.py 1.2 => 1.3 ===
--- Products/OSCOM/NOTSite/setup.py:1.2	Tue May 13 12:09:51 2003
+++ Products/OSCOM/NOTSite/setup.py	Mon May 26 00:38:52 2003
@@ -7,6 +7,10 @@
 from Products.CMFDefault.Portal import CMFSite
 from Products.CMFDefault.Portal import PortalGenerator
 
+from content import NewsStory_FTI
+from content import StoryTease_FTI
+from content import NewsSection_FTI
+
 from utils import _loadPageTemplateFile
 
 class NOTSite( CMFSite ):
@@ -23,7 +27,23 @@
 
     def setup( self, new_site, create_userfolder ):
 
-        PortalGenerator.setup( self, new_site, create_userfolder )
+        self.setupTools( new_site )
+        self.setupMailHost( new_site )
+        if int( create_userfolder ) != 0:
+            self.setupUserFolder( new_site )
+        self.setupCookieAuth( new_site )
+        self.setupMembersFolder( new_site )
+        self.setupRoles( new_site )
+        self.setupPermissions( new_site )
+        self.setupDefaultSkins( new_site )
+
+        self.setupTypes( new_site, NewsStory_FTI )
+        self.setupTypes( new_site, StoryTease_FTI )
+        self.setupTypes( new_site, NewsSection_FTI )
+
+        self.setupMimetypes( new_site )
+        self.setupWorkflow( new_site )
+        self.setupActionIcons( new_site )
 
     def setupDefaultSkins( self, new_site ):
 
@@ -53,6 +73,19 @@
                                    , ', '.join( DEFAULT_SKIN_PATH )
                                    , make_default=1
                                    )
+
+    def setupActionIcons( self, new_site ):
+
+        from Products.CMFActionIcons.Extensions.Install import install
+        install( new_site )
+
+        aitool = getToolByName( new_site, 'portal_actionicons' )
+        aitool.addActionIcon( category='object'
+                            , action_id='tease'
+                            , icon_expr='tease_icon.png'
+                            , title='Tease Story'
+                            , priority=5
+                            )
 
 addNOTSiteForm = _loadPageTemplateFile( 'site_add' )