def prepare_mountpoint(app, path):
    for mountpoint in manage_getMountStatus(app):
        if mountpoint["path"] == path:
            break
    else:
        raise zc.buildout.UserError('That mountpoint does not exist in zope.conf')

    if mountpoint["status"] == "** Something is in the way **":
        raise zc.buildout.UserError("The current filestorage has an obstruction prevent use of the ZODB Mount '%s'!" % path)

    elif mountpoint["status"] == "Ready to create":
        manage_addMounts(app, (path, ))
        print "Created mount point '%s'" % path

    elif mountpoint["status"] == "Ok":
        print "Mount point '%s' is Ok, nothing to update"

    else:
        raise zc.buildout.UserError("Mountpoint '%s' is '%s' - that is an unknown state, buildout cant continue" % (path, mountpoint["status"]))

    # Traverse from the root to wherever the mountpoint is, return that as the place the
    # plone site will be created
    retval = app
    for part in path.split("/"):
        if not part:
            continue
        retval = app[part]

    return retval
Esempio n. 2
0
    def setUp(self):
        global original_config
        if original_config is None:
            # stow away original config so we can reset it
            original_config = App.config.getConfiguration()

        databases = [
            TestDBConfig('test_main.fs', ['/']).getDB(),
            TestDBConfig('test_mount1.fs', ['/mount1']).getDB(),
            TestDBConfig('test_mount2.fs', ['/mount2']).getDB(),
        ]
        mount_points = {}
        mount_factories = {}
        for database in databases:
            points = database.getVirtualMountPaths()
            name = database.config.getSectionName()
            mount_factories[name] = database
            for point in points:
                mount_points[point] = name
        conf = DBTab(mount_factories, mount_points)
        d = App.config.DefaultConfiguration()
        d.dbtab = conf
        App.config.setConfiguration(d)
        self.conf = conf
        db = conf.getDatabase('/')
        conn = db.open()
        root = conn.root()
        root['Application'] = app = Application()
        self.app = app
        transaction.commit()  # Get app._p_jar set
        manage_addMounts(app, ('/mount1', '/mount2'))
        transaction.commit()  # Get the mount points ready
def setupMountFolder(app, quiet=0):
    transaction.begin()
    _start = time.time()
    portal = app.portal

    if not quiet: ZopeTestCase._print('Installing MountFolder ... ')

    # login as manager
    user = app.acl_users.getUserById(portal_owner).__of__(app.acl_users)
    newSecurityManager(None, user)
    
    # add MountFolder
    if hasattr(aq_base(portal), 'portal_mountfolder'):
        ZopeTestCase._print('MountFolder already installed ... ')
    else:
        installMountFolder(portal)

    # Initialized MountPoint
    manage_addMounts(app, (mountfolder_path,))
    transaction.commit()

    # Create portal member
    portal.portal_registration.addMember(portal_member, 'azerty', ['Member'])
    portal.portal_registration.addMember(portal_member2, 'azerty', ['Member'])

    # Log out
    noSecurityManager()
    transaction.commit()
    if not quiet: ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
Esempio n. 4
0
 def setUp(self):
     global original_config
     if original_config is None:
         # stow away original config so we can reset it
         original_config = App.config.getConfiguration()
         
     databases = [TestDBConfig('test_main.fs', ['/']).getDB(),
                  TestDBConfig('test_mount1.fs', ['/mount1']).getDB(),
                  TestDBConfig('test_mount2.fs', ['/mount2']).getDB(),
                  ]
     mount_points = {}
     mount_factories = {}
     for database in databases:
         points = database.getVirtualMountPaths()
         name = database.config.getSectionName()
         mount_factories[name] = database
         for point in points:
             mount_points[point] = name
     conf = DBTab(mount_factories, mount_points)
     d = App.config.DefaultConfiguration()
     d.dbtab = conf
     App.config.setConfiguration(d)
     self.conf = conf
     db = conf.getDatabase('/')
     conn = db.open()
     root = conn.root()
     root['Application'] = app = Application()
     self.app = app
     transaction.commit()  # Get app._p_jar set
     manage_addMounts(app, ('/mount1', '/mount2'))
     transaction.commit()  # Get the mount points ready
Esempio n. 5
0
    def install_tempfolder_and_sdc(self):
        app = self.getApp()
        from Products.ZODBMountPoint.MountedObject import manage_addMounts,\
             MountedObject
        from Products.ZODBMountPoint.MountedObject import getConfiguration as \
             getDBTabConfiguration

        dbtab_config = getDBTabConfiguration()

        tf = getattr(app, 'temp_folder', None)

        if getattr(tf, 'meta_type', None) == MountedObject.meta_type:
            # tf is a MountPoint object.  This means that the temp_folder
            # couldn't be mounted properly (the meta_type would have been
            # the meta type of the container class otherwise).  The
            # MountPoint object writes a message to zLOG so we don't
            # need to.
            return

        if tf is None:
            # do nothing if we've already installed one
            if not app._getInitializerFlag('temp_folder'):
                if dbtab_config is None:
                    # DefaultConfiguration, do nothing
                    return
                mount_paths = [ x[0] for x in dbtab_config.listMountPaths() ]
                if not '/temp_folder' in mount_paths:
                    # we won't be able to create the mount point properly
                    LOG.error('Could not initialze a Temporary Folder because '
                              'a database was not configured to be mounted at '
                              'the /temp_folder mount point')
                    return
                try:
                    manage_addMounts(app, ('/temp_folder',))
                    app._setInitializerFlag('temp_folder')
                    self.commit('Added temp_folder')
                    tf = app.temp_folder
                except:
                    LOG.error('Could not add a /temp_folder mount point due to an '
                              'error.', exc_info=sys.exc_info())
                    return

        # Ensure that there is a transient object container in the temp folder
        config = getConfiguration()

        if not hasattr(aq_base(tf), 'session_data'):
            from Products.Transience.Transience import TransientObjectContainer
            addnotify = getattr(config, 'session_add_notify_script_path', None)
            delnotify = getattr(config, 'session_delete_notify_script_path',
                                None)
            default_limit = 1000
            default_period_secs = 20
            default_timeout_mins = 20

            limit = getattr(config, 'maximum_number_of_session_objects',
                            default_limit)
            timeout_spec = getattr(config, 'session_timeout_minutes',
                                   default_timeout_mins)
            period_spec = getattr(config, 'session_resolution_seconds',
                                  default_period_secs)

            if addnotify and app.unrestrictedTraverse(addnotify, None) is None:
                LOG.warn('failed to use nonexistent "%s" script as '
                         'session-add-notify-script-path' % addnotify)
                addnotify=None

            if delnotify and app.unrestrictedTraverse(delnotify, None) is None:
                LOG.warn('failed to use nonexistent "%s" script as '
                         'session-delete-notify-script-path' % delnotify)
                delnotify=None

            if 1:  # Preserve indentation for diff
                toc = TransientObjectContainer('session_data',
                                               'Session Data Container',
                                               timeout_mins = timeout_spec,
                                               addNotification = addnotify,
                                               delNotification = delnotify,
                                               limit=limit,
                                               period_secs = period_spec)

            tf._setObject('session_data', toc)
            tf_reserved = getattr(tf, '_reserved_names', ())
            if 'session_data' not in tf_reserved:
                tf._reserved_names = tf_reserved + ('session_data',)
            self.commit('Added session_data to temp_folder')
            return tf # return the tempfolder object for test purposes
Esempio n. 6
0
    def install_tempfolder_and_sdc(self):
        app = self.getApp()
        from Products.ZODBMountPoint.MountedObject import manage_addMounts,\
             MountedObject
        from Products.ZODBMountPoint.MountedObject import getConfiguration as \
             getDBTabConfiguration

        dbtab_config = getDBTabConfiguration()

        tf = getattr(app, 'temp_folder', None)

        if getattr(tf, 'meta_type', None) == MountedObject.meta_type:
            # tf is a MountPoint object.  This means that the temp_folder
            # couldn't be mounted properly (the meta_type would have been
            # the meta type of the container class otherwise).  The
            # MountPoint object writes a message to zLOG so we don't
            # need to.
            return

        if tf is None:
            # do nothing if we've already installed one
            if not app._getInitializerFlag('temp_folder'):
                if dbtab_config is None:
                    # DefaultConfiguration, do nothing
                    return
                mount_paths = [x[0] for x in dbtab_config.listMountPaths()]
                if not '/temp_folder' in mount_paths:
                    # we won't be able to create the mount point properly
                    LOG.error('Could not initialze a Temporary Folder because '
                              'a database was not configured to be mounted at '
                              'the /temp_folder mount point')
                    return
                try:
                    manage_addMounts(app, ('/temp_folder', ))
                    app._setInitializerFlag('temp_folder')
                    self.commit('Added temp_folder')
                    tf = app.temp_folder
                except:
                    LOG.error(
                        'Could not add a /temp_folder mount point due to an '
                        'error.',
                        exc_info=sys.exc_info())
                    return

        # Ensure that there is a transient object container in the temp folder
        config = getConfiguration()

        if not hasattr(aq_base(tf), 'session_data'):
            from Products.Transience.Transience import TransientObjectContainer
            addnotify = getattr(config, 'session_add_notify_script_path', None)
            delnotify = getattr(config, 'session_delete_notify_script_path',
                                None)
            default_limit = 1000
            default_period_secs = 20
            default_timeout_mins = 20

            limit = getattr(config, 'maximum_number_of_session_objects',
                            default_limit)
            timeout_spec = getattr(config, 'session_timeout_minutes',
                                   default_timeout_mins)
            period_spec = getattr(config, 'session_resolution_seconds',
                                  default_period_secs)

            if addnotify and app.unrestrictedTraverse(addnotify, None) is None:
                LOG.warn('failed to use nonexistent "%s" script as '
                         'session-add-notify-script-path' % addnotify)
                addnotify = None

            if delnotify and app.unrestrictedTraverse(delnotify, None) is None:
                LOG.warn('failed to use nonexistent "%s" script as '
                         'session-delete-notify-script-path' % delnotify)
                delnotify = None

            if 1:  # Preserve indentation for diff
                toc = TransientObjectContainer('session_data',
                                               'Session Data Container',
                                               timeout_mins=timeout_spec,
                                               addNotification=addnotify,
                                               delNotification=delnotify,
                                               limit=limit,
                                               period_secs=period_spec)

            tf._setObject('session_data', toc)
            tf_reserved = getattr(tf, '_reserved_names', ())
            if 'session_data' not in tf_reserved:
                tf._reserved_names = tf_reserved + ('session_data', )
            self.commit('Added session_data to temp_folder')
            return tf  # return the tempfolder object for test purposes
 def afterSetUp(self,):
     # Now we add the mount point for the content itself
     Log(LOG_DEBUG, "afterSetUp")
     manage_addMounts(self.app, ('/portal/content', ))       #'/portal/content2'))
     transaction.commit()  # Get the mount points ready