Skip to main content

· One min read

國外有人將 Django / TurboGears 的選擇比做 Mac 跟 Linux 的選擇.

Mac OSX (Django) 美觀,從頭打造,有專職團隊維護, 有較好的宣傳與一致的文件.

Linux (TurboGears) 彈性, python 網頁開發相關模組的有機集合,可訂製程度高。文件散見各模組,皆為自由貢獻,品質不一.

雖然 MAC/LINUX (Django/TurboGears) 都是 UNIX (python) 核心,但是社群的偏向還是有差異的.

喜歡一體成形,具有很高一致性方案的人可能就會選擇 Django. 有高彈性需求的人可能會比較偏愛 TurboGears.

· 2 min read

身穿冒險服裝,身纏蟒蛇的漫畫少女 (萌) 會讓你聯想到什麼?

荒島求生,畢業旅行,還是純情房東俏房客這些讓人臉紅心跳的日系 AVG 遊戲?

再怎麼想,大概也不會想到我要介紹的卻是 Ren'py 這個免費的 AVG 冒險遊戲設計工具吧 :-D

Ren'py 透過主視窗就可以產生新專案,一個空白的專案就包含了一般 AVG 遊戲常見的選單,記錄,讀出等功能 (嗯嗯... 可惜沒看到看圖功能 XD) 或是將設計好的遊戲發佈成 Windows, Mac, Linux 等各平台的套件,非常方便將自己製作的遊戲與其他人分享.

Ren'py 的文件還不錯 (甚至還有互動遊戲版說明 :-D), 腳本的寫作與編譯也相當方便. 而且這個工具支援中文 (另外抓螢火飛的中文字型即可). 需要進階功能的話,可以使用 Python 語言撰寫加強程式,擴展性極佳:-D 如果想要設計一套 AVG 遊戲,Ren'py 實在是相當棒的選擇.

PS: 看看可愛的蟒蛇還咬著遊戲手把,有些人可能已經猜到,這個工具是基於 pygame 來開發的.

· One min read

聖誕節流行什麼東西呢?

卡哇伊的聖誕節佈景主題面版 + 業界最新的中文介面 Mlcrosoft Firefox 2007 瀏覽器應該不只能吸引一批批眼睛冒著小星星的女生吧 :-D

下載頁面於此。(2.0 繁體中文,6.1mb)

1. 中文版 Firefox 2.0 瀏覽器 2. 預裝聖誕版面

http://blog.pixnet.net/xdriftdoll/post/1202231

BTW, 截圖裡的網站是聖誕老人北極的家 , 點玩具工廠的圖示進去,還可以選要自己讀故事或聽人念故事喔:)

· One min read

拿到一個現成的資料庫,最快速的就是直接存取啦.

TurboGears 中除了預先定義 schema 外,也可以直接使用 SQLAlchemy 中的 SqlSoup 模組來直接存取資料庫.

之前我有寫過英文版的,今天 trace 一下 sqlsoup 後發現還有更簡單的方法:直接取用 metadata.

1. 修改 dev.cfg 中的 sqlalchemy.dburi , 指到對應的資料庫

2. 在 your project/model.py 中,寫下

from turbogears.database import metadata from sqlalchemy.ext.sqlsoup import SqlSoup

soup = SqlSoup(metadata)

3. 使用 shell 存取資料

$ tg-admin shell

poll = soup.poll.select() print poll

· 2 min read

Purpose

Have an exist database and want migrate to TurboGears? Or you've been using TurboGears SQLObject model and want to migrate to SQLAlchemy?

Solution

TurboGears newly support SQLAlchemy 0.2 module(>0.9a6), it provide a slick solution: SqlSoup !

What SqlSoup does?

SqlSoup inspects your database and reflects its contents to class, no model definitions are necessary!

What does that mean?

It means you only need to specify a uri for database, and call SqlSoup to do the rest.

What's the Benifits?

SqlSoup maps database tables to classes automatically. I'm not sure how efficient it is, but at least you can use SqlSoup by following ways:

  • To use existing Database design tools to design my database
  • To use SqlSoup in design phase, and code to SQLAlchemy class when the databse is settled down.
  • To painless migrate SQLObject generated database to SQLAlchemyTest Code

Try the test code, it is thin.

in model.py

1 from sqlalchemy.ext.sqlsoup import SqlSoup

2 uri = "sqlite://%(current_dir_uri)s/devdata.sqlite" 3 soup = SqlSoup(uri)

Explain

line 1 import SqlSoup from sqlalchemy module,

line 2 specify the uri link to the database (I believe it can be improved)

line 3 the real code calling SqlSoup connect to uri

line 4 and line 5 shows I call the table "poll" from database

if you can't execute is , maybe you should install sqlalchemy first

$ easy_install sqlalchemy

or try the TurboGears way:

1 from turbogears import config 2 from sqlalchemy.ext.sqlsoup import SqlSoup

3 uri = config.get('sqlalchemy.dburi') 4 soup = SqlSoup(uri) All you need to do is specify the dburi for sqlsoup.

Let's test what we got

poll = soup.poll.select() print poll

Reference

That's all you need in TurboGears. To get further usage , you can refer to Introducing SqlSoup

ps: Actually TurboGears has done nothing particularly to support SqlSoup, I just use it as other modules.