Personal tools
You are here: Home にっき いろいろな「最近の変更」を最適化する
Document Actions

いろいろな「最近の変更」を最適化する

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

とりあえず想定通りになったので個人的には満足。もっといいやり方はあるんでしょうけど

The URL to Trackback this entry is:
http://ns.jk.to/Nikki/moblog2009-07-23-12-35/tbping
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
« February 2012 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
Categories
仮想化 (18)
Python/Zope/Plone (9)
にっき (1292)
鉄道 (2)
水泳 (9)
ローカーボ (18)
 
そちらのOSの時刻なので 正確性はあなた次第
 
こういう意味のないの好き
 
本をお勧め中
 
CDもお勧め中
のだめカンタービレ ベスト100
ドラマの演奏とは違います。でもこの感じでこの価格ならアリかと
 
消耗品や家電
 
よく使うサイト
社名ロゴ88×631
 
ぐぐってみる
 
誰が使うんだろう
 

Powered by Plone