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


Python IContentListingObject.providedBy方法代码示例

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


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

示例1: _get_scaled_img

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 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,代码行数:32,代码来源:imagetool.py

示例2: _get_scaled_img

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 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,代码行数:35,代码来源:imagetool.py

示例3: walk

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
        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,代码行数:28,代码来源:campaign.py

示例4: construct_icalendar

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
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,代码行数:60,代码来源:exporter.py

示例5: get_type

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
    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,代码行数:17,代码来源:boxes_view.py

示例6: get_state_css

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 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:,项目名称:,代码行数:18,代码来源:

示例7: _get_scaled_img

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 def _get_scaled_img(self, item, image_field, size):
     request = getRequest()
     if (
         ICatalogBrain.providedBy(item) or
         IContentListingObject.providedBy(item)
     ):
         obj = item.getObject()
     else:
         obj = item
     info = {}
     if hasattr(obj, image_field):
         scales = getMultiAdapter((obj, request), name='images')
         if size == 'lgip':
             stored_image = getattr(obj, image_field)
             scale = image_scale.scaleImage(
                 stored_image.data,
                 width=stored_image.getImageSize()[0],
                 height=stored_image.getImageSize()[1],
                 direction='keep',
                 quality=10
             )
         if size == 'small':
             scale = scales.scale(image_field, width=300, height=300)
         if size == 'medium':
             scale = scales.scale(image_field, width=600, height=600)
         if size == 'large':
             scale = scales.scale(image_field, width=900, height=900)
         else:
             scale = scales.scale(image_field, 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,项目名称:anv,代码行数:44,代码来源:imagetool.py

示例8: test_contentlisting_iteration

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 def test_contentlisting_iteration(self):
     self.assertTrue(IContentListingObject.providedBy(
         [item for item in self.contentlisting][0]))
开发者ID:4teamwork,项目名称:ftw.solr,代码行数:5,代码来源:test_contentlisting.py

示例9: test_contentlisting_getitem

# 需要导入模块: from plone.app.contentlisting.interfaces import IContentListingObject [as 别名]
# 或者: from plone.app.contentlisting.interfaces.IContentListingObject import providedBy [as 别名]
 def test_contentlisting_getitem(self):
     self.assertTrue(
         IContentListingObject.providedBy(self.contentlisting[0]))
开发者ID:4teamwork,项目名称:ftw.solr,代码行数:5,代码来源:test_contentlisting.py


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