Esempio n. 1
0
    def download(self, email="", **kwargs):
        """ Download
        """
        # Fallback ePub provided
        if self.fallback:
            self._link = self.fallback

        storage = IStorage(self.context).of("epub")
        filepath = storage.filepath()
        fileurl = self.link()
        url = self.context.absolute_url()
        title = self.context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty("email_from_name")
        from_email = portal.getProperty("email_from_address")

        if self.fallback or async.file_exists(filepath):
            wrapper = async.ContextWrapper(self.context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title,
                etype="epub",
            )

            event.notify(AsyncEPUBExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 2
0
 def link(self):
     """ Download link
     """
     if not self._link:
         storage = IStorage(self.context).of('pdf')
         self._link = storage.absolute_url()
     return self._link
Esempio n. 3
0
 def link(self):
     """ Download link
     """
     if not self._link:
         storage = IStorage(self.context).of("epub")
         self._link = storage.absolute_url()
     return self._link
Esempio n. 4
0
    def download(self, email='', **kwargs):
        """ Download
        """
        # Fallback PDF provided
        fallback = self.context.restrictedTraverse('action-download-pdf', None)
        if fallback and fallback.absolute_url().startswith(
                self.context.absolute_url()):
            self._link = self.context.absolute_url() + '/action-download-pdf'
        else:
            fallback = None

        # PDF already generated
        storage = IStorage(self.context).of('pdf')
        filepath = storage.filepath()
        fileurl = self.link()
        url = self.context.absolute_url()
        title = self.context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if fallback or async.file_exists(filepath):
            wrapper = async.ContextWrapper(self.context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title
            )

            event.notify(AsyncPDFExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 5
0
    def download(self, email='', **kwargs):
        """ Download
        """
        # Fallback ePub provided
        if self.fallback:
            self._link = self.fallback

        storage = IStorage(self.context).of('epub')
        filepath = storage.filepath()
        fileurl = self.link()
        url = self.context.absolute_url()
        title = self.context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if self.fallback or async .file_exists(filepath):
            wrapper = async .ContextWrapper(self.context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title,
                etype='epub')

            event.notify(AsyncEPUBExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 6
0
    def download(self, email='', **kwargs):
        """ Download
        """
        # Fallback PDF provided
        fallback = self.context.restrictedTraverse('action-download-pdf', None)
        if fallback and fallback.absolute_url().startswith(
                self.context.absolute_url()):
            self._link = self.context.absolute_url() + '/action-download-pdf'
        else:
            fallback = None

        # PDF already generated
        storage = IStorage(self.context).of('pdf')
        filepath = storage.filepath()
        fileurl = self.link()
        url = self.context.absolute_url()
        title = self.context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if fallback or async .file_exists(filepath):
            wrapper = async .ContextWrapper(self.context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title)

            event.notify(AsyncPDFExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 7
0
    def download(self, email='', **kwargs):
        """ Download
        """
        # PDF already generated
        storage = IStorage(self.context).of('pdf')
        filepath = storage.filepath()
        fileurl = storage.absolute_url()
        url = self.context.absolute_url()
        title = self.context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if async .file_exists(filepath):
            wrapper = async .ContextWrapper(self.context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title)

            event.notify(AsyncPDFExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 8
0
 def flushPDFsCache(self):
     """ Flush all PDFs cache for this theme
     """
     catalog = getToolByName(self.context, 'portal_catalog')
     for brain in catalog.searchResults(portal_type=self.types):
         obj = brain.getObject()
         storage = IStorage(obj).of('pdf')
         storage_pdf_obj = obj.unrestrictedTraverse(
             storage.absolute_url(True), None)
         #change modification time only if
         #the object has a PDF generated in downloads
         if storage_pdf_obj is not None:
             updateContext(obj)
     return json.dumps('ok')
Esempio n. 9
0
 def flushPDFsCache(self):
     """ Flush all PDFs cache for this theme
     """
     catalog = getToolByName(self.context, 'portal_catalog')
     for brain in catalog.searchResults(portal_type=self.types):
         obj = brain.getObject()
         storage = IStorage(obj).of('pdf')
         storage_pdf_obj = obj.unrestrictedTraverse(
             storage.absolute_url(True), None)
         #change modification time only if
         #the object has a PDF generated in downloads
         if storage_pdf_obj is not None:
             updateContext(obj)
     return json.dumps('ok')
Esempio n. 10
0
    def download(self, email='', **kwargs):
        """ Download
        """
        context = self.context
        # Fallback PDF provided
        fallback = context.restrictedTraverse('action-download-pdf', None)
        if fallback and fallback.absolute_url().startswith(
                context.absolute_url()):
            self._link = context.absolute_url() + '/action-download-pdf'
        else:
            fallback = None
        wrapped_field = getattr(context, 'getWrappedField', None)
        if wrapped_field:
            static = context.getWrappedField('pdfStatic')
            if static and getattr(static, 'getFilename', lambda x: '')(context):
                self._link = context.absolute_url() + '/download.pdf.static'
                fallback = True

        # PDF already generated
        storage = IStorage(context).of('pdf')
        filepath = storage.filepath()
        fileurl = self.link()
        url = context.absolute_url()
        title = context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if fallback or async.file_exists(filepath):
            wrapper = IContextWrapper(context)(
                fileurl=fileurl,
                filepath=filepath,
                email=email,
                url=url,
                from_name=from_name,
                from_email=from_email,
                title=title
            )

            event.notify(AsyncPDFExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 11
0
    def download(self, email='', **kwargs):
        """ Download
        """
        context = self.context
        # Fallback PDF provided
        fallback = context.restrictedTraverse('action-download-pdf', None)
        if fallback and fallback.absolute_url().startswith(
                context.absolute_url()):
            self._link = context.absolute_url() + '/action-download-pdf'
        else:
            fallback = None
        wrapped_field = getattr(context, 'getWrappedField', None)
        if wrapped_field:
            static = context.getWrappedField('pdfStatic')
            if static and getattr(static, 'getFilename',
                                  lambda x: '')(context):
                self._link = context.absolute_url() + '/download.pdf.static'
                fallback = True

        # PDF already generated
        storage = IStorage(context).of('pdf')
        filepath = storage.filepath()
        fileurl = self.link()
        url = context.absolute_url()
        title = context.title_or_id()

        portal = getSite()
        from_name = portal.getProperty('email_from_name')
        from_email = portal.getProperty('email_from_address')

        if fallback or async .file_exists(filepath):
            wrapper = IContextWrapper(context)(fileurl=fileurl,
                                               filepath=filepath,
                                               email=email,
                                               url=url,
                                               from_name=from_name,
                                               from_email=from_email,
                                               title=title)

            event.notify(AsyncPDFExportSuccess(wrapper))
            return self.finish(email=email)
Esempio n. 12
0
 def link(self):
     """ Download link
     """
     storage = IStorage(self.context).of('pdf')
     return storage.absolute_url()