upstream portal { server 127.0.0.1:5001; server 127.0.0.1:5002; server 127.0.0.1:5003; server 127.0.0.1:5004; server 127.0.0.1:5005; server 127.0.0.1:5006; server 127.0.0.1:5007; server 127.0.0.1:5008; }
值得注意的是,upstart 在 12.04 有個 bug,Supplementary groups not set for user jobs,這會導致上面的 setuid www-data 不如預期,例如 user www-data 的 supplementary group 有一個 groupabc,然後某檔案設定為 groupabc 可以寫,結果 upstart 跑起來以後是寫不進去的。 解法之一是改用 sudo -u www-data -E -- 來跑。14.04 就沒這問題了。
find(self, *args, **kwargs) :Parameters: - `spec` (optional): a SON object specifying elements which must be present for a document to be included in the result set bson.son class SON(__builtin__.dict) SON data. A subclass of dict that maintains ordering of keys and provides a few extra niceties for dealing with SON. SON objects can be converted to and from BSON. __init__(self, data=None, **kwargs)
所以若要保留順序,就要直接用 SON 物件來當 find 的參數。建立的方法跟
dict.items() 傳回來的東西一樣,是 “list of D’s (key, value) pairs, as
2-tuples”
1 2 3 4 5 6
>>> from bson import son >>> a = son.SON([('a', 1), ('b', 1), ('c', 1), ('d', 1)]) >>> a SON([('a', 1), ('b', 1), ('c', 1), ('d', 1)]) >>> a.to_dict() {'a': 1, 'c': 1, 'b': 1, 'd': 1}
WXR Parser 可用來分析
WordPress.com 匯出的 XML 檔案,是為了這次要搬出來然後用
Wintersmith 靜態產生 blog 頁面寫的,目前可以匯
出適合 Wintersmith 使用的目錄結構。不過因為設計上 parser 跟 backend 分
開,所以要擴充來產生其他格式也蠻簡單。
A simple WXR parser written in Python to parse the XML export from
WordPress and store the information it in in Python’s basic data
structures, i.e. dictionaries and lists. It also goes with a backend
to export it in Markdown syntax suitable for
Wintersmith. In its current form, it can
simplify the migration from WordPress to Wintersmith, but it’s easy to
be extended to export more formats.
It’s created because the author failed to find a simple one to use.