コード例 #1
0
    def __call__(self, event, no_response=False, msg=None):
        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning(
                'Could not create move job for blacklisted object (%s at %s)' %
                (self.context.Title(), '/'.join(
                    self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        # This View should not be executed at the PloneSiteRoot
        if IPloneSiteRoot.providedBy(self.context):
            raise Exception('Not allowed on PloneSiteRoot')

        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()

        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)

        additional_data = {
            'move_data': {
                'newName': event.newName,
                'newParent': get_site_relative_path(event.newParent),
                'newTitle': event.object.Title().decode('utf-8'),
                'oldName': event.oldName,
                'oldParent': get_site_relative_path(event.oldParent),
            }
        }

        queue.createJob('move',
                        self.context,
                        username,
                        additional_data=additional_data)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
            'move',
            self.context.Title(),
            '/'.join(self.context.getPhysicalPath()),
        ))

        # status message
        if msg is None:
            msg = _(u'Object move/rename action has been added to the queue.')

        IStatusMessage(self.request).addStatusMessage(msg, type='info')
        if not no_response:
            return self.request.RESPONSE.redirect('./view')
コード例 #2
0
    def __call__(self, no_response=False, msg=None, *args, **kwargs):
        """
        The __call__ method is used to execute the BrowserView. It creates and
        adds a "PUSH"-Job on the current context to the queue.
        @param args:    list of unnamed arguments
        @type args:     list
        @param kwargs:  dict of named keyword-arguments
        @type kwargs:   dict
        @return:        Redirect to object`s default view
        """

        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning('Could not create push job for blacklisted '+\
                                    'object (%s at %s)' % (
                    self.context.Title(),
                    '/'.join(self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        # mle: now its possible to execite this view on plonesiteroot
        # This View should not be executed at the PloneSiteRoot
        #if IPloneSiteRoot.providedBy(self.context):
        #    raise Exception('Not allowed on PloneSiteRoot')
        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()
        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)
        queue.createJob('push', self.context, username)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
                'push',
                self.context.Title(),
                '/'.join(self.context.getPhysicalPath()),
                ))

        # status message
        if msg is None:
            msg = _(u'This object has been added to the queue.')
        IStatusMessage(self.request).addStatusMessage(
            msg,
            type='info'
            )
        if not no_response:
            return self.request.RESPONSE.redirect('./view')
コード例 #3
0
    def __call__(self, no_response=False, msg=None, *args, **kwargs):
        """
        Add the current context as delete-job to the queue, creates a status
        message to inform the user and returns to the default view.
        @param args:    list of unnamed arguments
        @type args:     list
        @param kwargs:  dict of named keyword-arguments
        @type kwargs:   dict
        @return:        Redirect to object`s default view
        """

        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning('Could not create delete job for blacklisted '
                                'object (%s at %s)' % (
                    self.context.Title(),
                    '/'.join(self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        # This view should not be executed at the PloneSiteRoot
        if IPloneSiteRoot.providedBy(self.context):
            raise Exception('Not allowed on PloneSiteRoot')
        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()
        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)
        queue.createJob('delete', self.context, username)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
                'delete',
                self.context.Title(),
                '/'.join(self.context.getPhysicalPath()),
                ))

        # status message
        if msg is None:
            msg = _(u'This object will be deleted at the remote sites.')
        add_transaction_aware_status_message(self.request, msg, type='info')

        if not no_response:
            return self.request.RESPONSE.redirect('./view')
コード例 #4
0
    def createJob(self, *args, **kwargs):
        """
        Creates a new Job object, adds it to the queue
        and returns it.
        Arguments are redirected to the Job-Constructor.
        @return:    Job object
        @rtype:     Job
        """
        if publisher_jobs_are_disabled():
            return None

        job = Job(*args, **kwargs)
        self.appendJob(job)
        return job
コード例 #5
0
    def appendJob(self, job):
        """
        Appends a Job to the queue
        @param job:     Job object
        @type:          Job
        @return:        None
        """
        if publisher_jobs_are_disabled():
            return None

        if not isinstance(job, Job):
            raise TypeError('Excpected Job object')

        self._get_jobs_queue().put(job)
コード例 #6
0
    def createJob(self, *args, **kwargs):
        """
        Creates a new Job object, adds it to the queue
        and returns it.
        Arguments are redirected to the Job-Constructor.
        @return:    Job object
        @rtype:     Job
        """
        if publisher_jobs_are_disabled():
            return None

        job = Job(*args, **kwargs)
        self.appendJob(job)
        return job
コード例 #7
0
    def appendJob(self, job):
        """
        Appends a Job to the queue
        @param job:     Job object
        @type:          Job
        @return:        None
        """
        if publisher_jobs_are_disabled():
            return None

        if not isinstance(job, Job):
            raise TypeError('Excpected Job object')

        self._get_jobs_queue().put(job)
コード例 #8
0
    def __call__(self, no_response=False, msg=None, recursive=True):
        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning(
                'Could not create push job for blacklisted object (%s at %s)' %
                (self.context.Title(), '/'.join(
                    self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        event.notify(BeforePublishEvent(self.context))

        # mle: now its possible to execite this view on plonesiteroot
        # This View should not be executed at the PloneSiteRoot
        # if IPloneSiteRoot.providedBy(self.context):
        #    raise Exception('Not allowed on PloneSiteRoot')
        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()

        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)
        queue.createJob('push', self.context, username)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
            'push',
            self.context.Title(),
            '/'.join(self.context.getPhysicalPath()),
        ))

        if recursive and base_hasattr(self.context, 'contentValues'):
            # Use contentValues for implicit ftw.trash compatibility.
            for obj in filter(belongs_to_parent, self.context.contentValues()):
                obj.restrictedTraverse('@@publisher.publish')(no_response=True,
                                                              msg=msg)

        # status message
        if msg is None:
            msg = _(u'This object has been added to the queue.')
        IStatusMessage(self.request).addStatusMessage(msg, type='info')
        if not no_response:
            return self.request.RESPONSE.redirect('./view')
コード例 #9
0
    def __call__(self, no_response=False, msg=None):
        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning('Could not create delete job for blacklisted '
                                'object (%s at %s)' %
                                (self.context.Title(), '/'.join(
                                    self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        # This view should not be executed at the PloneSiteRoot
        if IPloneSiteRoot.providedBy(self.context):
            raise Exception('Not allowed on PloneSiteRoot')

        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()

        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)
        queue.createJob('delete', self.context, username)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
            'delete',
            self.context.Title(),
            '/'.join(self.context.getPhysicalPath()),
        ))

        # status message
        if msg is None:
            msg = _(u'This object will be deleted at the remote sites.')
        add_transaction_aware_status_message(self.request, msg, type='info')

        if not no_response:
            return self.request.RESPONSE.redirect('./view')
コード例 #10
0
    def __call__(self, event, no_response=False, msg=None, *args, **kwargs):
        """
        Creates a "rename" job for the current item(s)
        @param args:    list of unnamed arguments
        @type args:     list
        @param kwargs:  dict of named keyword-arguments
        @type kwargs:   dict
        @return:        Redirect to object`s default view
        """

        if IPreventPublishing.providedBy(self.context):
            return 'prevented'

        if publisher_jobs_are_disabled():
            return 'disabled'

        self.logger = getLogger()
        # is the object blacklisted?
        if IPathBlacklist(self.context).is_blacklisted():
            self.logger.warning('Could not create move job for blacklisted '+\
                                    'object (%s at %s)' % (
                    self.context.Title(),
                    '/'.join(self.context.getPhysicalPath())))
            if not no_response:
                return self.request.RESPONSE.redirect('./view')
            return False

        # This View should not be executed at the PloneSiteRoot
        if IPloneSiteRoot.providedBy(self.context):
            raise Exception('Not allowed on PloneSiteRoot')
        # get username
        user = self.context.portal_membership.getAuthenticatedMember()
        username = user.getUserName()
        # create Job
        portal = self.context.portal_url.getPortalObject()
        queue = IQueue(portal)

        additional_data = {'move_data': {
            'newName': event.newName,
            'newParent': get_site_relative_path(event.newParent),
            'newTitle': event.object.Title().decode('utf-8'),
            'oldName': event.oldName,
            'oldParent': get_site_relative_path(event.oldParent),
        }}

        queue.createJob('move', self.context, username,
                        additional_data=additional_data)
        self.logger.debug('Created "%s" Job for "%s" at %s' % (
            'move',
            self.context.Title(),
            '/'.join(self.context.getPhysicalPath()),
        ))
        # status message
        if msg is None:
            msg = _(u'Object move/rename action has been added to the queue.')

        IStatusMessage(self.request).addStatusMessage(
            msg,
            type='info'
        )
        if not no_response:
            return self.request.RESPONSE.redirect('./view')