The Django Book

Appendix A: Case Studies

kgCx0v <a href=”http://kkxpgdgfvjkg.com/“>kkxpgdgfvjkg</a>, [url=http://avagejjbypul.com/]avagejjbypul[/url], [link=http://wvwhoqkhcjio.com/]wvwhoqkhcjio[/link], http://qcnpwntqfiyg.com/

To help answer questions about how Django works in the real world, we spoke with (well, emailed) a handful of people who have complete, deployed Django sites under their belts. Most of this appendix is in their words, which have been lightly edited for clarity.

涓轰簡鍥炵瓟 Django 鍦ㄧ幇瀹炰腑绌剁珶琛ㄧ幇濡備綍锛屾垜浠窡寰堝浜轰氦璋堣繃锛堝寘鎷 email 鏂瑰紡锛夛紝杩欎簺浜洪兘宸茬粡鍦ㄤ粬浠殑鍦扮洏涓婂畬鎴愶紝閮ㄧ讲杩 Django 绔欑偣銆傛湰闄勫綍涓昏鏄粬浠殑瑷杈烇紝褰撶劧涓轰簡琛ㄨ堪鏇存竻鏅颁篃鐣ヤ綔浜嗕竴浜涚紪杈戙

Cast of Characters

浜虹墿鍒楄〃

Lets meet our cast and their projects.

XaWSFu <a href=”http://acczogakanxw.com/“>acczogakanxw</a>, [url=http://bozlbsvhsrwv.com/]bozlbsvhsrwv[/url], [link=http://gbqhxgjzfqsf.com/]gbqhxgjzfqsf[/link], http://txbknegujyrf.com/

Ned Batchelder is the lead engineer at Tabblo.com. Tabblo started life as a storytelling tool built around photo sharing, but it was recently bought by Hewlett-Packard for more wide-reaching purposes:

QvtHj7 <a href=”http://sxzfqcbebnmd.com/“>sxzfqcbebnmd</a>, [url=http://caotjsvdfleu.com/]caotjsvdfleu[/url], [link=http://oscksxneivux.com/]oscksxneivux[/link], http://rjcvailnfjak.com/

HP saw real value in our style of web development, and in the way we bridged the virtual and physical worlds. They acquired us so that we could bring that technology to other sites on the Web. Tabblo.com is still a great storytelling site, but now we are also working to componentize and rehost the most interesting pieces of our technology.

鎴戜滑鐨剋eb寮鍙戦鏍硷紝浠ュ強鎴戜滑杩炴帴铏氭嫙涓栫晫涓庣墿鐞嗕笘鐣岀殑鏂瑰紡锛岃HP鐪嬪埌浜嗙湡姝g殑浠峰硷紝浠栦滑鏀惰喘浜嗘垜浠紝璁╂垜浠彲浠ュ皢鎶鏈甫缁檞eb涓婄殑鍏朵粬绔欑偣銆 Tabblo.com渚濈劧鏄竴涓紵澶х殑鏁呬簨璁茶堪绔欑偣锛屽悓鏃讹紝鎴戜滑涔熷繖浜庡皢鎴戜滑鏈鏈夎叮鐨勬妧鏈ā鍧楀寲骞舵洿鎹富鏈恒

Johannes Beigel is a lead developer at Brainbot Technologies AG. Brainbots major public-facing Django site is http://pediapress.com/, where you can order printed versions of Wikipedia articles. Johanness team is currently working on an enterprise-class knowledge-management program known as Brainfiler.

Johannes Beigel 鏄疊rainbot Technologies AG鐨勫紑鍙戜富绠★紝Brainbots 闈㈠悜鍏紬鐨勪富瑕丏jango绔欑偣鏄 http://pediapress.com/, 浣犲彲浠ヤ粠閭i噷璁㈣喘缁村熀鐧剧鐨勬墦鍗扮増銆侸ohannes鐨勫洟闃熺洰鍓嶆鑷村姏浜庝竴涓О涓築rainfiler鐨勪紒涓氱骇鐭ヨ瘑绠$悊杞欢銆

Johannes tells us that Brainfiler

Johannes 鍛婅瘔鎴戜滑锛孊rainfiler

[] is a software solution to manage, search for, categorize, and share information from distributed information sources. Its built for enterprise usage for both the intranet and the Internet and is highly scalable and customizable. The development of the core concepts and components started in 2001. Just recently we have redesigned/reimplemented the application server and Web front-end, which is [now] based on Django.

tp3sYj <a href=”http://ijlsmchjrqqb.com/“>ijlsmchjrqqb</a>, [url=http://wwolzjfopsxb.com/]wwolzjfopsxb[/url], [link=http://ehluzfideanl.com/]ehluzfideanl[/link], http://ujxvaefmdiml.com/

David Cramer is the lead developer at Curse, Inc. He develops Curse.com, a gaming site devoted to massively multiplayer online games like World of Warcraft, Ultima Online, and others.

David Cramer 鏄疌urse鐨勫紑鍙戜富绠★紝浠栧紑鍙戜簡Curse.com,涓涓嚧鍔涗簬澶у瀷澶氫汉鍦ㄧ嚎娓告垙(渚嬪榄斿吔涓栫晫锛岀綉缁滃垱涓栫邯绛)鐨勭珯鐐广

Curse.com is one of the largest deployed Django sites on the Internet:

Curse.com鏄簰鑱旂綉涓婃渶澶х殑鐢―jango寤烘垚鐨勭珯鐐逛箣涓:

We do roughly 60-90 million page views in an average month, and we have peaked at over 130 million page views [in a month] using Django. We are a very dynamic and user-centric Web site for online gamers, specifically massively multiplayer games, and are one of the largest Web sites globally for World of Warcraft. Our Web site was established in early 2005, and since late 2006 we have been expanding our reach into games beyond World of Warcraft.

鎴戜滑姣忔湀澶ф鏈夊叚鍗冧竾鍒颁節鍗冧竾鐨勯〉闈㈣闂噺锛屼娇鐢―jango锛屾垜浠〉闈㈣闂噺鐨勫嘲鍊艰揪鍒拌繃涓涓湀涓浜夸笁鍗冧竾銆傛垜浠槸楂樺害鍔ㄦ佺殑浠ョ敤鎴蜂负涓績鐨勭珯鐐癸紝鎴戜滑涓哄湪绾挎父鎴忕帺瀹舵彁渚涙湇鍔★紝鐗瑰埆鏄ぇ鍨嬪浜哄湪绾跨綉缁滄父鎴忋傛垜浠槸鍏ㄧ悆鏈澶х殑榄斿吔涓栫晫绔欑偣涔嬩竴锛屾垜浠寤轰簬2005骞达紝鍦2006骞达紝鎴戜滑鎵╁睍鍒伴瓟鍏戒笘鐣屼互澶栫殑鍏朵粬娓告垙銆

Christian Hammond is a senior engineer at VMware (a leading developer of virtualization software). Hes also the lead developer of Review Board (http://www.review-board.org/), a Web-based code review system. Review Board began life as an internal VMware project, but is now open source:

Christian Hammond VMware (铏氭嫙鍖栬蒋浠剁殑棰嗗ご缇)鐨勯珮绾у伐绋嬪笀锛屽悓鏃朵粬涔熸槸Review Board(http://www.review-board.org/)鐨勫紑鍙戜富绠★紝Review Board鏄竴涓熀浜巜eb鐨勪唬鐮佽蛋鏌ョ郴缁燂紝瀹冭捣婧愪簬VMware鐨勪竴涓唴閮ㄩ」鐩紝鐜板湪鎴愪簡涓涓紑婧愰」鐩:

In late 2006, David Trowbridge and I were discussing the process we used at VMware for handling code reviews. Before people committed code to the source repository, they were supposed to send out a diff of the change to a mailing list and get it reviewed. It was all handled over email, and as such, it became hard to keep track of reviews requiring your attention. We began to discuss potential solutions for this problem.

2006骞村簳锛孌avid Trowbridge鍜屾垜璁ㄨ浜嗗湪VMware浣跨敤鐨勪唬鐮佽蛋鏌ユ祦绋嬶紝鍦ㄥ皢浠g爜鎻愪氦鍒版簮浠g爜浠撳簱涔嬪墠锛岀▼搴忓憳瑕佸皢鏀瑰姩鐨勯儴鍒嗙敤閭欢鍙戝嚭鏉ヨ鍏朵粬浜哄闃呫傚湪杩欎釜鍩轰簬閭欢鐨勬祦绋嬩腑锛屾兂璺熻釜鏌愪釜鎰熷叴瓒g殑浠g爜璧版煡灏辨瘮杈冨洶闅俱傚洜姝わ紝鎴戜滑寮濮嬭璁鸿繖涓棶棰樼殑瑙e喅鏂规銆

Rather than writing down my ideas, I put them into code. Before long, Review Board was born. Review Board helps developers, contributors, and reviewers to keep track of the code thats out for review and to better communicate with each other. Rather than vaguely referencing some part of the code in an email, the reviewer is able to comment directly on the code. The code, along with the comments, will then appear in the review, giving the developer enough context to work with to quickly make the necessary changes.

鎴戝苟娌℃湁鎶婃兂娉曞啓鍑烘潵锛岃屾槸鐩存帴寮濮嬬紪鐮併備笉涔咃紝Review Board璇炵敓浜嗭紝瀹冨彲浠ュ府鍔╁紑鍙戜汉鍛樸佷唬鐮佸闃呰呭強鐩稿叧璐d换浜烘柟渚垮湴璺熻釜浠g爜璧版煡涓庢洿濂界殑娌熼氥備娇鐢ㄨ呭彲浠ョ洿鎺ュ湪浠g爜涓婂仛璇勬敞锛岃屼笉鏄儚鍘熸潵閭f牱鍦ㄩ偖浠朵腑鐢ㄦ枃瀛楁ā绯婄殑鎸囦唬鏌愰儴鍒嗕唬鐮併備唬鐮佷笌璇勬敞涓璧峰睍鐜板湪绯荤粺涓紝寮鍙戣呭彲浠ユ牴鎹繖浜涜瘎娉ㄦ柟渚垮湴瀵逛唬鐮佸仛鍑轰慨鏀广

Review Board grew quickly at VMware. Much faster than expected, actually. Within a few short weeks, we had ten teams using Review Board. However, this project is not internal to VMware. It was decided day one that this should be open source and be made available for any company or project to use.

鍦╒Mware锛孯eview Board鐨勮敁寤跺揩寰楄秴涔庢兂璞★紝鍦ㄧ煭鐭嚑鍛ㄥ唴锛屽凡缁忔湁鍗佹潵涓洟闃熶娇鐢ㄥ畠浜嗐傜幇鍦紝杩欎釜椤圭洰宸茬粡涓嶅啀灞闄愪簬VMware鍐呴儴浜嗭紝鎴戜滑甯屾湜鏈変竴澶╁畠鍙互璧板悜寮婧愶紝璁╂洿澶氱殑鍏徃涓庨」鐩娇鐢ㄥ畠銆

We made an open source announcement and put a site together, which is available at http://www.review-board.org/. The response to our public announcement was as impressive as our internal VMware announcement. Before long, our demo server reached over 600 users, and people began to contribute back to the project.

A0KWvQ <a href=”http://qllnukhkitqa.com/“>qllnukhkitqa</a>, [url=http://gexrhzhjvsab.com/]gexrhzhjvsab[/url], [link=http://kvpuwdrwoxgo.com/]kvpuwdrwoxgo[/link], http://rxkqpzjawlgr.com/

Review Board isnt the only code review tool on the market, but it is the first we have seen that is open source and has the extensive feature set weve worked to build into it. We hope this will in time benefit many open source and commercial projects.

wimLHQ <a href=”http://xgclqztduggh.com/“>xgclqztduggh</a>, [url=http://mpirlevloyjq.com/]mpirlevloyjq[/url], [link=http://irrgjspblhth.com/]irrgjspblhth[/link], http://bkeaotspsavm.com/

Why Django?

涓轰粈涔堥夋嫨Django?

We asked each developer why he decided to use Django, what other options were considered, and how the decision to use Django was ultimately made.

鎴戜滑璇㈤棶姣忎竴涓紑鍙戜汉鍛橈紝涓轰粈楹戒粬鍐冲畾鐢―jango锛岀┒绔熸湁浠涔堝叾浠栫殑閫夋嫨鑰冭檻锛屼互鍙婂浣曟渶缁堝喅瀹氫娇鐢╠jango銆.

Ned Batchelder :

Ned Batchelder瑾:

Before I joined Tabblo, Antonio Rodriguez (Tabblos founder/CTO) did an evaluation of Rails and Django, and found that both provided a great quick-out-of-the-blocks rapid development environment. In comparing the two, he found that Django had a greater technical depth that would make it easier to build a robust, scalable site. Also, Djangos Python foundation meant that wed have all the richness of the Python ecosystem to support our work. This has definitely been proven out as weve built Tabblo.

鍦ㄦ垜鍔犲叆 Tabblo 涔嬪墠, Antonio Rodriguez (Tabblos 鐨勫垱寤鸿呬笌 CTO) 瀵 Rails 鍜 Django 鍋氫簡涓祴璇, 鍙戠幇涓よ呴兘鍙互鎻愪緵闈炲父楂樻晥鐨勫揩閫熸瀯寤虹幆澧冦傚湪涓よ呯殑瀵规瘮涓紝浠栧彂鐜帮紝Django 鏇存湁鎶鏈惈閲忥紝鍙互鏇村鏄撶殑鏋勫缓寮哄.鐨勩佸彲鎵╁睍鐨勭珯鐐广傚彟澶栵紝Python瀹屽杽鐨勭敓鎬佺郴缁熶娇寰桪jango鍏锋湁寮烘湁鍔涚殑绀惧尯鏀寔銆俆obblo鐨勫紑鍙戝厖鍒嗚瘉鏄庝簡浠ヤ笂瑙傜偣銆

Johannes Beigel :

Johannes Beigel瑾:

As we have been coding in Python for many years now, and quickly started using the Twisted framework, Nevow was the most natural solution for our Web application stuff. But we soon realized that despite the perfect Twisted integration many things were getting a little cumbersome and got in the way of our agile development process.

鎴戜滑浣跨敤Python缂栫爜宸茬粡寰堝骞翠簡锛屼笉涔呮垜浠紑濮嬩娇鐢═wisted妗嗘灦锛寃eb鏂归潰鑷劧灏变娇鐢ㄤ簡Nevow. 鐒惰屽緢蹇紝鎴戜滑鍙戠幇灏界Twisted鎻愪緵浜嗗畬缇庣殑闆嗘垚锛屽緢澶氫笢瑗胯繕鏄細鐣ユ樉绗ㄩ噸锛屽畠缁欐垜浠伒娲荤殑寮鍙戞祦绋嬮犳垚浜嗛樆纰嶃

After some Internet research it quickly became clear that Django was the most promising Web development framework for our requirements.

杩涜杩囦竴浜涘唴閮ㄨ璁轰箣鍚庯紝寰堟槑鏄撅紝Django鏄鍚堟垜浠渶姹傜殑鏈鐞嗘兂鐨剋eb妗嗘灦銆

The trigger that led us to Django was its template syntax, but we soon appreciated all the other features that are included, and so Django was pretty much a fast-selling item.

鎴戜滑杞悜Django鐨勬渶鍒濆姩鏈烘槸瀹冪殑妯℃澘璇硶锛屼絾寰堝揩鎴戜滑灏卞彂鐜癉jango涓殑鍏朵粬鐗规т篃闈炲父鏈夌敤锛孌jango涓鏃剁倷鎵嬪彲鐑

After doing a few years of parallel development and deployment (Nevow is still in use for some projects on customer sites), we came to the conclusion that Django is a lot less cumbersome, results in code that is much better to maintain, and is more fun to work with.

鍦ㄥ仛浜嗗嚑骞村苟琛屽紑鍙戜笌閮ㄧ讲宸ヤ綔鍚庯紙鍦ㄤ竴浜涘鎴风珯鐐圭殑椤圭洰涓璑evow渚濈劧鍦ㄤ娇鐢級锛屾垜浠緱鍑轰簡杩欐牱鐨勭粨璁猴細Djiango鏇磋交閲忋佹洿鐏垫椿锛屽啓鍑虹殑浠g爜鏇村鏄撶淮鎶わ紝涔熸洿鏈夎叮銆

David Cramer :

David Cramer 瑾:

I heard about Django in the summer of 2006, about the time we were getting ready to do an overhaul of Curse, and we did some research on it. We were all very impressed at what it could do, and where it could save time for us. We talked it over, decided on Django, and began writing the third revision to the Web site almost immediately.

鎴戝湪2006骞村澶╁惉璇翠簡Django锛岄偅鏃舵垜浠鍦ㄥ繖浜庝竴涓瘮杈冨ぇ鐨勯噸鏋勩傜爺绌朵簡涓涓婦jango涔嬪悗锛屽畠缁欐垜浠暀涓嬩簡寰堟繁鐨勫嵃璞★紝瀹冩彁渚涘緢澶氬姛鑳斤紝鍙互鑺傜渷鎴戜滑鐨勬椂闂达紝鎴戜滑鍟嗛噺鐫锛屽喅瀹氬氨鐢―jango銆傞┈涓婏紝鎴戜滑灏卞紑濮嬬紪鍐欑涓夌増鐨勪唬鐮佷簡銆

Christian Hammond :

Christian Hammond瑾:

I had toyed around with Django on a couple of small projects and had been very impressed with it. Its based on Python, which I had become a big fan of, and it made it easy not only to develop Web sites and Web apps, but also to keep them organized and maintainable. This was always tricky in PHP and Perl. Based on past experiences, going with Django was a no-brainer.

鎴戝湪鍑犱釜灏忕殑椤圭洰涓皾璇曚娇鐢ㄤ簡Django锛屽畠缁欐垜鐨勫嵃璞″緢娣憋紝瀹冩槸鍩轰簬Python鐨勶紝鎴戠幇鍦ㄥ凡缁忔垚浜嗕竴涓狿ython鐨勭埍濂借呫侱jango涓嶄粎浣垮緱缂栧啓缃戠珯鎴栬匴eb搴旂敤寰堝鏄擄紝鑰屼笖瀹冭繕鍙互淇濇寔浠g爜鐨勫彲缁存姢鎬э紝閫氬父杩欏湪php鎴栬卲erl涓槸姣旇緝闅惧仛鍒扮殑銆傛牴鎹繖浜涚粡楠岋紝鎴戜笉鍋囨濈储鐨勯夋嫨Django銆

Getting Started

璧锋

Since Djangos a relatively new tool, there arent that many experienced Django developers out there. We asked our panel how they got their team up to speed on Django and for any tips they wanted to share with new Django developers.

鐢变簬Django杩樻槸涓涓瘮杈冩柊鐨勫伐鍏凤紝鏈夌粡楠岀殑Django寮鍙戣呰繕涓嶆槸澶锛岃鎴戜滑鐪嬬湅杩欎簺鍏堣鑰呬滑鏄庝箞寮濮嬩娇鐢―jango锛屼互鍙婁粬浠湁鍝簺缁忛獙鍙互鍒嗕韩缁橠jango鐨勬柊鎵嬨

Johannes Beigel :

Johannes Beigel瑾亾:

After coding mostly in C++ and Perl, we switched to Python and continued using C++ for the computationally intensive code.

鎴戜滑涓鐩村湪鍐檆++涓巔erl绋嬪簭锛屽垏鎹㈠埌python涔嬪悗锛屾垜浠緷鐒剁敤c++鏉ュ疄鐜颁竴浜涜绠楀瘑闆嗗瀷鐨勯儴鍒嗐

[We learned Django by] working through the tutorial, browsing the documentation to get an idea of whats possible (its easy to miss many features by just doing the tutorial), and trying to understand the basic concepts behind middleware, request objects, database models, template tags, custom filters, forms, authorization, localization Then [we could] take a deeper look at those topics when [we] actually needed them.

鎴戜滑鏄繖鏍峰涔燚jango鐨勶細鐓х潃鏁欑▼鍋氱粌涔狅紝闃呰鏂囨。浜嗚В瀹冮兘鑳藉仛浠涔堬紙鍙窡鐫鏁欑▼鍋氬鏄撴紡鎺夊緢澶氱壒鎬э級锛屽姫鍔涘幓鐞嗚В杩欎簺缁勪欢鑳屽悗鐨勫熀鏈蹇碉紝濡俶iddleware,request objects, database models, template tags, custom filters, forms,authorization, localization銆傚湪鐪熸闇瑕佺殑鏃跺欙紝鎴戜滑浼氬幓娣卞叆鐮旂┒杩欎簺涓婚銆

David Cramer :

David Cramer璜囧埌:

The Web site documentation is great. Stick with it.

瀹樼綉涓婄殑鏂囨。寰堜笉閿欙紝鏃跺埢鍏虫敞瀹冦

Christian Hammond :

Christian Hammond璜囧埌:

David and I both had prior experience with Django, though it was limited. We had learned a lot through our development of Review Board. I would advise new users to read through the well-written Django documentation and [the book youre reading now], both of which have been invaluable to us.

David鍜屾垜涔嬪墠瀵笵jango閮芥湁浣跨敤缁忛獙锛屽嵆浣块偅鏃惰繕鏄彈闄愮殑銆傛垜浠粠璇勮鐗堢殑寮鍙戜腑瀛﹀埌浜嗗緢澶氫笢瑗裤傛垜浼氬缓璁柊鎵嬪幓闃呰绮惧績缂栧啓鐨凞jango鏂囨。鍜屼綘姝e湪闃呰鐨勮繖鏈功锛屽畠浠浜庢垜浠兘鏄棤浠风殑銆

We didnt have to bribe Christian to get that quote promise!

鎴戜滑涓嶆槸闈炲緱鍚戝熀鐫e緬琛岃纯鏉ュ緱鍒板紩鐢ㄧ殑鏉冨姏銆

Porting Existing Code

qVPiIP <a href=”http://yttqrkvgoiin.com/“>yttqrkvgoiin</a>, [url=http://kxzaeecicatj.com/]kxzaeecicatj[/url], [link=http://hmnrgnjhuqmo.com/]hmnrgnjhuqmo[/link], http://ldqzqxdbeoxc.com/

Although Review Board and Tabblo were ground-up development, the other sites were ported from existing code. We were interested in hearing how that process went.

铏界劧 Review Board 鍜 Tabblo 鏄櫧鎵嬭捣瀹跺紑鍙戣捣鏉ョ殑锛屽叾浠栫殑缃戠珯鍗存槸浠庣幇鏈変唬鐮佺Щ妞嶈屾潵銆傛垜浠劅鍏磋叮鐨勬槸浜嗚В杩欎釜绉绘鐨勮繃绋嬨

Johannes Beigel :

Johannes Beigel :

We started to port the site from Nevow, but we soon realized that wed like to change so many conceptual things (both in the UI part and in the application server part) that we started from scratch and used the former code merely as a reference.

鎴戜滑寮濮嬬殑鏃跺欎粠 Nevow 绉绘绔欑偣锛屼絾寰堝揩鎰忚瘑鍒板繀椤绘洿鏂板お澶氭蹇垫т簨鐗╋紙鍖呮嫭鍦 UI 閮ㄥ垎鍜屽簲鐢ㄦ湇鍔″櫒閮ㄥ垎锛夛紝鍥犳鎴戜滑杞屼粠闆跺紑濮嬶紝鑰屽皢涔嬪墠鐨勪唬鐮佷富瑕佺敤浣滃弬鑰冦

David Cramer :

David Cramer :

The previous site was written in PHP. Going from PHP to Python was great programmatically. The only downfall is you have to be a lot more careful with memory management [since Django processes stay around a lot longer than PHP processes (which are single cycle)].

涔嬪墠鐨勭珯鐐圭敤 PHP 缂栧啓鑰屾垚銆備粠 PHP 鍒 Python 鐨勭Щ妞嶅伐浣滈潪甯哥▼寮忓寲銆傚敮涓鐨勯棶棰樻槸浣犲繀椤婚潪甯稿皬蹇冨唴瀛樼鐞嗛棶棰樸愮敱浜 Django 杩涚▼杩愯鏃堕棿姣 PHP 杩涚▼锛堝崟寰幆锛夎闀垮緱澶氥傘

How Did It Go?

鐜扮姸

Now for the million-dollar question: How did Django treat you? We were especially interested in hearing where Django fell down its important to know where your tools are weak before you run into roadblocks.

涓嬮潰鏄竴涓叧閿棶棰橈細Django 鏄浣曞寰呬綘鐨勶紵鎴戜滑瀵瑰惉瑙 Django 鍑洪敊鐗瑰埆鎰熷叴瓒b斺斿湪鎾炲崡澧 涔嬪墠 灏辩煡閬撴墍鐢ㄥ伐鍏风殑寮辩偣鎵鍦ㄦ槸寰堥噸瑕佺殑銆

Ned Batchelder :

Ned Batchelder :

Django has really enabled us to experiment with our Web sites functionality. Both as a startup heat-seeking customers and businesses, and now as a part of HP working with a number of partners, weve had to be very nimble when it comes to adapting the software to new demands. The separation of functionality into models, views, and controllers has given us modularity so we can appropriately choose where to extend and modify. The underlying Python environment gives us the opportunity to make use of existing libraries to solve problems without reinventing the wheel. PIL, PDFlib, ZSI, JSmin, and BeautifulSoup are just a handful of the libraries weve pulled in to do some heavy lifting for us.

Django鐪熸浣挎垜浠兘澶熸弧瓒虫垜浠渶瑕佺殑缃戠粶鏋舵瀯 浣滀负鐑偣鐢ㄦ埛,浼佷笟 ,鐜板湪浣滀负hp鐨勫悎浣滀紮浼, 鎴戜滑浣跨敤闈炲父鐏垫椿鐨勬柟寮,浣胯蒋浠堕傚簲鏂扮殑闇姹. 鍒嗙鍔熻兘,妯″瀷,瑙嗗浘鍜屾帶鍒跺櫒,MVC妯″潡鍖,璁╂垜浠彲浠ユ柟渚跨殑鎵╁睍鍜岀淮鎶 鑰屽熀浜巔ython鐨勮瑷缁欎簡鐢ㄦ埛鏈轰細浣跨敤澶ч噺鐨勫凡鏈夊簱鏉ヨВ鍐 闂涓嶅繀閲嶅閫犺疆瀛 鎰熻阿 PIL, PDFlib, ZSI, JSmin,

System Message: ERROR/3 (<string>, line 585)

Unexpected indentation.

and BeautifulSoup

The most difficult part of our Django use has been the relationship of memory objects to database objects, in a few ways. First, Djangos ORM does not ensure that two references to the same database record are the same Python object, so you can get into situations where two parts of the code are both trying to modify the same record, and one of the copies is stale. Second, the Django development model encourages you to base your data objects on database objects. Weve found over time more and more uses for data objects that are not tied to the database, and weve had to migrate away from assuming that data is stored in the database.

鍐呭瓨瀵硅薄鍜屾暟鎹簱瀵硅薄涔嬮棿鐨勫叧绯绘槸锛 in a few ways锛孌jango 鐨勪娇鐢ㄤ腑鏈闅剧殑閮ㄥ垎銆傜涓锛孌jango鐨凮RM骞朵笉鑳戒繚璇侊紝瀵瑰悓涓涓暟鎹簱璁板綍鐨勪袱姝ゅ紩鐢ㄦ槸鏉ヨ嚜鍚屼竴涓狿ython瀵硅薄锛屾墍浠ヤ綘鍙兘浼氶亣鍒拌繖绉嶆儏鍐碉細浠g爜涓殑涓や釜閮ㄥ垎瑕佷慨鏀瑰悓涓鏁版嵁搴撹褰曪紝鑰屽叾涓竴涓殑鏁版嵁鏄棫鐨勩傜浜岋紝Django 寮鍙戞ā鍨嬮紦鍔变綘鍦ㄦ暟鎹簱瀵硅薄鐨勫熀纭涓婂缓绔嬩綘鐨勬暟鎹璞°傛垜浠細鍙戠幇鏇撮绻佺殑瓒呮椂锛屾洿澶氬湴浣跨敤閭d簺娌℃湁瀵瑰簲鍒版暟鎹簱鐨勬暟鎹璞★紝鎴戜滑鍙ソ涓嶅啀鍋囧畾鏁版嵁鏄繚瀛樺湪鏁版嵁搴撻噷鐨勩

For a large, long-lived code base, it definitely makes sense to spend time up front anticipating the ways your data will be stored and accessed, and building some infrastructure to support those ways.

瀵逛簬涓涓湁澶ч噺鐨勩佺敓鍛藉懆鏈熷緢闀跨殑浠g爜搴擄紝鑺辨椂闂存潵anticipating浣犵殑鏁版嵁瀛樺偍鍜岃闂槸鏈夐潪甯告剰涔夌殑銆俷d building some infrastructure to support those ways.

Weve also added our own database migration facility so that developers dont have to apply SQL patches to keep their database schemas current. Developers who change the schema write a Python function to update the database, and these are applied automatically when the server is started.

鎴戜滑涔熷鍔犱簡鏁版嵁搴撹縼绉诲姛鑳斤紝杩欐牱寮鍙戜汉鍛樺氨涓嶅繀閫氳繃SQL鑴氭湰鏉ユ洿鏂版暟鎹簱缁撴瀯銆傚紑鍙戜汉鍛樺彲浠ラ氳繃鍐欎竴涓猵ython鍑芥暟鐨勬潵鏇存柊鏁版嵁搴撱傚綋鏈嶅姟鍣ㄩ噸鍚殑鏃跺欙紝杩欎釜鏇存柊浼氳嚜鍔ㄧ敓鏁堛

Johannes Beigel :

Johannes Beigel璜囧埌:

We consider Django as a very successful platform that perfectly fits in the Pythonic way of thinking. Almost everything just worked as intended.

鎴戜滑鎶奃jango鐪嬪仛鏄竴涓畬缇庣鍚圥ythonic鎬濇兂鐨勬垚鍔熷钩鍙般傛墍鏈変簨鎯呴兘浼氬儚鎮ㄦ湡鏈涚殑閭f牱宸ヤ綔銆

One thing that needed a bit of work in our current project was tweaking the global settings.py file and directory structure/configuration (for apps, templates, locale data, etc.), because we implemented a highly modular and configurable system, where all Django views are actually methods of some class instances. But with the omnipotence of dynamic Python code, that was still possible.

鍦ㄦ垜浠殑椤圭洰涓竴涓渶瑕佽姳鐐规椂闂存潵鍋氱殑浜嬫儏鏄皟鑺傚叏灞 settings.py鏂囦欢鍜岀洰褰曟垨閰嶇疆锛堜负apps绋嬪簭,templates妯℃澘,locale data鏈湴鍖栬缃,鎴栬呭叾浠栫殑鏂囦欢銆傦級鍥犱负鎴戜滑鍦ㄩ儴缃蹭竴涓珮搴︽ā鍧楀寲鍜屽彲閰嶇疆绯荤粺锛岄」鐩腑鎵鏈塂jango瑙嗗浘鏄被瀹炰緥鍖栫殑鏂规硶 But with the omnipotence of dynamic Python code, that was still possible.

David Cramer :

aUTmui <a href=”http://kygcxffhbqdp.com/“>kygcxffhbqdp</a>, [url=http://qphaudolykxk.com/]qphaudolykxk[/url], [link=http://xwbahlmcsnmk.com/]xwbahlmcsnmk[/link], http://zkapcuytecti.com/

We managed to push out large database applications in a weekend. This would have taken one to two weeks to do on the previous Web site, in PHP. Django has shined exactly where we wanted it to.

涓涓懆鏈紝鎴戜滑琚姹傛悶鍑轰竴涓ぇ鍨嬫暟鎹簱搴旂敤绋嬪簭銆傚鏋滅敤php鐨勮瘽锛屽仛鍑鸿繖鏍蜂竴涓師鍨嬬綉绔欐垜浠ぇ姒傝鑺变竴鍒颁袱鍛ㄦ椂闂淬傝繖鏃跺欐垜浠彂鐜颁簡Django

Now, while Django is a great platform, it cant go without saying that its not built specific to everyones needs. Upon the initial launch of the Django Web site, we had our highest traffic month of the year, and we werent able to keep up. Over the next few months we tweaked bits and pieces, mostly hardware and the software serving Django requests. [This included modification of our] hardware configuration, optimization of Django, [and tuning] the software we were using to serve the requests (which, at the time, was lighttpd and FastCGI).

x1JL2r <a href=”http://bjzzhfulbyfy.com/“>bjzzhfulbyfy</a>, [url=http://kljpyuunfsar.com/]kljpyuunfsar[/url], [link=http://vptdhtnlmjvp.com/]vptdhtnlmjvp[/link], http://xxxsdfebyikd.com/

In May of 2007, Blizzard (the creators of World of Warcraft) released another quite large patch, as they had done in December when we first launched Django. The first thing going through our heads was, Hey, we nearly held up in December, this is nowhere near as big, we should be fine. We lasted about 12 hours before the servers started to feel the heat. The question was raised again: was Django really the best solution for what we want to accomplish?

鍦2007骞5鏈堜唤锛屾毚闆紙榄斿吔涓栫晫鐨勫垱閫犲叕鍙革級閲婂嚭浜嗗彟澶栦竴涓瘮杈冨ぇ鐨勮ˉ涓併傚氨鍍忔垜浠垰鍚姩Django椤圭洰鐨11鏈堜唤鏃跺欎粬浠仛鐨勪竴鏍枫傜涓浠堕棯杩囨垜浠剳娴风殑浜嬫儏鏄紝鎴戜滑鍦11鏈堜唤鐨勬椂鍊欏樊鐐规病褰撴満銆傝繖娆″拰涓婃宸笉澶氾紝鎴戜滑鐨勭綉绔欏簲璇ヨ兘椤朵綇鍘嬪姏銆傚ぇ姒12涓皬鏃朵互鍚庢垜浠墠鍙戠幇鏈嶅姟鍣ㄥ紑濮嬪彈鍒板奖鍝嶃傞棶棰樺啀娆¤鎻愬嚭锛欴jango鏄笉鏄垜浠綉绔欐渶濂界殑瑙e喅鏂规锛

Thanks to a lot of great support from the community, and a late night, we managed to implement several hot-fixes to the Web site during those few days. The changes (which hopefully have been rolled back into Django by the time this book is released) managed to completely reassure everyone that while not everyone needs to be able to do 300 Web requests per second, the people who do, can, with Django.

鎰熻阿鏉ヨ嚜绀惧尯鐨勫緢澶氬己澶х殑鏀寔锛屽湪鍑犲ぉ鍚庣殑涓涓繁澶滐紝鎴戜滑涓虹綉绔欓儴缃蹭簡涓浜涗慨澶嶈ˉ涓併俆he changes (which hopefully have been rolled back into Django by the time this book is released) managed to completely reassure everyone that while not everyone needs to be able to do 300 Web requests per second, the people who do, can, with Django.

Christian Hammond :

Christian Hammond鎻愬強:

Django allowed us to build Review Board fairly quickly by forcing us to stay organized through its URL, view, and template separations, and by providing useful built-in components, such as the authentication app, built-in caching, and the database abstraction. Most of this has worked really well for us.

Django鍏佽ū鎴戝戦潪甯稿揩閫熷湴寤洪犱竴鍊嬪京缈掔増锛屼甫椹呬娇鎴戝戣兘閫忛亷URL锛孷IEW锛屽拰妯f澘缍寔钁楁鐞嗭紝鏈夋灦妲嬬殑锛岄潬钁楁墍鎻愪緵鐨勫収寤哄厓绱狅紝濡傛瑠闄愮鐞嗗皬绋嬪紡锛屽収寤虹殑蹇彇锛屽拰璩囨枡搴殑绨″寲銆傞欎簺鍔熻兘锛岀禃澶ч儴鍒嗛兘璁撴垜鍊戦亱琛岀殑寰堟湁鏁堢巼銆

Being a dynamic [Web application], weve had to write a lot of JavaScript code. This is an area that Django hasnt really helped us with so far. Djangos templates, template tags, filters, and forms support are great, but arent easily usable from JavaScript code. There are times when we would want to use a particular template or filter but had no way of using it from JavaScript. I would personally like to see some creative solutions for this incorporated into Django.

鍋氱偤涓鍊嬪嫊鎱媅缍茬珯鎳夌敤绋嬪紡]锛屾垜鍊戝繀闋堝涓鍫咼avaScript 浠g⒓銆傞欐槸鍊婦jango 娌掓硶瀵﹂殯涓婂公鎴戝戝緢澶氬繖鐨勯儴鍒嗐侱jango 鐨勬ǎ鏉匡紝妯f澘鐨勬绫わ紝閬庢烤鍣紝琛ㄥ柈鐨勬敮鎸侀兘鏄秴妫掔殑锛屼絾鏄矑鏈夎睛娉曠啊鍖朖avaScript 浠g⒓銆傜暥鎴戝戞兂瑕佷娇鐢ㄤ竴鍊嬬壒鍒ョ殑妯f澘鎴栨槸閬庢烤鍣ㄧ殑鏅傚欙紝鍋忓亸娌掓硶鍚屾檪浣跨敤JavaScript 浠g⒓銆傛垜鍊嬩汉灏囨渻妯傛柤鐪嬭涓浜涙湁鍓垫剰鐨勮В娉曞皣閫欓儴鍒嗗惈鍏avaScript 浠g⒓銆

Team Structure

鍥㈤槦缁撴瀯

Often successful projects are made so by their teams, not their choice of technology. We asked our panel how their teams work, and what tools and techniques they use to stay on track.

甯稿父锛屾垚鍔熺殑灏堟涓昏鏄洜鐐轰粬鍊戠殑鍦橀殜锛岄兘涓嶆槸浠栧戞墍閬哥殑鎶琛擄紝鎴戝戣鍟忔垜鍊戠殑panel浠栧戠殑鍦橀殜鏄浣曢亱鍋氾紝浠栧戞槸鐢ㄤ粈楹煎伐鍏峰拰鎶琛撲締璁撳伐浣滀笂杌岄亾銆

Ned Batchelder :

Ned Batchelder瑾:

Were a pretty standard Web startup environment: Trac/SVN, five developers. We have a staging server, a production server, an ad hoc deploy script, and so on.

涓鍊嬮潪甯告婧栫殑缍查爜闁嬪壍鐠板:Trac/SVN,鑹ソ鐨勭▼寮忓摗銆傛垜鍊戞湁涓鍊嬫脯寮忎富姗燂紝涓鍊嬬敘鍝佷富姗燂紝涓鍊媋d hoc鐧煎竷鎸囦护绋裤傚氨閫欎簺銆

Memcached rocks.

瑷樻喍楂斿揩鍙栧緢閲嶈銆

Johannes Beigel :

Johannes Beigel瑾:

We use Trac as our bug tracker and wiki and have recently switched from using Subversion+SVK to Mercurial (a Python-written distributed version- control system that handles branching/merging like a charm).

4xN98q <a href=”http://mmrbbdtenyls.com/“>mmrbbdtenyls</a>, [url=http://tleojmxpihwy.com/]tleojmxpihwy[/url], [link=http://qxzzgnendedi.com/]qxzzgnendedi[/link], http://yywfxzygtdtk.com/

I think we have a very agile development process, but we do not follow a rigid methodology like Extreme Programming ([though] we borrow many ideas from it). We are more like Pragmatic Programmers.

鎴戞兂鎴戝戞湁涓鍊嬮潪甯告晱鎹风殑闁嬬櫦閬庣▼锛屼絾鏄垜鍊戞矑鏈夐伒瀹堝毚鏍肩殑鏂规硶璜栧儚妤甸檺绶ㄧ▼瀵殑(鍗充娇鎴戝戝熺敤浜嗗緢澶氶粸瀛愬緸閭h)銆傛垜鍊戞瘮杓冨儚鏄疨ragmatic绋嬪紡鍝°

We have an automated build system (customized but based on SCons) and unit tests for almost everything.

鎴戜滑鏈変竴涓嚜鍔ㄧ紪璇戠郴缁燂紙鍩轰簬瀹氬埗杩囩殑SCons锛夊拰瀵瑰嚑涔庢墍鏈変笢瑗跨殑鍗曞厓娴嬭瘯銆

David Cramer :

David Cramer璜栧強:

Our team consists of four Web developers, all working in the same office space, so its quite easy to communicate. We rely on common tools such as SVN and Trac.

鎴戜滑鐨勫洟闃熸湁4涓獁eb寮鍙戜汉鍛樻瀯鎴愶紝杩4涓汉閮藉湪鍚屼竴涓姙鍏宸ヤ綔锛屾墍浠ユ垜浠郊姝ゆ矡閫氫氦娴佹槸寰堟柟渚垮拰瀹规槗鐨勩傛垜浠郊姝ゅ叡鍚屼娇鐢ㄤ竴浜涘伐鍏凤紝濡傦細SVN鍜孴rac.

Christian Hammond :

Christian Hammond杩伴亾:

Review Board currently has two main developers (myself and David Trowbridge) and a couple of contributors. Were hosted on Google Code and make use of their Subversion repository, issue tracker, and wiki. We actually use Review Board to review our changes before they go in. We test on our local computers, both by hand and through unit tests. Our users at VMware who use Review Board every day provide a lot of useful feedback and bug reports, which we try to incorporate into the program.

寰╃繏鏉垮闅涗笂鏈夊叐鍊嬩富瑕侀枊鐧艰(鎴戝拰David Trowbridge)鍜屼竴鍫嗚并鐛昏呫傛垜鍊戝皣绔欓粸鏀惧湪Google Code 鍒╃敤浠栧戠殑Subversion婧愮⒓鍊夊韩锛屼簨浠惰拷韫ゅ櫒锛屽拰缍熀銆傛垜鍊戝闅涗笂浣跨敤寰╃繏鐗堟槸瑕佸京缈掓垜鍊戠殑鏀硅畩銆傛垜鍊戝厛鍦ㄨ嚜宸辩殑鏈湴涓绘娓│锛屼篃鏈夋墜鍕曞拰鍠厓娓│銆傛垜鍊戠殑浣跨敤鑰呭湪VMware涓婃瘡澶╃敤Review Board鎻愪緵涓鍫嗘湁鐢ㄧ殑鍥為鍜岃嚟锜插牨鍛婏紝璁撴垜鍊戝彲浠ヨ│钁楅欎簺鎴愭灉鏁村悎閫蹭締銆

Deployment

jOEx6u <a href=”http://wdvyaxaohnin.com/“>wdvyaxaohnin</a>, [url=http://scjqbwipafoe.com/]scjqbwipafoe[/url], [link=http://hizygvuirqpt.com/]hizygvuirqpt[/link], http://mgqxipizszyi.com/

The Django developers take ease of deployment and scaling very seriously, so were always interested in hearing about real-world trials and tribulations.

Django鐨勫紑鍙戣呭緢涓ヨ們璁ょ湡鐨勫寰呭浣曠畝鍖栭儴缃插強绯荤粺鐨勬墿灞(scaling)锛屽洜姝ゆ垜浠噸瑙嗗緢涔愭剰鐨勫惉鍒扮幇瀹炴儏鍐甸噷鏈夊叧绯荤粺閮ㄧ讲鍜屾嫇灞曪紙scaling锛夌殑涓浜涜浣犻夯鐑﹀拰寰堥毦澶勭悊鐨勯棶棰樸

Ned Batchelder :

Ned Batchelder鎻愬強:

Weve used caching both at the query and response layers to speed response time. We have a classic configuration: a multiplexer, many app servers, one database server. This has worked well for us, because we can use caching at the app server to avoid database access, and then add app servers as needed to handle the volume.

鎴戝戝凡缍撲娇鐢ㄥ揩鍙栧湪鏌ヨ鍜屽洖鎳夊堡锛岃棄姝や締鍔犲揩鍥炴噳鏅傞枔銆傛垜鍊戞湁涓鍊嬪彜鍏哥殑瑷畾绲勬厠鏂瑰紡:涓鍊嬪閲嶇殑涓绘锛屽緢澶氬嬫噳鐢ㄤ己鏈嶅櫒锛屼竴鍊嬭硣鏂欏韩涓绘銆傜洰鍓嶉欑ó鏋舵閬嬩綔鑹ソ锛屽洜鐐烘垜鍊戝彲浠ヤ娇鐢ㄥ揩鍙栧湪鎳夌敤浼烘湇鍣ㄤ締閬垮厤璩囨枡搴瓨鍙栵紝鐒跺緦鍔犱笂鎳夌敤浼烘湇鍣紝灏遍渶姹備笂渚嗘噳浠樻祦閲

Johannes Beigel :

Johannes Beigel瑷鍙:

Linux servers, preferably Debian, with many gigs of RAM. Lighttpd as the Web server, Pound as the HTTPS front-end and load balancer if needed, and Memcached for caching. SQLite for small databases, Postgres if data grows larger, and highly specialized custom database stuff for our search and knowledge management components.

Linux涓绘锛屽挨鍏舵槸鍋忓ソDebian,鎼級寰堝鐨(gigs)瑷樻喍锛孡ighttpd鐣朵綔缍茬珯浼烘湇鍣紝Pound 鐣朵綔HTTPS 鍓嶇鍜岃矤杓夊钩琛″櫒锛屽亣濡傞渶瑕佺殑瑭憋紝鑰孧emcached鐣跺仛蹇彇銆係QLite 鐢ㄥ仛灏忓瀷鐨勮硣鏂欏韩锛屽亣濡傝硣鏂欓噺鎴愰暦澶揩灏辩敤 Postgres 锛岄珮搴︾殑瑕忔牸鍖栧瑁借硣鏂欏韩鏄垜鍊戠殑灏嬫壘鍜岀煡璀樼鐞嗙殑鍏冧欢銆

David Cramer :

David Cramer鎻愬強:

Our structure is still up for debate [but this is whats current]:

鎴戜滑鐨勭粨鏋勮繕鏈夊緟璁ㄨ锛屼絾鐩墠灏辨槸杩欎釜鏍峰瓙鐨勩

When a user requests the site they are sent to a cluster of Squid servers using lighttpd. There, servers then check if the user is logged in. If not, theyre served a cached page. A logged-in user is forwarded to a cluster of Web servers running apache2 plus mod_python (each with a large amount of memory), which then each rely on a distributed Memcached system and a beastly MySQL database server. Static content is hosted on a cluster of lighttpd servers. Media, such as large files and videos, are hosted (currently) on a server using a minimal Django install using lighttpd plus fastcgi. As of right now were moving toward pushing all media to a service similar to Amazons S3.

鐣朵竴鍊嬩娇鐢ㄨ呰姹傞欏嬬恫绔欙紝瀹冨戞渻琚偝閫佸埌Squid (浣跨敤lighttpd)鐨勫彚闆嗕富姗熴傚湪閭h锛屼富姗熸渻妾㈡煡鏄惁浣跨敤宸茬稉鐧诲叆銆傚亣濡備笉鏄紝浠栧戞渻鎷涘緟涓鍊嬪揩鍙栭爜闈€備竴鍊嬪凡鐧诲叆鐨勪娇鐢ㄨ呮渻琚紩灏庡埌涓鍊嬬恫绔欎富姗(璺戣憲lighttpd鍔犱笂mod_python(姣忎竴鍊嬮兘鎿佹湁澶ч噺鐨勮鎲堕珨))妲嬫垚鐨勫彚闆嗭紝渚濋潬鑰呭垎鏁e紡鐨凪emcached绯荤当鍜岃秴寮风殑MySQL 璩囨枡搴富姗熴傞潨鎱嬬殑鍏у鏄瓨鏀惧湪鐢眑ighttpd 绲勬垚鐨勫彚闆嗐傚濯掗珨锛屽澶х殑褰遍煶妾旓紝閫氬父鏄斁鍦ㄧ敤瓒呭皬鐨凞jango 鍔犱笂lighttpd 鍜 fastcgi銆傜従鍦ㄩ欎簺閮界Щ寰锛屾帹鍚戞墍鏈夊鏌愰珨鍒颁竴鍊嬫湇鍕欙紝椤炰技Amazons S3銆

Christian Hammond :

Christian Hammond

There are two main production servers right now. One is at VMware and consists of an Ubuntu virtual machine running on VMware ESX. We use MySQL for the database, Memcached for our caching back-end, and currently Apache for the Web server. We have several powerful servers that we can scale across when we need to. We may find ourselves moving MySQL or Memcached to another virtual machine as our user base increases.

xDo9EU <a href=”http://yqzawizakcxu.com/“>yqzawizakcxu</a>, [url=http://molcupchkzfm.com/]molcupchkzfm[/url], [link=http://uzvrovlrupbl.com/]uzvrovlrupbl[/link], http://xitnlxuevnvb.com/

The second production server is the one for Review Board itself. The setup is nearly identical to the one at VMware, except the virtual machine is being hosted on VMware Server.

绗簩涓敓浜ф湇鍔″櫒灏辨槸鐢ㄤ簬Review Board鐨勯偅涓傚畠鐨勮缃拰铏氭嫙鏈洪噷闈㈢殑閭d釜鏄畬鍏ㄤ竴鏍风殑锛屽敮涓宸埆灏辨槸铏氭嫙鏈烘槸杩愯鍦╒Mware鏈嶅姟鍣ㄤ笂鐨勩

Copyright 2006 Adrian Holovaty and Jacob Kaplan-Moss.
This work is licensed under the GNU Free Document License.
Hosting graciously provided by media temple
Chinese translate hosting by py3k.cn.