Author: Fry-IT



This package provides a few simple functions with common tasks used with initial
site content setup.

This does not aim to be as general as possible but it may speed things up.

>>> from collective.setuphelpers.structure import setupStructure
>>> portal = layer['portal']
>>> STRUCTURE = [{'id':'example-id','title':'Example title','type':'Document'}]
>>> setupStructure(portal, STRUCTURE)
>>> portal['example-id']
<ATDocument at /plone/example-id>
>>> portal.manage_delObjects(['example-id'])

You can use subfolders etc.

>>> setupStructure(portal, layer['test_structure'])
>>> portal['testfolder']['item1'].getText()
'<p>Text body</p>'

Content related methods:


  def clearUpSite(context, to_delete):
    """ Remove content from the plone site root using given list of ids e.g.:
        TO_DELETE = ['news', 'events']

  def setupStructure(portal, structure, default_language=LANGUAGE, base_path=''):
    """ Setup initial content structure. e.g.:

        STRUCTURE = [
                'title' : 'About us',
                'type' : 'Document',
                'interfaces': (
                'title' : 'Products',
                'type' : 'Folder',
                'layout': 'folder_listing',
                'subfolder': [
                        'title': 'Cheap Products',
                        'type': 'Folder',
                        'allowed_types': ['Document'],
                        'block-portlets': {'manager': 'plone.rightcolumn'},
                        # pass either module or configuration dict to the 'portlets' key
                              { 'module':,
                                'name': 'myportlet1',
                                'manager': 'plone.rightcolumn',
                                'params': dict(template='mytemplate', macro='portlet')
                        'subfolder': [
                                'title': 'Product 1',
                                'type': 'Document',
                                'layout': '@@product-page'
                                'title': 'Recommended',
                                'type': 'Collection',
                                 'title': u'Picture',
                                 'id': u'image1.jpg',
                                 'file': 'data/image1.jpg',

        base_path parameter can specify absolute path for Files and Images. For example
        you can use context._profile_path, where context is GenericSetup context. It allows
        you to put files and images to profiles/default/data/image1.jpg.

Users and groups related methods:


  def createGroups(portal, groups):
    """ Create user groups by passing list of tuples containing group ids and titles:

        @example groups list:

        GROUPS = [
          ('customers', 'Customers'),
          ('staff', 'Staff')

        from tools.sitesetup import createGroups
        createGroups(portal, GROUPS)


    """ Enable anonymous users to register their user account. """

  def enableUserPwdChoice(portal):
    """ Enable user password choice during user registration. """

Various methods:


  def registerDisplayViews(portal, views):
    """ Register additional display views for content types based on "views"
        dictionary containing li