コード例 #1
0
 def update(self):
     self.context = aq_inner(self.context)
     # is context a Periodical?
     self.is_periodical = IPeriodical.providedBy(self.context)
     # is context a News Article inside a Periodical?
     self.is_news_article = INITF.providedBy(self.context) and \
         IPeriodical.providedBy(self.context.__parent__)
コード例 #2
0
    def collection(self):
        context = None
        portal_state = getMultiAdapter((self.context, self.request),
                                       name=u'plone_portal_state')
        portal = portal_state.portal()

        if (IPloneSiteRoot.providedBy(self.context)
                or IATTopic.providedBy(self.context)):
            self.kind = 'all'
            collection = 'todas-las-noticias'
            context = portal

        if INITF.providedBy(self.context):
            self.kind = 'section'
            normalizer = getUtility(IIDNormalizer)
            collection = normalizer.normalize(self.context.section)
            context = portal.get('noticias', None)

        if not context:
            return None

        result = context.get(collection, None)

        if result is not None:
            sm = getSecurityManager()
            if not sm.checkPermission('View', result):
                result = None

        return result
コード例 #3
0
    def __iter__(self):
        for item in self.previous:

            path = item['_path']
            nitf = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(nitf):  # path does not exist or not a NITF
                yield item; continue

            path = item['_from']
            newsitem = self.context.unrestrictedTraverse(path, None)

            if not IATNewsItem.providedBy(newsitem):  # path does not exist or not a News Item
                yield item; continue

            # delete News Item and replace NITF UUID to assure link integrity
            id = newsitem.getId()
            uuid = newsitem.UID()
            folder = newsitem.aq_parent
            # FIXME: this seems to be trigering manage_beforeDelete in
            # Archetypes/Referenceable.py removing News Item object references
            # before we replace them with the new NITF news article object
            folder.manage_delObjects([id])
            folder.manage_renameObject(nitf.getId(), id)
            IMutableUUID(nitf).set(uuid)

            zope.event.notify(ObjectModifiedEvent(nitf))

            yield item
コード例 #4
0
    def __iter__(self):
        for item in self.previous:

            path = item['_path']
            nitf = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(nitf):  # path does not exist or not a NITF
                yield item
                continue

            path = item['_from']
            newsitem = self.context.unrestrictedTraverse(path, None)

            if not IATNewsItem.providedBy(
                    newsitem):  # path does not exist or not a News Item
                yield item
                continue

            # delete News Item and replace NITF UUID to assure link integrity
            id = newsitem.getId()
            uuid = newsitem.UID()
            folder = newsitem.aq_parent
            # FIXME: this seems to be trigering manage_beforeDelete in
            # Archetypes/Referenceable.py removing News Item object references
            # before we replace them with the new NITF news article object
            folder.manage_delObjects([id])
            folder.manage_renameObject(nitf.getId(), id)
            IMutableUUID(nitf).set(uuid)

            zope.event.notify(ObjectModifiedEvent(nitf))

            yield item
コード例 #5
0
    def __iter__(self):
        for item in self.previous:

            if not isinstance(item['image'], Image):  # no image or not an Image
                yield item; continue

            path = item['_path']
            container = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(container):  # path does not exist or not a NITF
                yield item; continue

            try:
                _createObjectByType('Image', container, 'image', title='image')
            except:
                # could not create image
                yield item; continue

            image = container['image']
            image.setDescription(item['imageCaption'])
            image.setImage(item['image'])

            zope.event.notify(ObjectCreatedEvent(image))

            yield item
コード例 #6
0
    def __iter__(self):
        for item in self.previous:

            if not isinstance(item['image'],
                              Image):  # no image or not an Image
                yield item
                continue

            path = item['_path']
            container = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(
                    container):  # path does not exist or not a NITF
                yield item
                continue

            try:
                _createObjectByType('Image', container, 'image', title='image')
            except:
                # could not create image
                yield item
                continue

            image = container['image']
            image.setDescription(item['imageCaption'])
            image.setImage(item['image'])

            zope.event.notify(ObjectCreatedEvent(image))

            yield item
コード例 #7
0
    def collection(self):
        context = None
        portal_state = getMultiAdapter((self.context, self.request),
                                       name=u'plone_portal_state')
        portal = portal_state.portal()
        
        if (IPloneSiteRoot.providedBy(self.context) or
            IATTopic.providedBy(self.context)):
            self.kind = 'all'
            collection = 'todas-las-noticias'
            context = portal

        if INITF.providedBy(self.context):
            self.kind = 'section'
            normalizer = getUtility(IIDNormalizer)
            collection = normalizer.normalize(self.context.section)
            context = portal.get('noticias', None)

        if not context:
            return None

        result = context.get(collection, None)

        if result is not None:
            sm = getSecurityManager()
            if not sm.checkPermission('View', result):
                result = None

        return result
コード例 #8
0
    def __iter__(self):
        for item in self.previous:

            path = item['_path']
            obj = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(obj):  # path does not exist or not a NITF
                yield item
                continue

            # Content
            obj.title = item['title']
            obj.subtitle = ''
            obj.description = item['description']
            #obj.abstract = item['description']
            obj.byline = ''
            obj.text = RichTextValue(item['text'], 'text/html',
                                     'text/x-html-safe')
            obj.genre = genre_default_value(None)
            obj.section = section_default_value(None)
            obj.urgency = urgency_default_value(None)

            # Categorization
            obj.setSubject(item['subject'])
            # TODO: reimplement when relatedItems issue is solved
            #obj.relatedItems = item['relatedItems']
            obj.location = item['location']
            obj.setLanguage(item['language'])

            # Dates
            obj.setEffectiveDate(item['effectiveDate'])
            obj.setExpirationDate(item['expirationDate'])

            # Ownership
            obj.setCreators(item['creators'])
            obj.setContributors(item['contributors'])
            obj.setRights(item['rights'])

            zope.event.notify(ObjectModifiedEvent(obj))

            yield item
コード例 #9
0
    def __iter__(self):
        for item in self.previous:

            path = item['_path']
            obj = self.context.unrestrictedTraverse(path, None)

            if not INITF.providedBy(obj):  # path does not exist or not a NITF
                yield item; continue

            # Content
            obj.title = item['title']
            obj.subtitle = ''
            obj.description = item['description']
            #obj.abstract = item['description']
            obj.byline = ''
            obj.text = RichTextValue(item['text'], 'text/html', 'text/x-html-safe')
            obj.kind = kind_default_value(None)
            obj.section = section_default_value(None)
            obj.urgency = urgency_default_value(None)

            # Categorization
            obj.setSubject(item['subject'])
            # TODO: reimplement when relatedItems issue is solved
            #obj.relatedItems = item['relatedItems']
            obj.location = item['location']
            obj.setLanguage(item['language'])

            # Dates
            obj.setEffectiveDate(item['effectiveDate'])
            obj.setExpirationDate(item['expirationDate'])

            # Ownership
            obj.setCreators(item['creators'])
            obj.setContributors(item['contributors'])
            obj.setRights(item['rights'])

            zope.event.notify(ObjectModifiedEvent(obj))

            yield item
コード例 #10
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='collective.nitf.content')
     factory = fti.factory
     new_object = createObject(factory)
     self.failUnless(INITF.providedBy(new_object))
コード例 #11
0
 def test_adding(self):
     self.folder.invokeFactory('collective.nitf.content', 'n1')
     n1 = self.folder['n1']
     self.failUnless(INITF.providedBy(n1))
コード例 #12
0
 def test_adding(self):
     self.assertTrue(INITF.providedBy(self.n1))
コード例 #13
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name="collective.nitf.content")
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(INITF.providedBy(new_object))