コード例 #1
0
 def __call__(self):
     self.adapter = getGalleryAdapter(self.context, self.request)
     self.displayer = getDisplayAdapter(self.adapter)
     self.settings = GallerySettings(
         self.context,
         interfaces=[self.adapter.schema, self.displayer.schema])
     return self.index()
コード例 #2
0
    def validate(self, album):
        settings = Data(self.view)

        if settings.gallery_type != 'picasa':
            return

        username = settings.picasa_username

        if empty(album):
            raise zope.schema.ValidationError(
                _(u"label_validate_picasa_ablum_empty",
                default=u"You must specify a picasa album."),
                True
            )
        if empty(username):
            # do not continue validation until they have a valid username
            return
        adapter = getGalleryAdapter(self.context, self.request,
                                    gallery_type=settings.gallery_type)
        found = adapter.get_album_name(name=album, user=username)

        if found is None:
            raise zope.schema.ValidationError(
                _(u"label_validate_picasa_find_album",
                default=u"Could not find album."),
                True
            )
コード例 #3
0
 def test_getDisplayAdapter(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'],
                                  TestRequest())
     alsoProvides(IAttributeAnnotatable, gadapter.request)
     displayer = getDisplayAdapter(gadapter)
     self.failUnless(displayer.name == 'slideshow')
     self.failUnless(gadapter.settings.display_type == 'slideshow')
コード例 #4
0
    def validate(self, photoset):
        super(FlickrSetValidator, self).validate(photoset)
        settings = Data(self.view)

        if settings.gallery_type != 'flickr':
            return

        if empty(photoset):
            raise zope.schema.ValidationError(
                _(u"label_validate_flickr_specify_user",
                    default=u"You must specify a flickr set to use."),
                True
            )

        try:
            adapter = getGalleryAdapter(self.context, self.request,
                                        settings.gallery_type)
            userid = adapter.get_flickr_user_id(settings.flickr_username)
            flickr_photosetid = adapter.get_flickr_photoset_id(photoset,
                                                               userid)

            if empty(flickr_photosetid):
                raise zope.schema.ValidationError(
                    _(u"label_validate_flickr_find_set",
                    default="Could not find flickr set."),
                    True
                )
        except:
            raise zope.schema.ValidationError(
                _(u"label_validate_flickr_find_set",
                default="Could not find flickr set."),
                True
            )
コード例 #5
0
    def validate(self, username):
        super(FlickrUsernameValidator, self).validate(username)

        settings = Data(self.view)
        if settings.gallery_type != 'flickr':
            return

        if empty(username):
            raise zope.schema.ValidationError(
                _(u"label_validate_flickr_specify_username",
                default=u"You must specify a username."),
                True
            )

        try:
            adapter = getGalleryAdapter(self.context, self.request,
                                        settings.gallery_type)
            flickr_userid = adapter.get_flickr_user_id(username)
            if empty(flickr_userid):
                raise zope.schema.ValidationError(
                    _(u"label_validate_flickr_user",
                    default=u"Could not find flickr user."),
                    True
                )
        except:
            raise zope.schema.ValidationError(_(u"label_validate_flickr_user",
                default=u"Could not find flickr user."),
                True
            )
コード例 #6
0
 def test_getGalleryAdapter_when_asking_for_non_existant_type(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'],
         self.request, gallery_type="foobar")
     displayer = getDisplayAdapter(gadapter)
     self.assertEquals(displayer.name, 'galleria')
     self.assertEquals(gadapter.settings.display_type, 'galleria')
     self.assertEquals(gadapter.name, 'basic')
     self.assertEquals(gadapter.settings.gallery_type, 'basic')
コード例 #7
0
 def test_getGalleryAdapter_when_asking_for_non_existant_type(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'],
         self.request, gallery_type="foobar")
     displayer = getDisplayAdapter(gadapter)
     self.assertEquals(displayer.name, 'galleria')
     self.assertEquals(gadapter.settings.display_type, 'galleria')
     self.assertEquals(gadapter.name, 'basic')
     self.assertEquals(gadapter.settings.gallery_type, 'basic')
コード例 #8
0
 def __call__(self):
     self.adapter = getGalleryAdapter(self.context, self.request)
     self.displayer = getDisplayAdapter(self.adapter)
     self.settings = GallerySettings(
         self.context,
         interfaces=[self.adapter.schema, self.displayer.schema]
     )
     return self.index()
コード例 #9
0
 def __init__(self, context, request):
     super(FlowView, self).__init__(context, request)
     self.settings = IFlowViewSettings(context)
     portal_state = getMultiAdapter((context, request),
                                     name='plone_portal_state')
     self.portal_url = portal_state.portal_url()
     self.staticFiles = "%s/%s" % (self.portal_url,
                                   self.staticFilesRelative)
     if hasTrueGallery:
         self.adapter = getGalleryAdapter(self.context, self.request)
コード例 #10
0
 def __init__(self, context, request):
     super(BaseDisplayType, self).__init__(context, request)
     self.adapter = getGalleryAdapter(context, request)
     self.context = self.gallery = self.adapter.gallery
     self.settings = GallerySettings(context,
                         interfaces=[self.adapter.schema, self.schema])
     portal_state = getMultiAdapter((context, request),
                                     name='plone_portal_state')
     self.portal_url = portal_state.portal_url()
     self.staticFiles = "%s/%s" % (self.portal_url,
                                   self.staticFilesRelative)
コード例 #11
0
 def test_getGalleryAdapter_when_asking_for_non_existant_type(self):
     gadapter = getGalleryAdapter(
         self.portal['test_gallery'],
         TestRequest(),
         gallery_type="foobar"
     )
     displayer = getDisplayAdapter(gadapter)
     self.failUnless(displayer.name == 'slideshow')
     self.failUnless(gadapter.settings.display_type == 'slideshow')
     self.failUnless(gadapter.name == 'basic')
     self.failUnless(gadapter.settings.gallery_type == 'basic')
コード例 #12
0
    def __call__(self):
        catalog = getToolByName(self.context, "portal_catalog")

        for gallery in catalog.searchResults(portal_type="Gallery"):
            gallery = gallery.getObject()

            self.request.response.write("cooking %s, located at %s\n" % (gallery.Title(), gallery.absolute_url()))

            adapter = getGalleryAdapter(gallery, self.request)
            adapter.cook()

        self.request.response.write("Timer is up!  Finished cooking!")
コード例 #13
0
 def test_size_map_for_default_sizes_with_size_upgrades(self):
     props = getUtility(IPropertiesTool)
     imaging_properties = props.get('imaging_properties', None)
     if imaging_properties:
         adapter = getGalleryAdapter(self.portal['test_gallery'],
                                     self.request)
         self.assertEquals(adapter.sizes['small']['width'], 320)
         self.assertEquals(adapter.sizes['small']['height'], 320)
         self.assertEquals(adapter.sizes['medium']['width'], 576)
         self.assertEquals(adapter.sizes['medium']['height'], 576)
         self.assertEquals(adapter.sizes['large']['width'], 768)
         self.assertEquals(adapter.sizes['large']['height'], 768)
コード例 #14
0
 def test_size_map_for_default_sizes_with_size_upgrades(self):
     props = getUtility(IPropertiesTool)
     imaging_properties = props.get('imaging_properties', None)
     if imaging_properties:
         adapter = getGalleryAdapter(self.portal['test_gallery'],
                                     self.request)
         self.assertEqual(adapter.sizes['small']['width'], 320)
         self.assertEqual(adapter.sizes['small']['height'], 320)
         self.assertEqual(adapter.sizes['medium']['width'], 576)
         self.assertEqual(adapter.sizes['medium']['height'], 576)
         self.assertEqual(adapter.sizes['large']['width'], 768)
         self.assertEqual(adapter.sizes['large']['height'], 768)
コード例 #15
0
 def __init__(self, context, request):
     super(BaseDisplayType, self).__init__(context, request)
     self.adapter = getGalleryAdapter(context, request)
     self.context = self.gallery = self.adapter.gallery
     self.settings = GallerySettings(
         context, interfaces=[self.adapter.schema, self.schema])
     portal_state = getMultiAdapter((context, request),
                                    name='plone_portal_state')
     self.portal_url = portal_state.portal_url()
     self.staticFiles = "%s/%s" % (self.portal_url,
                                   self.staticFilesRelative)
     self.typeStaticFiles = '%s/%s' % (self.portal_url,
                                       self.typeStaticFilesRelative)
コード例 #16
0
 def test_size_map_for_default_sizes_with_size_upgrades(self):
     props = getUtility(IPropertiesTool)
     imaging_properties = props.get('imaging_properties', None)
     if imaging_properties:
         request = TestRequest()
         alsoProvides(request, IAttributeAnnotatable)
         adapter = getGalleryAdapter(self.portal['test_gallery'], request)
         self.assertEquals(adapter.sizes['small']['width'], 320)
         self.assertEquals(adapter.sizes['small']['height'], 200)
         self.assertEquals(adapter.sizes['medium']['width'], 576)
         self.assertEquals(adapter.sizes['medium']['height'], 400)
         self.assertEquals(adapter.sizes['large']['width'], 768)
         self.assertEquals(adapter.sizes['large']['height'], 768)
コード例 #17
0
    def __call__(self):
        catalog = getToolByName(self.context, 'portal_catalog')

        for gallery in catalog.searchResults(portal_type="Gallery"):
            gallery = gallery.getObject()

            self.request.response.write(
                "cooking %s, located at %s\n" %
                (gallery.Title(), gallery.absolute_url()))

            adapter = getGalleryAdapter(gallery, self.request)
            adapter.cook()

        self.request.response.write("Timer is up!  Finished cooking!")
コード例 #18
0
    def get_image(self):
        catalog = getToolByName(self.context, 'portal_catalog')

        uid = self.request.get('portlet-gallery-uid', None)
        if not uid:
            return "bad request..."

        obj = catalog(UID=uid)[0].getObject()
        adapter = getGalleryAdapter(obj, self.request)
        portlet_adapter = PortletGalleryAdapter(adapter)
        image = portlet_adapter.image

        return str({
            'src': image['image_url'],
            'title': image['title'],
            'description': image['description'],
            'image-link': portlet_adapter.image_link(),
            'next-url': portlet_adapter.next_image_url_params(),
            'prev-url': portlet_adapter.prev_image_url_params()
        })
コード例 #19
0
    def get_image(self):
        catalog = getToolByName(self.context, 'portal_catalog')

        uid = self.request.get('portlet-gallery-uid', None)
        if not uid:
            return "bad request..."

        obj = catalog(UID=uid)[0].getObject()
        adapter = getGalleryAdapter(obj, self.request)
        portlet_adapter = PortletGalleryAdapter(adapter)
        image = portlet_adapter.image

        return str({
            'src': image['image_url'],
            'title': image['title'],
            'description': image['description'],
            'copyright': image['copyright'],
            'image-link': portlet_adapter.image_link(),
            'next-url': portlet_adapter.next_image_url_params(),
            'prev-url': portlet_adapter.prev_image_url_params()
        })
コード例 #20
0
    def get_image(self):
        catalog = getToolByName(self.context, "portal_catalog")

        uid = self.request.get("portlet-gallery-uid", None)
        if not uid:
            return "bad request..."

        obj = catalog(UID=uid)[0].getObject()
        adapter = getGalleryAdapter(obj, self.request)
        portlet_adapter = PortletGalleryAdapter(adapter)
        image = portlet_adapter.image

        return str(
            {
                "src": image["image_url"],
                "title": image["title"],
                "description": image["description"],
                "copyright": image["copyright"],
                "image-link": portlet_adapter.image_link(),
                "next-url": portlet_adapter.next_image_url_params(),
                "prev-url": portlet_adapter.prev_image_url_params(),
            }
        )
コード例 #21
0
 def test_getGalleryAdapter(self):
     adapter = getGalleryAdapter(self.portal['test_gallery'], self.request)
     self.assertEqual(adapter.name, "basic")
     self.assertEqual(adapter.settings.gallery_type, "basic")
コード例 #22
0
 def test_getDisplayAdapter(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'],
                                  TestRequest())
     displayer = getDisplayAdapter(gadapter)
     self.failUnless(displayer.name == 'slideshow')
     self.failUnless(gadapter.settings.display_type == 'slideshow')
コード例 #23
0
 def test_getGalleryAdapter(self):
     adapter = getGalleryAdapter(self.portal['test_gallery'], TestRequest())
     self.failUnless(adapter.name == "basic")
     self.failUnless(adapter.settings.gallery_type == "basic")
コード例 #24
0
 def test_getDisplayAdapter(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'],
                                  self.request)
     displayer = getDisplayAdapter(gadapter)
     self.assertEquals(displayer.name, 'galleria')
     self.assertEquals(gadapter.settings.display_type, 'galleria')
コード例 #25
0
 def test_getGalleryAdapter(self):
     adapter = getGalleryAdapter(self.portal['test_gallery'], self.request)
     self.assertEquals(adapter.name, "basic")
     self.assertEquals(adapter.settings.gallery_type, "basic")
コード例 #26
0
 def getAdaptedGallery(self, gallery):
     return getGalleryAdapter(gallery, self.request)
コード例 #27
0
 def __call__(self):
     adapter = getGalleryAdapter(self.context, self.request)
     adapter.cook()
     self.request.response.redirect(self.context.absolute_url())
コード例 #28
0
 def test_getDisplayAdapter(self):
     gadapter = getGalleryAdapter(self.portal['test_gallery'], self.request)
     displayer = getDisplayAdapter(gadapter)
     self.assertEqual(displayer.name, 'galleria')
     self.assertEqual(gadapter.settings.display_type, 'galleria')
コード例 #29
0
 def getAdaptedGallery(self, gallery):
     return getGalleryAdapter(gallery, self.request)
コード例 #30
0
 def __call__(self):
     adapter = getGalleryAdapter(self.context, self.request)
     adapter.cook()
     self.request.response.redirect(self.context.absolute_url())