Exemplo n.º 1
0
    def get_dependencies_with_pinnings(self):
        dependencies = self.resolve_dependency_versions(self.package_name,
                                                        extras=self.extras)

        assert 'zc.recipe.egg' in dependencies, \
            'For using the ConsoleScriptLayer you need to put "zc.recipe.egg" in' + \
            ' the test dependencies of your package.'

        if getFSVersionTuple() < (4, 3):
            self.resolve_dependency_versions('manuel', dependencies)
            self.resolve_dependency_versions('zope.hookable', dependencies)
        if getFSVersionTuple() > (5, 1):
            self.resolve_dependency_versions('zope.untrustedpython', dependencies)
        return dependencies
Exemplo n.º 2
0
 def update(self):
     context = aq_inner(self.context)
     self.portal_properties = getToolByName(context, 'portal_properties')
     self.portal_catalog = getToolByName(context, 'portal_catalog')
     self.site_properties = getattr(self.portal_properties, 'site_properties')
     self.has_p4 = getFSVersionTuple()[0] <= 4
     if getFSVersionTuple()[0] <= 4:
         self.navtree_properties = getattr(self.portal_properties, 'navtree_properties')
         self.view_action_types = self.portal_properties.getProperty('typesUseViewActionInListings', ())
         self.sortAttribute = self.navtree_properties.getProperty('sortAttribute', None)
         self.sortOrder = self.navtree_properties.getProperty('sortOrder', None)
         self.sections_displayed_types = self.navtree_properties.getProperty('sections_displayed_types', False)
         self.enable_wf_state_filtering = self.navtree_properties.getProperty('enable_wf_state_filtering', True)
         self.wf_states_to_show = self.navtree_properties.getProperty('wf_states_to_show', ())
         self.sections_wf_states_to_show = self.navtree_properties.getProperty('sections_wf_states_to_show', self.wf_states_to_show)
         self.disable_nonfolderish_sections = self.site_properties.getProperty('disable_nonfolderish_sections', False)
         self.sections_depth = self.navtree_properties.getProperty('sections_depth', 1)
         self.submenu_display = self.navtree_properties.getProperty('submenu_display', 'hover')
     else:
         from Solgema.RichMenu.dx.interfaces import IRichMenuSchema
         from Products.CMFPlone.interfaces import INavigationSchema
         registry = getUtility(IRegistry)
         self.richmenu_properties = registry.forInterface(
             IRichMenuSchema,
             prefix="plone",
             check=False
         )
         self.navtree_properties = registry.forInterface(INavigationSchema,
                                                 prefix="plone")
         self.view_action_types = registry.get('plone.types_use_view_action_in_listings', [])
         self.sortAttribute = self.navtree_properties.sort_tabs_on
         self.sortOrder = self.navtree_properties.sort_tabs_reversed and 'reverse' or 'ascending'
         self.sections_displayed_types = self.richmenu_properties.sections_displayed_types
         self.enable_wf_state_filtering = self.richmenu_properties.enable_wf_state_filtering
         self.workflow_states_to_show = self.navtree_properties.workflow_states_to_show
         self.sections_wf_states_to_show = self.richmenu_properties.sections_wf_states_to_show\
             and self.richmenu_properties.sections_wf_states_to_show or self.workflow_states_to_show
         self.disable_nonfolderish_sections = not self.navtree_properties.nonfolderish_tabs
         self.sections_depth = self.richmenu_properties.sections_depth
         self.submenu_display = self.richmenu_properties.submenu_display
     self.portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')
     self.anonymous = self.portal_state.anonymous()
     self.navigation_root_url = self.portal_state.navigation_root_url()
     root = self.portal_state.navigation_root()
     portal = self.portal_state.portal()
     self.canManageNavTree = not self.anonymous and portal.portal_membership.checkPermission('Add portal content', root) or False
     self.proxy = self.request.getHeader('proxy') == 'Varnish'
     self.portal_tabs = self.firstLevelTabs()
Exemplo n.º 3
0
    def javascript(self):
        if getFSVersionTuple()[0] < 5:
            return u"""
<script type="text/javascript">
    %(galleryscript)s
</script>
    """ % {
                'start_index_index': self.start_image_index,
                'staticFiles': self.staticFiles,
                'base_url': self.typeStaticFiles,
                'theme_js_url': self.theme_js_url(),
                'galleryscript': self.galleryscript()
            }
        else:
            return u"""
<script type="text/javascript">
requirejs(["unitegallery-%(theme)s"], function(util) {
    %(galleryscript)s
});
</script>
    """ % {
                'start_index_index': self.start_image_index,
                'staticFiles': self.staticFiles,
                'base_url': self.typeStaticFiles,
                'theme_js_url': self.theme_js_url(),
                'theme': self.theme,
                'galleryscript': self.galleryscript()
            }
Exemplo n.º 4
0
def uninstall(portal, reinstall=False):
    if not reinstall:
        setup_tool = portal.portal_setup
        setup_tool.setBaselineContext('profile-monet.calendar.event:uninstall')
        setup_tool.runAllImportStepsFromProfile('profile-monet.calendar.event:uninstall')
    if getFSVersionTuple()[0]>=4:
        unregisterIcon(portal)
Exemplo n.º 5
0
 def delete_folder(self):
     """ delete objects """
     self.request.set('link_integrity_events_to_expect', len(self.paths))
     if getFSVersionTuple() > (4, 0):
         # Using the legacy method from Plone 4
         success, failure = self.utils.deleteObjectsByPaths(
             self.paths, REQUEST=self.request)
     else:
         ## Using custom method up to Plone 3
         success, failure = self.deleteObjectsByPaths(self.paths,
                                                      REQUEST=self.request)
     if success:
         self.status = 'success'
         mapping = {u'items': ', '.join(success)}
         message = _(u'${items} deleted.', mapping=mapping)
         self.utils.addPortalMessage(message)
         view = IActionSuccess(self.context).view()
     if failure:
         failure_message = ', '.join([('%s (%s)' % (x, str(y))) for (
             x,
             y,
         ) in failure.items()])
         message = _(u'${items} could not be deleted.',
                     mapping={u'items': failure_message})
         self.utils.addPortalMessage(message, type='error')
         view = IActionFailure(self.context).view()
     return view()
 def delete_folder(self):
     """ delete objects """
     self.request.set('link_integrity_events_to_expect', len(self.paths))
     if getFSVersionTuple() > (4, 0):
         # Using the legacy method from Plone 4
         success, failure = self.utils.deleteObjectsByPaths(
             self.paths, REQUEST=self.request)
     else:
         ## Using custom method up to Plone 3
         success, failure = self.deleteObjectsByPaths(
             self.paths, REQUEST=self.request)
     if success:
         self.status = 'success'
         mapping = {u'items': ', '.join(success)}
         message = _(u'${items} deleted.', mapping=mapping)
         self.utils.addPortalMessage(message)
         view = IActionSuccess(self.context).view()
     if failure:
         failure_message = ', '.join(
             [('%s (%s)' % (x, str(y))) for (x, y,) in failure.items()])
         message = _(u'${items} could not be deleted.',
                     mapping={u'items': failure_message})
         self.utils.addPortalMessage(message, type='error')
         view = IActionFailure(self.context).view()
     return view()
class TestPloneUpgradeCommand(CommandAndInstanceTestCase):
    def setUp(self):
        super(TestPloneUpgradeCommand, self).setUp()
        self.write_zconf_with_test_instance()

    def test_help(self):
        self.upgrade_script('plone_upgrade --help')

    def test_plone_upgrade_already_uptodate(self):
        exitcode, output = self.upgrade_script('plone_upgrade -s plone')
        self.assertEqual(0, exitcode)
        transaction.begin()  # sync transaction
        self.assertIn(u'Plone Site was already up to date.', output)

    @skipIf(getFSVersionTuple() > (5, ), 'The test does not work on Plone 5.')
    def test_upgrade_plone(self):
        from Products.CMFPlone.factory import _DEFAULT_PROFILE
        setup = getToolByName(self.portal, 'portal_setup')
        setup.setLastVersionForProfile(_DEFAULT_PROFILE, '4')
        transaction.commit()

        exitcode, output = self.upgrade_script('plone_upgrade -s plone')
        self.assertEqual(0, exitcode)
        transaction.begin()  # sync transaction
        self.assertIn(u'Plone Site has been updated.', output)

    def test_portal_migration_tool_is_wrapped_in_request_container(self):
        portal = self.layer['portal']
        portal_migration = get_portal_migration(portal)

        self.assertIsInstance(portal_migration.REQUEST, HTTPRequest)
        self.assertIsInstance(aq_chain(portal_migration)[-1], RequestContainer)
class TestPloneUpgradeCommand(CommandAndInstanceTestCase):
    def setUp(self):
        super(TestPloneUpgradeCommand, self).setUp()
        self.write_zconf_with_test_instance()

    def test_help(self):
        self.upgrade_script('plone_upgrade --help')

    def test_plone_upgrade_already_uptodate(self):
        exitcode, output = self.upgrade_script('plone_upgrade -s plone')
        self.assertEquals(0, exitcode)
        transaction.begin()  # sync transaction
        self.assertIn(u'Plone Site was already up to date.', output)

    @skipIf(getFSVersionTuple() > (5, ), 'The test does not work on Plone 5.')
    def test_upgrade_plone(self):
        from Products.CMFPlone.factory import _DEFAULT_PROFILE
        setup = getToolByName(self.portal, 'portal_setup')
        setup.setLastVersionForProfile(_DEFAULT_PROFILE, '4')
        transaction.commit()

        exitcode, output = self.upgrade_script('plone_upgrade -s plone')
        self.assertEquals(0, exitcode)
        transaction.begin()  # sync transaction
        self.assertIn(u'Plone Site has been updated.', output)
Exemplo n.º 9
0
    def javascript(self):
        if getFSVersionTuple()[0] < 5:
            return u"""
<script type="text/javascript" src="%(base_url)s/js/unitegallery.min.js"></script>
<script type="text/javascript" src="%(theme_js_url)s"></script>
<script type="text/javascript">
        (function($){
            %(galleryscript)s
        })(jQuery);
</script>
    """ % {
                'start_index_index': self.start_image_index,
                'staticFiles': self.staticFiles,
                'base_url': self.typeStaticFiles,
                'theme_js_url': self.theme_js_url(),
                'galleryscript': self.galleryscript()
            }
        else:
            return u"""
<script type="text/javascript">
requirejs(["%(base_url)s/js/unitegallery.min.js"], function(util) {
    requirejs(["%(theme_js_url)s"], function(util) {
        (function($){
            %(galleryscript)s
        })(jQuery);
    });
});
</script>
    """ % {
                'start_index_index': self.start_image_index,
                'staticFiles': self.staticFiles,
                'base_url': self.typeStaticFiles,
                'theme_js_url': self.theme_js_url(),
                'galleryscript': self.galleryscript()
            }
Exemplo n.º 10
0
    def test_profile_only_listed_when_installed(self):
        self.package.with_profile(
            Builder('genericsetup profile').with_upgrade(
                Builder('plone upgrade step').upgrading('1', to='2')))
        self.package.with_profile(
            Builder('genericsetup profile').named('uninstall'))

        with self.package_created():
            self.assertNotIn(
                'the.package:default', self.get_listed_profiles(),
                'Not yet installed profiles should not be listed.')

            self.install_profile('the.package:default')
            self.assertIn('the.package:default', self.get_listed_profiles(),
                          'Installed profiles should be listed.')

            if getFSVersionTuple() > (5, 1):
                installer = getMultiAdapter(
                    (self.portal, self.layer['request']), name='installer')
                installer.uninstall_product('the.package')
            else:
                self.portal_quickinstaller.uninstallProducts(['the.package'])
            self.assertNotIn(
                'the.package:default', self.get_listed_profiles(),
                'Packages uninstalled by quickinstaller should not be listed.')
Exemplo n.º 11
0
    def test_static_portlet_found_in_rightcolumn(self, browser):
        portlet_text = 'Hello Right Column'
        create(Builder('static portlet')
               .titled('My Static Portlet')
               .having(text='<p>{0}</p>'.format(portlet_text))
               .in_manager(u'plone.rightcolumn'))

        browser.login().open(self.portal)
        column_two = browser.css('#portal-column-two')

        # Test the portlet header.
        self.assertEqual(
            'My Static Portlet',
            column_two.css('.portletHeader').first.text
        )

        # Test the portlet content.
        css_selector = '.portletItem'
        if getFSVersionTuple() >= (5,):
            css_selector = '.portletContent'

        self.assertEqual(
            portlet_text,
            column_two.css(css_selector).first.text
        )
Exemplo n.º 12
0
def upgrade_resources(context, logger=None):
    setup = getToolByName(context, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runImportStepFromProfile(PROFILE_ID_PLONE4, 'cssregistry')
        setup.runImportStepFromProfile(PROFILE_ID_PLONE4, 'jsregistry')
    else:
        setup.runImportStepFromProfile(PROFILE_ID_PLONE5, 'plone.app.registry')
Exemplo n.º 13
0
    def test_navi_portlet_found_in_leftcolumn(self, browser):
        self.grant('Manager')
        create(Builder('folder').titled(u'My Folder'))

        create(Builder('navigation portlet')
               .titled('My Navigation Portlet')
               .having(includeTop=True, topLevel=0))

        browser.login().open(self.portal)
        column_one = browser.css('#portal-column-one')

        # Test the portlet header.
        self.assertEqual(
            'My Navigation Portlet',
            column_one.css('.portletHeader').first.text
        )

        # Test the portlet content.
        css_selector = '.portletItem  ul li'
        if getFSVersionTuple() >= (5,):
            css_selector = '.portletContent ul li'

        self.assertEqual(
            ['Home', 'My Folder'],
            column_one.css(css_selector).text
        )
Exemplo n.º 14
0
def upgrade_resources(context, logger=None):
    setup = getToolByName(context, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runImportStepFromProfile(PROFILE_ID_PLONE4, 'cssregistry')
        setup.runImportStepFromProfile(PROFILE_ID_PLONE4, 'jsregistry')
    else:
        setup.runImportStepFromProfile(PROFILE_ID_PLONE5, 'plone.app.registry')
Exemplo n.º 15
0
    def create(self, app, site_id, products_initial, profiles_initial, site_replace):
        oids = app.objectIds()
        if site_id in oids:
            if site_replace and hasattr(app, site_id):
                if pre_plone3:
                    app.manage_delObjects([site_id,])
                else:
                    try:
                        app.manage_delObjects([site_id,])
                    except LinkIntegrityNotificationException:
                        pass
                transaction.commit()
                print "Removed existing Plone Site"
                oids = app.objectIds()
            else:
                print "A Plone Site already exists and will not be replaced"
                return

        # actually add in Plone
        if site_id not in oids:
            version = getFSVersionTuple()
            if version[0] < 4:
                factory = app.manage_addProduct['CMFPlone']
                factory.addPloneSite(site_id, create_userfolder=1)

            else:
                # we have to simulate the new zmi admin screen here - at
                # least provide:
                # extension_ids
                # setup_content (plone default is currently 'true')
                from Products.CMFPlone.factory import addPloneSite
                extension_profiles = (
                    'plonetheme.classic:default',
                    'plonetheme.sunburst:default'
                    )
                addPloneSite(
                    app,
                    site_id,
                    extension_ids=extension_profiles,
                    setup_content=False
                    )

            # commit the new site to the database
            transaction.commit()
            print "Added Plone Site"

        # install some products
        plone = getattr(app, site_id)

        # set the site so that the component architecture will work
        # properly
        if not pre_plone3:
            setSite(plone)

        if plone:
            self.quickinstall(plone, products_initial)
        # run GS profiles
            self.runProfiles(plone, profiles_initial)
        print "Finished"
Exemplo n.º 16
0
 def workflow_path(self):
     plone_version = getFSVersionTuple()
     if plone_version >= (4, 3, 5):
         return 'assets/example-4.3.5'
     elif plone_version > (4, 3):
         return 'assets/example-4.3.4'
     else:
         return 'assets/example-4.2'
Exemplo n.º 17
0
def checkVersion():
    from Products.CMFPlone.utils import getFSVersionTuple
    if getFSVersionTuple()[:3] < (3,0,1):
        import logging, sys
        logger=logging.getLogger("LinguaPlone")
        logger.log(logging.ERROR,
                "Unsupported Plone version: " 
                "LinguaPlone 2.0 requires Plone 3.0.1 or later")
        sys.exit(1)
 def check_canManageNavigationSettings(self):
     context = aq_inner(self.context)
     portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state')
     member = portal_state.member()
     plone_version_tuple = getFSVersionTuple() 
     if plone_version_tuple[0]>=4 and plone_version_tuple[1]>=1:
         # If on Plone 4.1 or better we need to check "Plone Site Setup: Navigation" instead of "Manage portal"
         return member.has_permission("Plone Site Setup: Navigation", portal_state.portal())
     return member.has_permission("Manage portal", portal_state.portal())
def installSolgemaNavigationPortlet(context):
    if context.readDataFile('solgemanavigationportlet_install.txt') is None:
        return
    site = context.getSite()

    setup = getToolByName(site, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-Solgema.NavigationPortlet:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-Solgema.NavigationPortlet:plone5')
Exemplo n.º 20
0
def uninstallRichMenu(context):
    if context.readDataFile('uninstall_solgema_richmenu.txt') is None:
        return
    portal = context.getSite()
    catalog = getToolByName(portal, 'portal_catalog')
    catalog.manage_reindexIndex()
    setup = getToolByName(portal, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-Solgema.RichMenu:uninstallplone4')
    else:
        setup.runAllImportStepsFromProfile('profile-Solgema.RichMenu:uninstallplone5')
def install(self, reinstall=False):
    tool = getToolByName(self, "portal_setup")

    if getFSVersionTuple()[0] >= 3:
        tool.runAllImportStepsFromProfile("profile-Products.Ploneboard:ploneboard", purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-Products.Ploneboard:default")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)
Exemplo n.º 22
0
def install(context):
    site = context.getSite()

    if not context.readDataFile('wildcard.media.txt'):
        return

    setup = getToolByName(site, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-wildcard.media:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-wildcard.media:plone5')
Exemplo n.º 23
0
def install(portal, reinstall=False):
    setup_tool = portal.portal_setup
    version = getFSVersionTuple()[0]

    if version < 5:
        setup_tool.runAllImportStepsFromProfile(
            'profile-pas.plugins.authomatic:plone4')
    else:
        setup_tool.runAllImportStepsFromProfile(
            'profile-pas.plugins.authomatic:plone5')
    logger.info("Installed")
Exemplo n.º 24
0
def install(context):
    site = context.getSite()

    if not context.readDataFile('wildcard.media.txt'):
        return

    setup = getToolByName(site, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-wildcard.media:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-wildcard.media:plone5')
Exemplo n.º 25
0
def uninstallSolgemaFlowView(context):
    if context.readDataFile('solgemaflowview_uninstall.txt') is None:
        return
    site = context.getSite()
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-Solgema.FlowView:uninstall4')
        jstool = getToolByName(site, 'portal_javascripts')
        jstool.cookResources()
        csstool = getToolByName(site, 'portal_css')
        csstool.cookResources()
    else:
        setup.runAllImportStepsFromProfile('profile-Solgema.FlowView:uninstall5')
Exemplo n.º 26
0
def install(context):
    site = context.getSite()

    if not context.readDataFile('video.converter.txt'):
        return

    setup = getToolByName(site, 'portal_setup')
    import ipdb
    ipdb.set_trace()
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-video.converter:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-video.converter:plone5')
Exemplo n.º 27
0
def uninstall(portal, reinstall=False):
    setup_tool = portal.portal_setup
    setup_tool.runAllImportStepsFromProfile("profile-redturtle.smartlink:uninstall")
    if getFSVersionTuple()[0] >= 4:
        unregisterIcon(portal)
    if not reinstall:
        removeSmartLinkMarks(portal)
        setup_tool.runAllImportStepsFromProfile("profile-redturtle.smartlink:smartLinkToATLink")
        logger.info("...done. Thanks you for using me!")
        portal.plone_utils.addPortalMessage(
            _("uninstall_info", default=u"All of yours Smart Link contents has been transformed back to Plone ATLink"),
            type="info",
        )
Exemplo n.º 28
0
def install(self, reinstall=False):
    tool = getToolByName(self, "portal_setup")

    if getFSVersionTuple()[0] >= 3:
        tool.runAllImportStepsFromProfile("profile-plonetheme.acmolenbeek:default", purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-plonetheme.acmolenbeek:default")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)

    return "Ran all import steps for profile-plonetheme.acmolenbeek:default."
Exemplo n.º 29
0
def configPortalSetup(self, out):
    """Run GenericSetup steps"""
    portal_setup=getToolByName(self, "portal_setup")

    if getFSVersionTuple()[:3]>=(3,0,0):
        portal_setup.runAllImportStepsFromProfile(
                "profile-Products.%s:default" % config.PROJECTNAME,
                purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        portal_setup.setImportContext(plone_base_profileid)
        portal_setup.setImportContext("profile-Products.%s:default" % config.PROJECTNAME)
        portal_setup.runAllImportSteps(purge_old=False)
        portal_setup.setImportContext(plone_base_profileid)
class TestCombineBundlesCommand(CommandAndInstanceTestCase):
    def setUp(self):
        super(TestCombineBundlesCommand, self).setUp()
        self.write_zconf_with_test_instance()

    def test_help(self):
        self.upgrade_script('combine_bundles --help')

    @skipIf(getFSVersionTuple() < (5, ), 'The test only works on Plone 5+.')
    def test_combine_bundles(self):
        with self.assert_bundles_combined():
            exitcode, output = self.upgrade_script('combine_bundles -s plone')
            self.assertEqual('OK\n', output)
            transaction.begin()
Exemplo n.º 31
0
    def test_dexterity_data_extraction(self):
        obj = createContentInContainer(
            self.portal, 'ExampleDxType', title=u'My Object')

        if getFSVersionTuple() >= (4, 3):
            relateditems = ['list', []]
        else:
            relateditems = ['raw', None]

        self.assertEquals({'IBasic': {'description': u'',
                                      'title': u'My Object'},
                           'IFoo': {},
                           'IRelatedItems': {'relatedItems': relateditems}},

                          self._get_field_data(obj))
Exemplo n.º 32
0
    def test_not_installable_products_are_not_checked_if_uninstalled(self):
        # Some profiles are not associated with a product.
        # Since we want those profiles to appear in manage-upgrades, we dont verify in the
        # quickinstaller that the product is installed, since it is always not installed because
        # there is no known product.
        # - Products.CMFEditions:CMFEditions
        # - Products.TinyMCE:TinyMCE
        # - plone.app.discussion:default
        # - plone.formwidget.autocomplete:default (depends on Plone version)

        profiles = self.get_listed_profiles(filter_package=None)
        if getFSVersionTuple() < (5, ):
            self.assertIn('Products.CMFEditions:CMFEditions', profiles)
            self.assertIn('Products.TinyMCE:TinyMCE', profiles)
        self.assertIn('plone.app.discussion:default', profiles)
def extensions(context):
    if context.readDataFile('monet.calendar.event-various.txt') is None:
        return
    # Define portal properties
    site = context.getSite()
    ptool = getToolByName(site, 'portal_properties')
    props = ptool.monet_calendar_event_properties
    
    for prop in _PROPERTIES:
        if not props.hasProperty(prop['name']):
            props.manage_addProperty(prop['name'], prop['value'], prop['type_'])
    
    _addKeysToCatalog(site)
    if getFSVersionTuple()[0]>=4:
        unregisterIcon(site)
Exemplo n.º 34
0
 def __init__(self, not_mapped, old_type, new_type, target_fields):
     if getFSVersionTuple() > (5, ):
         raise NotImplementedError(
             'The inplace migrator migrates from Archetypes.'
             ' Plone 5 has no Archetypes objects.')
     super(FieldsNotMappedError, self).__init__(
         self.message_template.format(
             not_mapped='\n- '.join(sorted(not_mapped)),
             old_type=old_type,
             new_type=new_type,
             target_fields='\n- '.join(sorted(target_fields))))
     self.not_mapped_fields = not_mapped
     self.old_type = old_type
     self.new_type = new_type
     self.target_fields = target_fields
def setupSolgemaEnvironmentViewlets(context):
    """various things to do while installing..."""
    if context.readDataFile('solgemaenvironmentviewlets_various.txt') is None:
        return
    site = context.getSite()
    out = StringIO()
    sm = site.getSiteManager()

    setup = getToolByName(site, 'portal_setup')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-Solgema.EnvironmentViewlets:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-Solgema.EnvironmentViewlets:plone5')

    print >> out, "Installing Solgema Environment Viewlets Settings Utility"
Exemplo n.º 36
0
    def test_getAvailableReferenceableLinkTypes(self):
        value = self.fti.getAvailableReferenceableLinkTypes()
        if getFSVersionTuple() > (4, 0):
            expected_value =  [
                'Document', 'Event', 'File', 'Folder', 'Image', 'Link',
                'News Item', 'PloneArticle', 'PloneArticleMultiPage', 'Topic'
                ]
        else:
            # Plone 3.x
            expected_value = [
                'Image', 'Topic', 'Large Plone Folder', 'Document', 'PloneArticleMultiPage',
                'Favorite', 'Event', 'Folder', 'Link', 'News Item', 'File', 'PloneArticle'
                ]

        self.assertEquals(set(value), set(expected_value))
Exemplo n.º 37
0
 def __init__(self, not_mapped, old_type, new_type, target_fields):
     if getFSVersionTuple() > (5, ):
         raise NotImplementedError(
             'The inplace migrator migrates from Archetypes.'
             ' Plone 5 has no Archetypes objects.')
     super(FieldsNotMappedError, self).__init__(
         self.message_template.format(
             not_mapped='\n- '.join(sorted(not_mapped)),
             old_type=old_type,
             new_type=new_type,
             target_fields='\n- '.join(sorted(target_fields))))
     self.not_mapped_fields = not_mapped
     self.old_type = old_type
     self.new_type = new_type
     self.target_fields = target_fields
Exemplo n.º 38
0
    def test_not_installable_products_are_not_checked_if_uninstalled(self):
        # Some profiles are not associated with a product.
        # Since we want those profiles to appear in manage-upgrades, we dont verify in the
        # quickinstaller that the product is installed, since it is always not installed because
        # there is no known product.
        # - Products.CMFEditions:CMFEditions
        # - Products.TinyMCE:TinyMCE
        # - plone.app.discussion:default
        # - plone.formwidget.autocomplete:default (depends on Plone version)

        profiles = self.get_listed_profiles(filter_package=None)
        if getFSVersionTuple() < (5,):
            self.assertIn('Products.CMFEditions:CMFEditions', profiles)
            self.assertIn('Products.TinyMCE:TinyMCE', profiles)
        self.assertIn('plone.app.discussion:default', profiles)
Exemplo n.º 39
0
    def setUpPloneSite(self, portal):
        if getFSVersionTuple() > (5, ):
            applyProfile(portal, 'plone.app.contenttypes:default')

        applyProfile(portal,
                     'Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow')
        applyProfile(portal, 'ftw.upgrade:default')

        self.fix_plone_app_jquery_version(portal)
        self.prevent_csrf_by_initializing_site_storages(portal)

        # Enable development mode so that resources are included in separately
        # in the HTML so that we can test for recooked resources.
        registry = getUtility(IRegistry)
        if 'plone.resources.development' in registry:
            registry['plone.resources.development'] = True
Exemplo n.º 40
0
def post_install(context):
    """Post install script"""
    # Do something at the end of the installation of this package.
    site = getSite()
    setup = getToolByName(site, 'portal_setup')

    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile(
            'profile-collective.js.unitegallery:plone4')
        jstool = getToolByName(site, 'portal_javascripts')
        jstool.cookResources()
        csstool = getToolByName(site, 'portal_css')
        csstool.cookResources()
    else:
        setup.runAllImportStepsFromProfile(
            'profile-collective.js.unitegallery:plone5')
Exemplo n.º 41
0
def install(self):
    out = StringIO()

    tool = getToolByName(self, "portal_setup")

    if getFSVersionTuple()[:3] >= (3, 0, 0):
        tool.runAllImportStepsFromProfile("profile-Products.Relations:default",
                                          purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-Products.Relations:default")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)

    print >> out, "Successfully installed %s" % PROJECTNAME
Exemplo n.º 42
0
    def test_getAvailableReferenceableLinkTypes(self):
        value = self.fti.getAvailableReferenceableLinkTypes()
        if getFSVersionTuple() > (4, 0):
            expected_value = [
                'Document', 'Event', 'File', 'Folder', 'Image', 'Link',
                'News Item', 'PloneArticle', 'PloneArticleMultiPage', 'Topic'
            ]
        else:
            # Plone 3.x
            expected_value = [
                'Image', 'Topic', 'Large Plone Folder', 'Document',
                'PloneArticleMultiPage', 'Favorite', 'Event', 'Folder', 'Link',
                'News Item', 'File', 'PloneArticle'
            ]

        self.assertEquals(set(value), set(expected_value))
Exemplo n.º 43
0
    def setUpPloneSite(self, portal):
        if getFSVersionTuple() > (5, ):
            applyProfile(portal, 'plone.app.contenttypes:default')

        applyProfile(
            portal, 'Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow')
        applyProfile(portal, 'ftw.upgrade:default')

        self.fix_plone_app_jquery_version(portal)
        self.prevent_csrf_by_initializing_site_storages(portal)

        # Enable development mode so that resources are included in separately
        # in the HTML so that we can test for recooked resources.
        registry = getUtility(IRegistry)
        if 'plone.resources.development' in registry:
            registry['plone.resources.development'] = True
Exemplo n.º 44
0
def install(self):
    out = StringIO()

    tool=getToolByName(self, "portal_setup")

    if getFSVersionTuple()[:3]>=(3,0,0):
        tool.runAllImportStepsFromProfile(
                "profile-Products.Relations:default",
                purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-Products.Relations:default")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)

    print >> out, "Successfully installed %s" % PROJECTNAME
Exemplo n.º 45
0
def setupRichMenu(context):
    if context.readDataFile('solgema_richmenu.txt') is None:
        return
    portal = context.getSite()
    catalog = getToolByName(portal, 'portal_catalog')
    catalog.manage_reindexIndex()
    setup = getToolByName(portal, 'portal_setup')
    portal_quickinstaller = getToolByName(portal, 'portal_quickinstaller')
    if getFSVersionTuple()[0] == 4:
        setup.runAllImportStepsFromProfile('profile-Solgema.RichMenu:plone4')
    else:
        setup.runAllImportStepsFromProfile('profile-Solgema.RichMenu:plone5')
    if not portal_quickinstaller.isProductInstalled('plone.app.widgets') and not portal_quickinstaller.isProductInstalled('plone.formwidget.contenttree'):
        try:
            setup.runAllImportStepsFromProfile('profile-plone.formwidget.contenttree:default')
        except:
            pass
Exemplo n.º 46
0
def uninstall(portal, reinstall=False):
    setup_tool = portal.portal_setup
    setup_tool.runAllImportStepsFromProfile(
        'profile-redturtle.smartlink:uninstall')
    if getFSVersionTuple()[0] >= 4:
        unregisterIcon(portal)
    if not reinstall:
        removeSmartLinkMarks(portal)
        setup_tool.runAllImportStepsFromProfile(
            'profile-redturtle.smartlink:smartLinkToATLink')
        logger.info("...done. Thanks you for using me!")
        portal.plone_utils.addPortalMessage(_(
            'uninstall_info',
            default=
            u'All of yours Smart Link contents has been transformed back to Plone ATLink'
        ),
                                            type='info')
Exemplo n.º 47
0
def uninstall(self):
    tool = getToolByName(self, "portal_setup")

    if getFSVersionTuple()[0] >= 3:
        tool.runAllImportStepsFromProfile("profile-plonetheme.acmolenbeek:uninstall", purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-plonetheme.acmolenbeek:uninstall")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)

    # Set Plone Default as default skin
    portal_skins = getToolByName(self, "portal_skins")
    portal_skins.default_skin = "Sunburst Theme"

    return "Ran all import steps for profile-plonetheme.acmolenbeek:uninstall."
Exemplo n.º 48
0
def importVarious(self):
    if self.readDataFile('atvocabularymanager.txt') is None:
        return

    site = self.getSite()
    if getFSVersionTuple()[0] >= 5:  # Plone 5
        import_profile(site, 'profile-Products.ATContentTypes:base')

    catalog = getToolByName(site, 'uid_catalog')

    idxName = 'getTermKeyPath'

    if idxName not in catalog.schema():
        catalog.addColumn(idxName)

    if idxName not in catalog.indexes():
        catalog.addIndex(idxName, 'KeywordIndex')
Exemplo n.º 49
0
def install(self):
    # this code courtesy of Raphael Ritz
    out = StringIO()

    tool = getToolByName(self, "portal_setup")

    if getFSVersionTuple()[:3] >= (3, 0, 0):
        tool.runAllImportStepsFromProfile("profile-Products.ATGoogleVideo:default", purge_old=False)
    else:
        plone_base_profileid = "profile-CMFPlone:plone"
        tool.setImportContext(plone_base_profileid)
        tool.setImportContext("profile-Products.ATGoogleVideo:default")
        tool.runAllImportSteps(purge_old=False)
        tool.setImportContext(plone_base_profileid)

    print >> out, "Successfully installed %s" % PROJECTNAME

    return out.getvalue()
Exemplo n.º 50
0
    def test_migrate_class_also_updates_provided_interfaces_info(self):
        if getFSVersionTuple() > (5, ):
            from plone.app.contenttypes.content import Link
            from plone.app.contenttypes.interfaces import ILink
            from plone.app.contenttypes.interfaces import IDocument
        else:
            from Products.ATContentTypes.content.link import ATLink as Link
            from Products.ATContentTypes.interfaces import IATLink as ILink
            from Products.ATContentTypes.interfaces import IATDocument as IDocument

        obj = create(Builder('document'))
        self.assertTrue(IDocument.providedBy(obj))
        self.assertFalse(ILink.providedBy(obj))

        class Step(UpgradeStep):
            def __call__(self):
                self.migrate_class(obj, Link)

        Step(self.portal_setup)
        self.assertFalse(IDocument.providedBy(obj),
                         'Document interface not removed in migration')
        self.assertTrue(ILink.providedBy(obj),
                        'Link interface not added in migration')
Exemplo n.º 51
0
        # If item is moved, apply, fss_move variable to instance
        if not is_moved:
            return

        fss_props = getattr(instance, '_v_fss_props', None)

        if fss_props is None:
            return

        for name, info in fss_props.items():
            fss_info_name = self.getFSSInfoVarname(name)
            setattr(instance, fss_info_name, info)


InitializeClass(FileSystemStorage)

from Products.CMFPlone.utils import getFSVersionTuple

# We switched to full Zope 3 style interfaces since Plone 4
if getFSVersionTuple() < (4, ):
    # Plone 3.x
    FileSystemStorage.__implements__ = StorageLayer.__implements__
    VirtualData.__implements__ = (IStreamIterator, )
    range_filestream_iterator.__implements__ = (IStreamIterator, )
else:
    # Plone 4.x
    from zope.interface import classImplements
    classImplements(VirtualData, IStreamIterator)
    classImplements(range_filestream_iterator, IStreamIterator)
Exemplo n.º 52
0
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
Global configuration data
"""

from Products.CMFPlone.utils import getFSVersionTuple
from Products.PloneGlossary.customconfig import BATCH_SIZE

# Prevent pyflakes warnings ;o)
BATCH_SIZE

# ZCTextIndex patch setup
# don't patch by default
PATCH_ZCTextIndex = False

# condition for adding glossaries items in indexed text
INDEX_SEARCH_GLOSSARY = ('SearchableText', )

PLONE_VERSION = getFSVersionTuple()[:2]  # as (2, 1)
del getFSVersionTuple

PROJECTNAME = 'PloneGlossary'
I18N_DOMAIN = PROJECTNAME.lower()
GLOBALS = globals()
SKINS_DIR = 'skins'
CONFIGLET_ICON = "ploneglossary_tool.gif"
PLONEGLOSSARY_TOOL = 'portal_glossary'
PLONEGLOSSARY_CATALOG = 'glossary_catalog'
Exemplo n.º 53
0
from ftw.publisher.core.states import ConnectionLost
from ftw.publisher.sender.persistence import Realm
from httplib import BadStatusLine
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.statusmessages.interfaces import IStatusMessage
import base64
import os.path
import sys
import socket
import traceback
import transaction
import urllib
import urllib2


IS_PLONE_4 = getFSVersionTuple() < (5,)
IS_AT_LEAST_PLONE_5_1 = getFSVersionTuple() >= (5, 1)


class ReceiverTimeoutError(Exception):
    pass


def _get_savepoint_ids():
    """Returns a list of ids of all currently active savepoints.
    """
    trans = transaction.get()
    if not trans._savepoint2index:
        return None
    else:
        return map(id, trans._savepoint2index)
Exemplo n.º 54
0
 def __call__(self):
     if getFSVersionTuple() > (5, ):
         self.install_upgrade_profile()
Exemplo n.º 55
0
from ftw.upgrade import UpgradeStep
from Products.CMFPlone.utils import getFSVersionTuple

PLONE5 = getFSVersionTuple() >= (5, 0)


class RemoveObsoleteBehaviours(UpgradeStep):
    """Remove obsolete behaviours.
    """

    def __call__(self):
        if PLONE5:
            self.install_upgrade_profile()
Exemplo n.º 56
0
from Products.CMFPlone.utils import getFSVersionTuple
from bda.plone.ticketshop.interfaces import ITicketShopExtensionLayer
from plone.app.robotframework.testing import MOCK_MAILHOST_FIXTURE
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import PLONE_FIXTURE
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import TEST_USER_ID
from plone.app.testing import setRoles
from plone.testing import z2
from zope.interface import alsoProvides
import plone.api

if getFSVersionTuple()[0] >= 5:
    PLONE5 = 1
else:
    PLONE5 = 0


def set_browserlayer(request):
    """Set the BrowserLayer for the request.

    We have to set the browserlayer manually, since importing the profile alone
    doesn't do it in tests.
    """
    alsoProvides(request, ITicketShopExtensionLayer)


class TicketshopLayer(PloneSandboxLayer):
    defaultBases = (PLONE_FIXTURE, )
Exemplo n.º 57
0
# -*- coding: utf-8 -*-
from dexterity.membrane import _
from dexterity.membrane.membrane_helpers import validate_unique_email
from plone.autoform import directives
from plone.supermodel import model
from zope import schema
from zope.interface import Invalid
from zope.interface import invariant

import re

from Products.CMFPlone.utils import getFSVersionTuple
PLONE5 = getFSVersionTuple()[0] >= 5

if PLONE5:
    from plone.app.textfield import RichText
    from plone.app.z3cform.widget import RichTextFieldWidget

def is_email(value):
    """Is this an email address?

    We only do very basic validation, as the docs say we should just
    check if there is an '@' sign in the address.

    >>> is_email('*****@*****.**')
    True
    >>> is_email('joe')
    Traceback (most recent call last):
    ...
    Invalid: Not an email address
    >>> is_email('')
Exemplo n.º 58
0
from collective.transmogrifier.interfaces import ISection
from collective.transmogrifier.interfaces import ISectionBlueprint
from collective.transmogrifier.utils import defaultMatcher
from plone.uuid.interfaces import IUUIDGenerator
from Products.CMFPlone.utils import getFSVersionTuple
from zope.component import getUtility
from zope.interface import classProvides
from zope.interface import implements

if getFSVersionTuple() >= (5, ):
    # Plone 5
    from plone.app.multilingual.interfaces import IMutableTG
    from plone.app.multilingual.interfaces import ITranslatable
    from plone.app.multilingual.interfaces import ITranslationManager
    from Products.CMFPlone.interfaces import ILanguage

else:
    # Plone <= 4
    from plone.multilingual.interfaces import ILanguage
    from plone.multilingual.interfaces import IMutableTG
    from plone.multilingual.interfaces import ITranslatable
    from plone.multilingual.interfaces import ITranslationManager


class LinguaPloneItemLinker(object):
    """Link content from a page that was translated with LinguaPlone.
    The items in the pipeline are ecpected to have the following keys:

        - a boolean indicating whether they are a 'canonical' translation
        - a reference (path) to the canonical translation (points to the item
          itself when the item is a canonical translation)