當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。