Example #1
0
class MyViewA(Page):
    grok.context(Interface)
    grok.name('myview')
    grok.layer(IDefaultLayer)

    def render(self):
        return "MYVIEW"
Example #2
0
class MyViewB(Page):
    grok.context(Interface)
    grok.name('myview')
    grok.layer(IAnotherLayer)

    def render(self):
        return "MYVIEW"
class ContentProvider(grok.ContentProvider):
    grok.name('foo')
    grok.context(Interface)
    grok.template('contentprovider')

    def render(self):
        """There's also a template!
Example #4
0
class LayeredPot(grok.ContentProvider):
    grok.name('pot')
    grok.context(Interface)
    grok.layer(IBoneLayer)

    def render(self):
        return u"Layered pot"
Example #5
0
class CaveView(grok.View):
    grok.context(Cave)

    def render(self):
        return self.static['resource.css']()
class AOneLayout(Layout):
    grok.context(One)
    grok.layer(IALayer)

    def render(self):
        return "Layout A for context One"
Example #7
0
class ViewOne(Page):
    grok.context(Interface)

    def render(self):
        return "MyView on regular layout"
Example #8
0
class LayoutOne(Layout):
    grok.context(One)

    def render(self):
        return "Layout One"
class BOneLayout(Layout):
    grok.context(One)
    grok.layer(IBLayer)

    def render(self):
        return "Layout B for context One"
Example #10
0
class Painting(grok.View):
    grok.context(zope.interface.Interface)
    grok.require(ViewPainting)

    def render(self):
        return 'What a beautiful painting.'
Example #11
0
class BLayout(Layout):
    grok.context(B)
    grok.layer(IAnotherLayer)

    def render(self):
        return "B Layout"
Example #12
0
class A2Layout(Layout):
    grok.context(A)
    grok.layer(IAnotherLayer)

    def render(self):
        return "A2 Layout"
Example #13
0
class ALayout(Layout):
    grok.context(A)
    grok.layer(IDefaultLayer)

    def render(self):
        return "A Layout"
Example #14
0
class BogusView(grok.View):
    grok.context(zope.interface.Interface)

    @grok.require(Bogus)
    def render(self):
        pass
Example #15
0
class MyView(Page):
    grok.context(Interface)
    grok.layer(IALayer)

    def render(self):
        return "MyView on IALayouer"
Example #16
0
class BTwoLayout(Layout):
    grok.context(Two)
    grok.layer(IBLayer)

    def render(self):
        return "Layout B for context Two"
Example #17
0
class Food(grok.View):
    grok.context(Mammoth)
Example #18
0
When providing a skin **name**, it will be injected in the URLs:

  >>> index_view.url(skin='foobar')
  'http://127.0.0.1/++skin++foobar/herd/manfred/test'

"""
import six
import grokcore.view as grok
from zope.container.contained import Contained


class Mammoth(Contained):
    pass


grok.context(Mammoth)


class Index(grok.View):
    def render(self):
        return self.url()


class Another(grok.View):
    def render(self):
        return self.url()


class YetAnother(grok.View):
    pass
Example #19
0
class BaseView(grok.View):
    grok.template('basetemplate')
    grok.context(object)
Example #20
0
class Index(grok.View):
    grok.context(zope.interface.Interface)

    def render(self):
        return u"Hi"
Example #21
0
class PublicNudity(grok.View):
    grok.context(zope.interface.Interface)
    grok.require(grok.Public)

    def render(self):
        return 'Everybody can see this.'
Example #22
0
class ATwoLayout(Layout):
    grok.context(Two)
    grok.layer(IALayer)

    def render(self):
        return "Layout A for context Two"
Example #23
0
  >>> index_view.url(skin=AnotherURLTestingSkin)
  'http://127.0.0.1/++skin++anotherurltesting/herd/manfred/test'

When providing a skin **name**, it will be injected in the URLs:

  >>> index_view.url(skin='foobar')
  'http://127.0.0.1/++skin++foobar/herd/manfred/test'

"""
import grokcore.view as grok
from zope.container.contained import Contained

class Mammoth(Contained):
    pass

grok.context(Mammoth)

class Index(grok.View):
    def render(self):
        return self.url()

class Another(grok.View):
    def render(self):
        return self.url()

class YetAnother(grok.View):
    pass

class Multiplier(grok.View):
    def update(self, age=0):
        self.age = age
Example #24
0
class CaveView(grok.View):
    grok.context(Cave)
Example #25
0
class ClubContentProvider(grok.ContentProvider):
    grok.name('manage.clubmen')
    grok.context(Club)

    def render(self):
        pass
Example #26
0
class CaveView(grok.View):
    grok.context(Interface)
Example #27
0
class LayoutTwo(Layout):
    grok.context(One)
    grok.provides(ILayoutTwo)

    def render(self):
        return "Layout Two"
Example #28
0
class Pot(grok.ContentProvider):
    grok.context(Interface)

    def render(self):
        return u"Soup pot"
Example #29
0
class ViewTwo(Page):
    grok.context(Interface)
    layout(ILayoutTwo)

    def render(self):
        return "MyView on layout two"
Example #30
0
class LandingPage(ApplicationForm):
    grok.context(interface.IInvoiceUploader)
    grok.name("index")
    grok.require("zope.Public")

    fields = Fields(interface.IInvoice)

    def update(self):
        resource.style.need()

    @action("Senden")
    def handel_save(self):
        data, errors = self.extractData()
        if errors:
            self.flash(u'Es sind leider Fehler aufgetreten')
            return
        if data['anrede'] == '':
            self.flash(u'Bitte wählen Sie eine Anrede aus.')
            return
        if data['email'] != '':
            checkmail = re.compile(
                r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$").match
            if not bool(checkmail(data['email'])):
                self.flash(
                    u'Bitte tragen Sie eine gültige E-Mail Adresse ein.')
                return
        if data['datenschutz'] is False:
            self.flash(
                u'Bitte bestätigen Sie die Datenschutzerklärung der UKH.')
            return
        for x in data['anlagen']:
            if x == NO_VALUE:
                self.flash(u'Sie haben keine Dateien zum Upload ausgewählt!')
                return
        output_path = settings.get('output_path')
        pdfstreams = []
        pdf_fn = UploadPdf(data, None)
        for attachment in data.get('anlagen'):
            print attachment.filename
            if "pdf" in attachment.filename:
                pdfstreams.append(attachment)

            elif "heic" in attachment.filename:
                from backports.tempfile import TemporaryDirectory
                with TemporaryDirectory() as tmpdirname:
                    ifn = '%s/%s' % (tmpdirname, attachment.filename)
                    ofn = '%s/%s.jpg' % (tmpdirname, attachment.filename)
                    import pdb
                    pdb.set_trace()

                    with open(ifn, 'wb') as heic:
                        heic.write(attachment.read())
                    subprocess.call(["heif-convert", ifn, ofn])
                    with open(ofn, 'rb') as f:
                        rgbimage = Image.open(f)
                        jpegimage = StringIO()
                        rgbimage.save(jpegimage, format="JPEG")
                        jpegimage.seek(0)
                        pdfimage = img2pdf.convert(jpegimage)
                        pdfstreams.append(StringIO(pdfimage))

            elif "jpeg" in attachment.filename or 'jpg' or 'png' in attachment.filename:
                pilimage = Image.open(attachment)
                if pilimage.mode == "RGBA":
                    rgbimage = pilimage.convert("RGB")
                else:
                    rgbimage = pilimage
                jpegimage = StringIO()
                rgbimage.save(jpegimage, format="JPEG")
                jpegimage.seek(0)
                pdfimage = img2pdf.convert(jpegimage)
                pdfstreams.append(StringIO(pdfimage))
        deckblatt = PdfFileReader(pdf_fn)
        fn_base = datetime.now().strftime('%Y%m%d_%H%M%S')
        for i, reader in enumerate(map(PdfFileReader, pdfstreams)):
            output_file = "%s/%s_%s.pdf" % (output_path, fn_base, i)
            logger.info('Write File %s' % output_file)
            writer = PdfFileMerger()
            with open(output_file, 'wb') as output:
                writer.append(deckblatt)
                writer.append(reader)
                writer.write(output)
                #for n in range(reader.getNumPages()):
                #    writer.addPage(reader.getPage(n))
                #    writer.write(output)
        self.flash(u'Vielen Dank, wir haben Ihre Dateien erhalten.')
        self.redirect(self.application_url())