Пример #1
0
    def get_html_tag(self,
                     additional_classes=[],
                     url_extension='',
                     viewname='download',
                     include_token=False):
        file_url = self.context.absolute_url()

        # Do not display a download confirmation for mail items
        if self.is_active() and not IOGMailMarker.providedBy(self.context):
            viewname = 'file_download_confirmation'
            clazz = (('link-overlay '
                      'modal '
                      '{0}').format(' '.join(additional_classes)))
        else:
            clazz = ' '.join(additional_classes)

        url = '{0}/{1}{2}'.format(file_url, viewname, url_extension)
        if include_token:
            url = addTokenToUrl(url)

        label = translate(_(u'label_download_copy', default='Download copy'),
                          context=self.request).encode('utf-8')

        return ('<a href="{0}" '
                'id="action-download" '
                'class="{1}">{2}</a>').format(url, clazz, label)
Пример #2
0
    def get_html_tag(self, additional_classes=[], url_extension='',
                     viewname='download', include_token=False):
        file_url = self.context.absolute_url()

        # Do not display a download confirmation for mail items
        if self.is_active() and not IOGMailMarker.providedBy(self.context):
            viewname = 'file_download_confirmation'
            clazz = (('link-overlay '
                      'modal '
                      '{0}')
                     .format(' '.join(additional_classes)))
        else:
            clazz = ' '.join(additional_classes)

        url = '{0}/{1}{2}'.format(file_url, viewname, url_extension)
        if include_token:
            url = addTokenToUrl(url)

        label = translate(_(u'label_download_copy', default='Download copy'),
                          context=self.request).encode('utf-8')

        return ('<a href="{0}" '
                'id="action-download" '
                'class="{1}">{2}</a>').format(url, clazz, label)
Пример #3
0
 def test_og_mail_behavior(self):
     mail = create(Builder("mail"))
     self.assertTrue(
         IOGMailMarker.providedBy(mail),
         'ftw mail obj does not provide the OGMail behavior interface.')
Пример #4
0
 def test_og_mail_behavior(self):
     mail = create(Builder("mail"))
     self.assertTrue(
         IOGMailMarker.providedBy(mail),
         'ftw mail obj does not provide the OGMail behavior interface.')
def main(app, argv=sys.argv[1:]):
    options, args = parser.parse_args()

    mode = options.mode.lower() if options.mode else None

    if not options.mode:
        parser.print_help()
        parser.error(
            'Please specify the "mode" with "bin/instance run <yourscript> -m '
            'reindex | history | store | activate"\n'
            )

    if options.plone_path:
        plone = app.unrestrictedTraverse(options.plone_path)
    else:
        plone = get_first_plone_site(app)

    setup_plone(plone)

    converter = getUtility(IBumblebeeConverter)

    if mode == 'reindex':
        LOG.info("Start indexing objects...")
        converter.reindex()
        return transaction.commit()

    elif mode == 'history':
        LOG.info("Start creating checksums for portal repository ...")
        repository = api.portal.get_tool('portal_repository')
        catalog = api.portal.get_tool('portal_catalog')

        brains = catalog.unrestrictedSearchResults(
            {'object_provides': 'ftw.bumblebee.interfaces.IBumblebeeable'})

        for brain in ProgressLogger(
                'Create checksums for objects in portal repository', brains,
                logger=LOG):

            obj = brain.getObject()
            versions = repository.getHistory(obj)
            if IOGMailMarker.providedBy(obj):
                if len(versions) > 0:
                    LOG.warning('Found mail with versions: {}'.format('/'.join(obj.getPhysicalPath())))
                continue

            for version in versions:
                # we have to calculate the checksum on the "restored" object
                # returned by `portal_repository`. The archived object does not
                # contain an accessible file without `portal_repository` magic.
                version_checksum = IBumblebeeDocument(version.object).calculate_checksum()

                archived_obj = Archeologist(obj, version).excavate()
                annotations = IAnnotations(archived_obj)
                annotations[DOCUMENT_CHECKSUM_ANNOTATION_KEY] = version_checksum
                archived_obj._p_changed = True

        return transaction.commit()

    elif mode == 'store':
        LOG.info("Start storing objects...")
        if not options.reset:
            LOG.warning(
                "You started storing without reseting the timestamp. "
                "Already converted objects will be skipped.")

        return converter.store(deferred=True, reset_timestamp=options.reset)

    elif mode == 'activate':
        api.portal.set_registry_record(
            'is_feature_enabled', True, interface=IGeverBumblebeeSettings)
        LOG.info("activating bumblebee feature in registry.")
        return transaction.commit()

    else:
        parser.print_help()
        parser.error('You entered an invalid mode: {}\n'.format(mode))