2012年11月22日 星期四

[nginx] facebook canvas連nginx時出現 HTTP 405 Not allowed


Facebook是用POST去抓canvas/iFrame,
但是nginx處理static file預設不給POST,
workaround如下:

location / {
    error_page 405 =200 $uri;
    root /var/www/html/yoursite.com;
}

比較好的處理如下:
http://invalidlogic.com/2011/04/12/serving-static-content-via-post-from-nginx/

2012年11月19日 星期一

[SQLAlchemy] 不用primary key的table

table沒有設pirmary key會出現這個錯誤:

sqlalchemy.exc.ArgumentError: Mapper Mapper|FooTable|foo_table could not assemble any primary key columns for mapped table 'foo_table'

mapper要設:

"primary_key":(col1, col2)}

2012年11月15日 星期四

[Mac][git] git diff in Mac


如果有裝GitX的話,設定選"Enable Terminal Usage",然後

git diff | gitx


或是XCode的FileMerge/opendiff也很好用,

git difftool -t opendiff -y

可以寫到.gitconfig的

[alias]
   df = difftool -t opendiff -y

2012年11月14日 星期三

[SQLAlchemy] foreign key constraint 問題


以不delete, SET NULL為例:

1. database level
db.Column(db.Integer, ForeignKey(db.ForeignKey('category.id',ondelete='SET NULL')))

2. pythen level
db.relationship(passive_deletes=True)

2012年11月10日 星期六