Exemple #1
0
def configure_site(site, event):
    log.info(u"Making %s a site manager..." % site)
    sm = LocalSiteManager(site)
    site.setSiteManager(sm)
    
    log.info(u'Creating registrations utility...')
    sm['registrations'] = Registrations()
    sm.registerUtility(sm['registrations'], IRegistrations)
    
    log.info(u"Creating authentication systems...")
    
    sm['session_data'] = RAMSessionDataContainer()
    sm.registerUtility(sm['session_data'], ISessionDataContainer)
    
    sm['authentication'] = PluggableAuthentication()
    sm.registerUtility(sm['authentication'], IAuthentication)
    sm['authentication']['session_credentials'] = SessionCredentialsPlugin()
    sm['authentication']['members'] = PrincipalFolder() 
    sm['authentication'].authenticatorPlugins = ('members',)
    sm['authentication'].credentialsPlugins = ('session_credentials',)
    
    log.info(u"Creating indexing system...")
    
    sm['intids'] = IntIds()
    sm.registerUtility(sm['intids'], IIntIds)
    
    sm['catalog'] = Catalog()
    sm.registerUtility(sm['catalog'], ICatalog)
    sm['catalog']['searchableText'] = TextIndex(field_name="getSearchableText",
                                                interface=ISearchableText,
                                                field_callable=True)
    sm['catalog']['name'] = FieldIndex("name", IPortalContent, False)
    sm['catalog']['tags'] = KeywordIndex('tags', ILearningEntry, False)
Exemple #2
0
    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        root = functional.getRootFolder()
        portal = Portal()
        event.notify(ObjectCreatedEvent(portal))
        root['portal'] = portal
        sm = LocalSiteManager(portal)
        portal.setSiteManager(sm)
        setSite(portal)
        sm = portal.getSiteManager()
        portal['ids'] = IntIds()
        sm.registerUtility(portal['ids'], IIntIds)

        portal['catalog'] = Catalog()
        sm.registerUtility(portal['catalog'], ICatalog)

        authconfiglet = sm.getUtility(IAuthenticationConfiglet)
        authconfiglet.installUtility()

        sm.getUtility(IAuthentication)._caching = False
Exemple #3
0
    def __call__(self, data):
        portal = self.context

        # create site manager
        try:
            sm = portal.getSiteManager()
        except:
            sm = None

        if sm is None:
            sm = LocalSiteManager(portal)
            portal.setSiteManager(sm)

        setSite(portal)

        if 'system' not in sm:
            system = SiteManagementFolder()
            event.notify(ObjectCreatedEvent(system))
            sm['system'] = system
        else:
            system = sm['system']

        # IIntId utility
        if 'ids' not in system:
            ids = component.createObject('zope.app.intid.IntIds')
            event.notify(ObjectCreatedEvent(ids))
            system['ids'] = ids
        else:
            system['ids'].__init__()

        ids = system['ids']

        sm.registerUtility(system['ids'], IIntIds)
        ids.register(portal)

        # Principal Annotations
        if 'principalannotations' not in system:
            pa = component.createObject('zope.app.PrincipalAnnotationUtility')
            event.notify(ObjectCreatedEvent(pa))

            system['principalannotations'] = pa
            sm.registerUtility(pa, IPrincipalAnnotationUtility)

        # session data container
        configlet = sm.getUtility(IConfiglet, 'system.session')
        configlet.sessiontype = 'ram'

        # set password
        password = sm.getUtility(IConfiglet, 'principals.password')
        password.passwordManager = 'MD5'

        # set site timezone
        fomratter = sm.getUtility(IConfiglet, 'system.formatter')
        fomratter.timezone = u'UTC'

        # set portal access to open
        manager = IPrincipalPermissionManager(portal)
        everyone = sm.queryUtility(IEveryoneGroup)
        if everyone is not None:
            manager.grantPermissionToPrincipal(
                'zojax.AccessPortal', everyone.id)

        authenticated = sm.queryUtility(IAuthenticatedGroup)
        if authenticated is not None:
            manager.unsetPermissionForPrincipal(
                'zojax.AccessPortal', authenticated.id)

        # setup default role
        roles = sm.getUtility(IPortalRoles)
        if 'site.member' not in roles:
            role = PortalRole(title = u'Site Member')
            event.notify(ObjectCreatedEvent(role))

            roles['site.member'] = role
            roleId = role.id
            sm.getUtility(IDefaultPortalRole).roles = [role.id]

            roleperm = IRolePermissionManager(portal)

            for permId in ('zojax.PersonalContent', 'zojax.PersonalSpace',
                           'zojax.forum.addMessage', 'zojax.forum.addTopic',
                           'zojax.SubmitBlogPost', 'zojax.SubmitDocuments',
                           'zojax.forum.SubmitTopic', 'zojax.SubmitPhoto',
                           'zojax.contenttype.SubmitNewsItem',):
                roleperm.grantPermissionToRole(permId, roleId)

        # install catalog
        sm.getUtility(IConfiglet, 'system.catalog').install()

        # install workspaces
        portal.workspaces = ('overview', 'people', 'news', 'documents')
        event.notify(ObjectModifiedEvent(portal))

        setSite(None)