当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.IContentListingObject类代码示例

本文整理汇总了Python中plone.app.contentlisting.interfaces.IContentListingObject的典型用法代码示例。如果您正苦于以下问题:Python IContentListingObject类的具体用法?Python IContentListingObject怎么用?Python IContentListingObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IContentListingObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_feed_order

    def test_feed_order(self):
        article = self.create_content('collective.cart.core.Article')
        instance = IContentListingObject(article)
        self.assertEqual(instance.feed_order(), u'Edit')

        instance._realobject.feed_order = 3
        self.assertEqual(instance.feed_order(), 3)
开发者ID:taito,项目名称:slt.content,代码行数:7,代码来源:test_ArticleContentListingObject.py

示例2: test_klass

    def test_klass(self):
        article = self.create_content('collective.cart.core.Article')
        instance = IContentListingObject(article)
        self.assertEqual(instance.klass(), 'normal')

        instance.discount_available = mock.Mock()
        self.assertEqual(instance.klass(), 'discount')
开发者ID:SultanInUfa,项目名称:collective.cart.shopping,代码行数:7,代码来源:test_ArticleContentListingObject.py

示例3: TestOpengeverContentListingWithEnabledBumblebee

class TestOpengeverContentListingWithEnabledBumblebee(FunctionalTestCase):

    layer = OPENGEVER_FUNCTIONAL_BUMBLEBEE_LAYER

    def setUp(self):
        super(TestOpengeverContentListingWithEnabledBumblebee, self).setUp()

        document = create(Builder('document')
                          .with_dummy_content())
        self.obj = IContentListingObject(obj2brain(document))

    def test_documents_are_bumblebeeable(self):
        self.assertTrue(self.obj.is_bumblebeeable())

    def test_dossiers_are_not_bumblebeeable(self):
        dossier = create(Builder('dossier'))
        listing = IContentListingObject(obj2brain(dossier))

        self.assertFalse(listing.is_bumblebeeable())

    def test_get_preview_image_url(self):
        self.assertIsNotNone(self.obj.get_preview_image_url())

    def test_get_overlay_title(self):
        self.assertEqual(u'Testdokum\xe4nt', self.obj.get_overlay_title())

    def test_get_overlay_url(self):
        self.assertEqual('http://nohost/plone/document-1/@@bumblebee-overlay-listing',
                         self.obj.get_overlay_url())
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: __call__

    def __call__(self):
        field_list = self.request.form.get('items.fl', '').strip()
        if field_list:
            field_list = field_list.split(',')
        else:
            field_list = ['@type', 'title', 'description', 'review_state']

        obj = IContentListingObject(self.context)
        summary = json_compatible({
            '@id': obj.getURL(),
        })

        for field in field_list:
            accessor = FIELD_ACCESSORS.get(field)
            if accessor is None:
                continue
            if isinstance(accessor, str):
                value = getattr(obj, accessor, None)
                if callable(value):
                    value = value()
            else:
                value = accessor(obj)
            summary[field] = json_compatible(value)

        if ('title' in summary and
                ITranslatedTitleSupport.providedBy(self.context)):
            # Update title to contain translated title in negotiated language
            attr = 'title_{}'.format(get_preferred_language_code())
            summary['title'] = getattr(self.context, attr)

        return summary
开发者ID:lukasgraf,项目名称:opengever.core,代码行数:31,代码来源:summary.py

示例5: test_discount_available

    def test_discount_available(self):
        article = self.create_content('collective.cart.core.Article')
        instance = IContentListingObject(article)
        self.assertFalse(instance.discount_available())

        instance.adapter = mock.Mock()
        instance.adapter.discount_available.ruturn_value = True
        self.assertTrue(instance.discount_available())
开发者ID:SultanInUfa,项目名称:collective.cart.shopping,代码行数:8,代码来源:test_ArticleContentListingObject.py

示例6: __call__

 def __call__(self):
     obj = IContentListingObject(self.context)
     summary = json_compatible({
         '@id': obj.getURL(),
         '@type': obj.PortalType(),
         'title': obj.Title(),
         'description': obj.Description()
     })
     return summary
开发者ID:lccruz,项目名称:plone.restapi,代码行数:9,代码来源:summary.py

示例7: create_list_item

def create_list_item(item, fields):
    obj = IContentListingObject(item)
    data = {'@id': obj.getURL()}
    for field in fields:
        if field not in FIELDS:
            continue
        accessor = FIELDS[field][1]
        if isinstance(accessor, str):
            value = getattr(obj, accessor, None)
            if callable(value):
                value = value()
        else:
            value = accessor(obj)
        data[field] = json_compatible(value)
    return data
开发者ID:4teamwork,项目名称:opengever.core,代码行数:15,代码来源:listing.py

示例8: _get_scaled_img

 def _get_scaled_img(self, item, size):
     request = getRequest()
     if ICatalogBrain.providedBy(item) or IContentListingObject.providedBy(item):
         obj = item.getObject()
     else:
         obj = item
     info = {}
     if hasattr(obj, "image"):
         scales = getMultiAdapter((obj, request), name="images")
         if size == "small":
             scale = scales.scale("image", width=300, height=300)
         if size == "medium":
             scale = scales.scale("image", width=600, height=600)
         if size == "large":
             scale = scales.scale("image", width=900, height=900)
         else:
             scale = scales.scale("image", width=1200, height=1200)
         if scale is not None:
             info["url"] = scale.url
             info["width"] = scale.width
             info["height"] = scale.height
         else:
             info["url"] = IMG
             info["width"] = "1px"
             info["height"] = "1px"
     else:
         info["url"] = IMG
         info["width"] = "1px"
         info["height"] = "1px"
     return info
开发者ID:ade25,项目名称:ade25.contacts,代码行数:30,代码来源:imagetool.py

示例9: walk

        def walk(items, result, parent):
            for item in items:
                collection = []
                if COLLECTION and IContentListingObject.providedBy(item):
                    item = item.getObject()
                elif IATTopic.providedBy(item):
                    collection = item.queryCatalog(b_size=100, full_objects=True)
                elif COLLECTION and ICollection.providedBy(item):
                    collection = item.getQuery()

                if collection:
                    result[item.title_or_id()] = []
                    walk(collection, result, item.title_or_id())
                else:
                    # add only published items
                    if wft.getInfoFor(item, "review_state") != "published":
                        IStatusMessage(self.request).\
                        add(_(u'Some of the items in your list are private. '
                               'They were not included in the wizard - '
                               'MailChimp supports only published content.'),
                            type='error')
                        continue

                    result[parent].append({'uid': IUUID(item),
                                           'title': item.title_or_id()})
            return result
开发者ID:RedTurtle,项目名称:redturtle.monkey,代码行数:26,代码来源:campaign.py

示例10: _get_scaled_img

 def _get_scaled_img(self, item, size):
     request = getRequest()
     if (
                 ICatalogBrain.providedBy(item) or
                 IContentListingObject.providedBy(item)
     ):
         obj = item.getObject()
     else:
         obj = item
     info = {}
     if hasattr(obj, 'image'):
         scales = getMultiAdapter((obj, request), name='images')
         if size == 'small':
             scale = scales.scale('image', width=300, height=300)
         if size == 'medium':
             scale = scales.scale('image', width=600, height=600)
         if size == 'large':
             scale = scales.scale('image', width=900, height=900)
         else:
             scale = scales.scale('image', width=1200, height=1200)
         if scale is not None:
             info['url'] = scale.url
             info['width'] = scale.width
             info['height'] = scale.height
         else:
             info['url'] = IMG
             info['width'] = '1px'
             info['height'] = '1px'
     else:
         info['url'] = IMG
         info['width'] = '1px'
         info['height'] = '1px'
     return info
开发者ID:a25kk,项目名称:asg,代码行数:33,代码来源:imagetool.py

示例11: setUp

 def setUp(self):
     super(TestIndividualRealContentItems, self).setUp()
     self.portal = self.layer["portal"]
     self.folder = self.portal["test-folder"]
     self.folder.invokeFactory("Document", "mypage", title="My Page", description="blah")
     self.item = IContentListingObject(self.folder.mypage)
     self.realitem = self.folder.mypage
开发者ID:plone,项目名称:plone.app.contentlisting,代码行数:7,代码来源:test_integration_unit.py

示例12: construct_icalendar

def construct_icalendar(context, events):
    """Returns an icalendar.Calendar object.

    :param context: A content object, which is used for calendar details like
                    Title and Description. Usually a container, collection or
                    the event itself.

    :param events: The list of event objects, which are included in this
                   calendar.
    """
    cal = icalendar.Calendar()
    cal.add('prodid', PRODID)
    cal.add('version', VERSION)

    cal_tz = default_timezone(context)
    if cal_tz:
        cal.add('x-wr-timezone', cal_tz)

    tzmap = {}
    if not hasattr(events, '__getslice__'):  # LazyMap doesn't have __iter__
        events = [events]
    for event in events:
        if ICatalogBrain.providedBy(event) or\
                IContentListingObject.providedBy(event):
            event = event.getObject()
        acc = IEventAccessor(event)
        tz = acc.timezone
        # TODO: the standard wants each recurrence to have a valid timezone
        # definition. sounds decent, but not realizable.
        if not acc.whole_day:  # whole day events are exported as dates without
                               # timezone information
            tzmap = add_to_zones_map(tzmap, tz, acc.start)
            tzmap = add_to_zones_map(tzmap, tz, acc.end)
        cal.add_component(IICalendarEventComponent(event).to_ical())

    for (tzid, transitions) in tzmap.items():
        cal_tz = icalendar.Timezone()
        cal_tz.add('tzid', tzid)
        cal_tz.add('x-lic-location', tzid)

        for (transition, tzinfo) in transitions.items():

            if tzinfo['dst']:
                cal_tz_sub = icalendar.TimezoneDaylight()
            else:
                cal_tz_sub = icalendar.TimezoneStandard()

            cal_tz_sub.add('tzname', tzinfo['name'])
            cal_tz_sub.add('dtstart', transition)
            cal_tz_sub.add('tzoffsetfrom', tzinfo['tzoffsetfrom'])
            cal_tz_sub.add('tzoffsetto', tzinfo['tzoffsetto'])
            # TODO: add rrule
            # tzi.add('rrule',
            #         {'freq': 'yearly', 'bymonth': 10, 'byday': '-1su'})
            cal_tz.add_component(cal_tz_sub)
        cal.add_component(cal_tz)

    return cal
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:58,代码来源:exporter.py

示例13: TestOpengeverContentListingWithDisabledBumblebee

class TestOpengeverContentListingWithDisabledBumblebee(FunctionalTestCase):

    def setUp(self):
        super(TestOpengeverContentListingWithDisabledBumblebee, self).setUp()

        document = create(Builder('document'))
        self.obj = IContentListingObject(obj2brain(document))

    def test_documents_are_not_bumblebeeable(self):
        self.assertFalse(self.obj.is_bumblebeeable())

    def test_get_css_classes(self):
        self.assertEqual('state-document-state-draft',
                         self.obj.get_css_classes())

    def test_get_preview_image_url(self):
        self.assertIsNone(self.obj.get_preview_image_url())

    def test_get_overlay_title(self):
        self.assertIsNone(self.obj.get_overlay_title())

    def test_get_overlay_url(self):
        self.assertIsNone(self.obj.get_overlay_url())
开发者ID:,项目名称:,代码行数:23,代码来源:

示例14: get_type

    def get_type(self, item):
        """differ the object typ and return the type as string"""

        if isinstance(item, dict):
            return 'dict'
        elif ICatalogBrain.providedBy(item):
            return 'brain'
        elif IContentListingObject.providedBy(item):
            return 'contentlistingobject'
        elif IFieldWidget.providedBy(item):
            return 'widget'
        elif isinstance(item, Task):
            return 'globalindex_task'
        else:
            raise ValueError("Unknown item type: {!r}".format(item))
开发者ID:4teamwork,项目名称:opengever.core,代码行数:15,代码来源:boxes_view.py

示例15: get_state_css

 def get_state_css(self, itemob=None):
     itemob = itemob or self.context
     if ICatalogBrain.providedBy(itemob) or IContentListingObject.providedBy(itemob):
         itemob = itemob.getObject()
     css_map = {
         None: 'success',
         'QUEUED': 'warning',
         'RUNNING': 'warning',
         'COMPLETED': 'success',
         'FAILED': 'error',
         'REMOVED': 'removed',
         'FINISHED': 'info'
     }
     # check job_state and return either success, error or block
     job_state = IExperimentJobTracker(itemob).state
     return css_map.get(job_state, 'info')
开发者ID:,项目名称:,代码行数:16,代码来源:


注:本文中的plone.app.contentlisting.interfaces.IContentListingObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。