getRefsByKind.py

getRefsByKind.py — Python Source, 1Kb

ファイルのコンテンツ

## Script (Python) "getRefsByKind"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=kind='media'
##title=Show archive
##
# !!!
# Handling for Content-type, File:swf,mp3,mpeg4 or something
#
from Products.CMFCore.utils import getToolByName

INTERFACE = 'Products.COREBlog2.interfaces.IInlineObject.IInlineObject'

itool = getToolByName(context, 'portal_interface')

# Portal types for media
media_types = ('Image','ATVideo','Amazon Item',
               'File:video/quicktime','File:video/x-ms-wmv')

ret_l = []

# Get referenced objects
for obj in context.getRefs('relatesTo'):
    try:
        ct = ''
        try:
            ct = ':' + obj.getContentType()
        except:
            pass
        if obj.portal_type in media_types or \
           obj.portal_type + ct in media_types or \
           itool.objectImplements(obj, INTERFACE):
            if kind == 'media':
                ret_l.append(obj)
        elif kind != 'media':
            ret_l.append(obj)
    except:
        pass

return ret_l
このBlogについて
Plone, Zope, Pythonなどのトピックについてのメモです。
カテゴリ
Plone (98)
Plone Products (23)
COREBlog2 (31)
COREBlog1 (29)
ReadingCOREBlog (7)
Zope (66)
Turbogears (18)
Django (12)
Python (25)
Linux (30)
Nagosui (11)
Design (33)
Misc (48)
moblog (5)
最近のエントリ
Glossy Horizontal Menuを使う nyusuke 2008年11月17日
第3回Python東海終了 nyusuke 2008年11月17日
Universalじゃない件 nyusuke 2008年11月15日
CorruptedErrorが出たので直す nyusuke 2008年11月14日
最近のコメント
Re:WebデザイナーのためのDjangoはじめの一歩 nyusuke 2007年06月01日
Re:WebデザイナーのためのDjangoはじめの一歩 pateo 2007年05月31日
Re:東海Python Workshop 01終了 nyusuke 2007年05月31日
Re:東海Python Workshop 01終了 kfuruhata 2007年05月30日