一、Django
Django
Django is oriented to programmers who deal mainly with content. The makers of Django are from the newspaper business. They say that they were often asked to implement certain features on their web site with tight deadlines. So they wrote their own framework. Django does not re-use many components. Even their way to access databases (the so called object-relational mapper) is home-made.
If you have similar requirements as Django's makers you will find that it is an excellent framework. But it is not meant to have its components replaced easily in case you don't like them. Their templating language is not very "pythonic" - it is a language of its own although an easy one. A nice feature is their admin frontend - it will create HTML forms for you to easily manage the data in your database. And it comes with a nifty way to map URLs to certain functions in your application based on regular expressions.
AJAX is basically possible with Django but not very comfortable. They have a web server built in but they suggest you run Django applications on an Apache with mod_python. One thing that can truly be said about Django: they have good marketing. Django is well documented, has a large community and there is even a book currently written. All in all Django is a "don't worry - be happy" framework that is tightly integrated and which will help you get things done quickly if you don't care too much which components it uses and don't expect all parts to look perfectly pythonic. It's a bit magical.
Django面向主要處理內容的程式員。Django的建立者們源自報紙商務服務。他們反映他們經常被要求短時間內在他們的網站上實現特定的特性。所以他們編寫了他們自己的架構。Django並沒有重用許多組件,即使他們串連資料庫的方式(所謂的對象關係映射器)是自製的。
如果你有如同Django建立者類似的需求,你會發現這是個傑出的架構。但這不意味著萬一你不喜歡他們便可以輕易替代他們。他們的範本語言並不十分的類似python——它有它自己的語言即使非常簡單。一個非常好的特性是他們的管理後台——它會為你產生HTML格式來使你輕易管理你資料庫中的資料。同時它與生俱來一種俏皮的方式在你基於Regex的應用程式中來定位URL到特定的功能。
AJAX在Django中基本支援但用起來並不十分舒服。它內建的web伺服器但建議你用mod_python在Apache上運行應用程式。關於Django有一件事情是事實:它有很好的市場前景。Django有十分好的文檔,有非常大的社區同時還有一本書正在編著。總的來說Django是一個“無需擔心,高興點”的架構,它緊密地整合同時如果你不對它使用了哪些組件過分在意同時不奢求所有的部分都完美地pythonic,它協助你快速地完成任務。它是有些魔幻的。
小結:Django優點:文檔支援完善,社區支援強大,admin管理後台很強大,文法魔幻。
缺點:對AJAX支援不夠,組件較難替換。
二、TurboGears
Turbogears makes use of existing components. Their web server runs on CherryPy, their HTML templates come from Kid, they access databases through SQLObject and even include a good way to write interactive AJAX applications through the use of a Javascript library called Mochikit that is tightly integrated.
They make it easier than Django to replace certain components in case you don't like them. For example you can throw away SQLObject and use SQLAlchemy instead; although many parts of Turbogears still lack full support for SQLAlchemy. Turbogears's URL mapping scheme is less explicit. You can't tell what is supposed to happen for certain URLs. Instead a program of the same name as the first part of the URL is called. So the URLs the user sees may appear less nifty.
A nicer feature is their set of web-based utilities. Among them is their WidgetBrowser to browse the library of supplied form elements - or Catwalk - a database administration frontend similar to that which Django provides. Turbogears is well documented and has a large community, too. All in all Turbogears has nifty features like its widget library or a good set of utility functions that make life easier.
Its documentation is somewhat incomplete and contains recipes and examples rather than a nice reference. A move to SQLAlchemy has been publicly announced but many features currently only work well with SQLObject. Turbogears may be a nice choice for programmers who are scared by the magic of Django and like it a bit more explicit.
TurboGears由已經存在的組件構成。它的web伺服器運行在CherryPy上,它的HTML模板來源於Kid,它通過sqlObject串連資料庫甚至包含了一個很好的方式通過使用一個緊密整合的叫Mochikit的javascript庫編寫互動的AJAX應用。
相對Django,如果你不喜歡幾個組件,TurboGears更容易替代它們。例如,你可以摒棄SQLObject而使用SQLAlchemy;即使TurboGears許多部分缺乏對SQLObject的完整支援。TurboGears的URL定位結構相對更不明確。對特定URL你並不清楚應將要發生什麼。相反與URL第一部分相同名稱的程式被喚起。所以使用者看到的URL會顯得不如Django俏皮。
一個相對更好的特性是它基於網路的實用功能集合。一個瀏支援檔案的外掛程式瀏覽器——或者Catwalk——一個資料庫後端管理,類似於Django提供的。TurboGears有很好的文檔同時也有很大的社區。總的來說TurboGears有極好的特性比如它的外掛程式庫或一個很好的實用功能集合,使你的工作更簡單。
它的文檔有些不完全包含秘訣和案例代碼而不是很好的引用。向SQLAlchemy的遷移已經向公眾宣布但當前許多特性只與SQLObject完全相容。TurboGears是對那些對Django的魔幻有些恐懼喜歡明確的程式員來說是個很好的選擇。
小結:TurboGears優點:文檔支援較完善,社區支援強大,組件可替換,文法明確,很好的外掛程式庫,很好的網路實用功能集合。
缺點:文檔不完全,對某些替代組件未提供完全支援,URL定位不明確。
三、Pylons
Pylons isn't exactly new but appears to have a smaller community than Django or Turbogears. That does not mean it's technically worse than other frameworks. It is unique in that it is more minimal and flexible than other frameworks. Basically you need to learn the basics of the components it uses. Next you need to understand how these components are controlled from within a Pylons application. So Pylons is the glue between the components with an additional powerful package called "Webhelpers" that aids in many areas from AJAX to RSS feed creation.
Pylons' flexibility means that you can exchange the components very easily. You don't like SQLAlchemy? Use SQLObjects. You read that Myghty is superseded by Mako? Use Mako. Pylons may not always hold your hand but it will try to make it easy to use different components than what Pylons uses by default. And you will likely be happy with what Pylons offers by default. The components are carefully chosen by looking at what other web frameworks do wrong.
The documentation for Pylons is still lacking and there is no "Pylons Handbook" yet. It seems like some fans of Pylons tried it because they generally liked the idea of web frameworks but were frustrated with Django or Turbogears. Some say that Pylons is the Ruby-on-Rails written in Python.
Pylons確切說並不新但相對Django和TurboGears有社區小。這並不意味著技術上它比其它架構糟糕。它十分特殊,體現在它相對其它架構更加輕量化更加靈活。從根本上來說你需要瞭解它使用組件的基礎。下一步你需要理解這些組件在一個Pylons應用中如何被控制。所以Pylons是通過一個附加的叫“webhelpers”能在許多領域把AJAX向RSS Feed建立提供協助的非常給力的包在這些組件起膠水的作用。
Pylons的靈活性意味著你可以輕鬆地替換掉組件。你不喜歡SQLAlchemy?使用SQLObjects就好了。你瞭解到Myghty被Mako替代了?那就用Mako。Pylons也許並不會時刻與你肩並肩但它嘗試著讓使用不同組件比使用預設組件更加容易。同時,你可能你會喜歡Pylons提供的預設組件。通過觀察別的web架構做錯的地方Pylons精心挑選了組件。
針對Pylons的文檔仍然十分缺乏。還沒有一個Pylons手冊。一些Pylons的追隨者嘗試過寫它因為喜歡這個web架構的主意但被Django和TurboGears疑惑了。一些人說Pylons是用Python寫的Ruby on Rails。
小結:Pylons優點:更加輕量化,更加靈活,可替換並支援完善的組件,預設組件吸收了其它web架構的經驗。像Ruby on Rails。
缺點:文檔十分缺乏,社區支援不夠。需要瞭解各組件的基礎知識和如何被控制。
我的話
本人自認為英語學得可以,但Python剛剛入門,對這些web架構也是只有一個初步的瞭解,談不上任何實戰經驗,對於一些專業詞彙翻譯不夠準確,:-)也算是增加些瞭解。