2009/07/23
いろいろな「最近の変更」を最適化する
by
jack
—
posted at
2009-07-23 12:25 PM
最近の変更で出したいもの、出したくないものがいろいろあります。
例えば画像をuploadしてもそれをいちいち出されてもこまる、とかそういうことです。
ファイルとドキュメントとブログエントリとリンクだけ出したいといっても、front-page は出したくないしrobot.txt もときどき変更するし、それを見てるのは、portlet-recent やらrecently_modifiedやらいろいろあるし、いわゆるフィード(RSS)もそのままだと画像やらなにやら全部でちゃうし・・・
ということで、getRecents というScript(Python) を書いてあちこちから参照させることにしました。
あちこちで、portal_catalog.searchResults を違うように呼んでたのでこのほうがよいだろうということで。
parametersは withfolder=0 が入っています。特定のフォルダのみ見せたり見せなかったりを制御したいという感じです。
recents = context.portal_catalog.searchResults(
portal_type=['File', 'Document','COREBlogEntry','Link'],
sort_on='modified',sort_order='reverse')[:30]
ret = []
for x in recents:
if '/robots.txt' in x.getPath(): continue
elif '/front-page' in x.getPath(): continue
elif (not withfolder) and ('/specialfolder/' in x.getPath()): continue
ret.append(x)
return ret
とりあえず想定通りになったので個人的には満足。もっといいやり方はあるんでしょうけど
- Category(s)
- Python/Zope/Plone
- The URL to Trackback this entry is:
- http://ns.jk.to/Nikki/moblog2009-07-23-12-35/tbping
- 栗本薫さん、お別れの会
- ¦
- Main
- ¦
- 天気雨と虹