Skip to main content

· 2 min read

現在不少 web 服務 (amazon, del.icio.us, flickr) 都提供有 API 或 RSS, 共通之處是這些 web 服務都使用了 XML 標記語言,解析起來類似. 但是問題來了,這些種類 web service 的標籤格式雖然都遵照 XML 標記語言規範了, 但各 web service 的格式還是都稍有不同,programmer 要使用這些 web 服務的時候,每要支援一個服務就得重寫一個 Adapter.

unAPI是一個新提出來的抽象 API, 希望透過統一介面操作這些 API, 讓 programmer 得以更輕鬆用同一個介面做出能線上分享書籍介紹,參照圖片,剪貼網頁的平台.(拿 windows 軟體來比喻的話就像是 Microsoft OneNote 那樣的功能) programmer 開發的速度加快了,使用者也更容易得到更好的體驗 (或是更奇怪的體驗?).

雖然之前已經有不少 web 2.0 網站打著可以將許多 web service 或是將 feed, blog post "燒" 在一起來用來看, 但是被 "綁" 在特定平台上的感覺總是不夠自在. 因此我感覺 unAPI 相當具有成功的機會.

unAPI 離我們有點遠,覺得太抽象?還有screencast可以參考喔.

· 2 min read

I wonder to know the reason why people here choose TurboGears? I'd like to share mine.

1. Python Battery Included With TurboGears I can apply >5000 python modules on my web application natually. "Battery Included" facilitate me focusing on my major job to getting things done.

ex: Wiki20: "docutils" module is helpful for wiki syntax TurboBlog: PIL "ImageFonts" module is helpful for blog anti-spam stuff.

2. Flexibility from Prototpying to Merchandising In small app or prototyping stage, I just want to see something work first. TurboGears give me the flexibility to do most of my web programming by only edit controller.py. I can adopt Template, ORM, AJAX.... latter if I really need them. I don't want to take care of "framework" stuff such as admin controll, templating, url mapping, or database reference at first (which Django did).

ex: I've written some short tutorials to teach myself turbogears' features without template. (in chinese). http://gasolinfred.pbwiki.com/%5BTurboGearsInMinutes

3. Easy to start, Plenty for Learn Model Designer , CatWalk, help me leave from the first headache of database backend web programming. http://trac.turbogears.org/turbogears/wiki/QuickPrototyping

And after learning how "controllers" and "expose" works (I think its the minimum set of turbogears core), I can construct a workable web app and enhance it during my learning curve.

· 2 min read

http://manatlan.online.fr/hypy.php

今天剛寫完 "Making a Time Tracker in TurboGears", 重新來看 Hypy 這個小樣板程式.

在 TurboGears 中可以這樣使用 hypy

0  from turbogears import controllers
0 from turbogears import expose
0 import hypy
1 class Root(controllers.RootController):
2 @expose()
3 def hypyd(self):
4 template="""
5 @html:
7 @head:
8 @title:
9 ${title}
10 @body:
11 Hello TurboGears!
12 """
13 context = (title = "Hello hypy")
14 web = hypy.parse(template,context)
15 return web

原本 template 字串樣版用 html 寫的話簡直就是糊在一起,但是改用 Hypy 寫之後整體就清楚多了 Hypy 的語法跟 kid 的基本語法接近。又能乾淨地在程式碼中內嵌網頁,很適合當作一個取代字串樣版介於 controller 與 template 的中間形式.

只是這樣是否就又要使用者多學一種語言,反而增加學習難度?這就是相當見仁見智的事了.

· 2 min read

2006/30/7 Since may people may come from 42, I suggest you to download the full instruction at TurboGears Trac, you'll see full instruction to make it.

This article is motivate by the framework comparison screencast performed by Sean Kelly. I found this screencast from TurboGears group. the screencast compare J2EE , Rails ,Zope ,TurboGears ,and Django. TurboGears did fairly well. but Sean Kelly wasn't using the latest version(~0.9) during his tests.Thus I try to re-imlement the demo by using bunch of exciting new features (Model Designer, CatWalk, DataController...) introduced in the latest TurboGears version.

Origin version in ScreenCast

The screencast implement page like this, there is a add only interface, no editing.

And it cost 2 python source files 49 lines of code, 2 page of templates, 53 lines of code, not a hundred lines of code.

Re-Implement version with latest svn(#885)

Its time catch up with Sean Kelly's demo in latest TurboGears version. The re-implement with latest Turbogears svn like this. TurboGears > 0.9 provide autogenerate Editor(Catwalk) in Admin Panel(Toolbox)

We can get another running mode editor(much usefull for real app) with DataController by several lines of code.

the re-implement version cost 2 python source files (now Turbogears config file is in python) 6 lines of code, 0 page of templates, not a ten lines of code. The re-implement version also include a full-functional database-relation editor.

Turbogears automatically generate pages for you both in admin and practice perspective. In Turbogears you can customize DataController and other widgets' looking and feel to fit your layout style.