Pylonsä½é¨è¨
Pylonsã¨ããã®ã¯Pythonã®æ°ããã¦ã§ããã¬ã¼ã ã¯ã¼ã¯ã§ãã
ã¯ããã«
ä»ããä¼ç¤¾ã¯ããªãPython人æ°ãé«ãã¦ã社å¡ã«å ããPythonistaã®å²åã§èããããããããã¨Google以ä¸ãããã¨ãããããçãPythonã使ã£ã¦ããããã¾ãï¼ã¾ãå°ããä¼ç¤¾ãªã®ã§ç¤¾å¡èªä½ãå°ãªããã§ãã)ãããã§ãä»åº¦ã®ä»äºã§Pylonsã使ãã¨ãã話ããã£ãã®ã§è©¦ãã«ä½ãä½ã£ã¦ã¿ãããã¨æããæåã¯åããªãã¨é¢ç½ããªãã®ã§ãid:perezvonããã®ä¸é£ã®è¨äºãåèãã¨ããããã®ã¾ã¾ä¸¸åãããã¦ããã£ã¦æããæ´ãã¨ããããå§ãã¾ããã
ç°å¢æ§ç¯
ãã®åã«Pythonã®ç°å¢æ§ç¯ããã¾ããPythonã«ãPerlã®CPANã¢ã¸ã¥ã¼ã«ã¨åãããã«ãããã¯ã¼ã¯ããããã±ã¼ã¸ãèªåçã«ã¤ã³ã¹ãã¼ã«ãã¦ãããeasy_installã¨ããä»çµã¿ãããã¾ããããã§ã以ä¸ã®ãµã¤ããªã©ãåèã«root権éãªãã§easy_installã§ããããã«ãã¾ãã
- ウノウラボ Unoh Labs: Python開発環境を整えよう
- sh1.2 pyblosxom : さくらでPythonモジュール設定
- 「さくらのレンタルサーバ」で Python 外部モジュールを使う
å ·ä½çã«ã¯ä»¥ä¸ã®æé ã§ãã
- 1. ~/.pydistutils.cfgãä½æ
[install] install_lib = /usr/local/python/lib/python install_scripts = /usr/local/python/bin
- 2.ç°å¢å¤æ°ãè¨å®
$ export PYTHONPATH=/usr/local/python/lib/python $ export PATH=/usr/local/python/bin:$PATH
- 3./usr/local/pythonãä½æãroot以å¤ã§ãæ¸ãè¾¼ããããã«æ¨©éãè¨å®ããï¼ãã®æé ã®ã¿rootã§ä½æ¥ï¼
- 4./usr/local/python/{bin,lib}ãä½æ
ããã¦easy_installãå®è¡ã
$ easy_install Pylons $ easy_install SQLAlchemy $ easy_install PasteScript
次ã«pasterã³ãã³ãã§ããã¸ã§ã¯ãã®éåã«ãªããã¡ã¤ã«ãä½æãã¾ãã
$ paster create --template=pylons BlogTutorial
ããããã§çµæ§ãããªã¾ãããã¾ãsetuptoolsã®ãã¼ã¸ã§ã³ãä½ãããã¨è¨ãããã®ã§easy_installã§setuptoolsãå ¥ãããã¨ãããã§ãããã¾ããã¼ã¸ã§ã³ã¢ãããã¦ãããã以ä¸ã®ããã«ãã¼ã¸ã§ã³æå®ããå¿ è¦ãããã¾ããã
$ easy_install "setuptools>=0.6c5"
ããã§ããã¼ã¸ã§ã³ãä½ãã¨ããã¨ã©ã¼ãåºãã®ã§ãRPMã§å ¥ãã¦ããsetuptoolsãã¢ã³ã¤ã³ã¹ãã¼ã«ãããã¨ã©ã¼ã¯åºãªããªãã¾ãããããã«ä½åº¦ãpaster createãå®è¡ãã¦ãã®åº¦ã«ãââããã±ã¼ã¸ãä¸è¶³ãã¦ãããã¨ããã¨ã©ã¼ãåºã¦ã¯easy_installã§ã¤ã³ã¹ãã¼ã«ãç¹°ãè¿ãã¦ãçµå±paster createãå®è¡ã§ããããã«ãªãã¾ã§ã«ä»¥ä¸ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ããï¼ãã®è¾ºã¯èªåã§å ¥ã£ã¦ããããã¨ãæå¾ ãã¦ãããã§ããããåãããªãã¨ããã§ãï¼ã
$ easy_install "nose>=0.9.2" $ easy_install "setuptools>=0.6c5" $ easy_install "decorator>=2.0.1" $ easy_install "simplejson>=1.7.1" $ easy_install "FormEncode>=0.7" $ easy_install "Myghty>=1.1" $ easy_install "Beaker>=0.6.3" $ easy_install "WebHelpers>=0.3"
paster createãå®è¡ããã¨ã«ã¬ã³ããã£ã¬ã¯ããªã«BlogTutorialã¨ãããã£ã¬ã¯ããªãã§ãã¦ããã®ã§ãããã«ç§»åãã¦ãµã¼ããèµ·åãã¦ã¿ã¾ãã
$ cd BlogTutorial $ paster serve --reload development.ini
ã¾ã 1è¡ãã³ã¼ããæ¸ãã¦ãã¾ãããããã©ã¦ã¶ã§http://localhost:5000/ã«ã¢ã¯ã»ã¹ããã¨Welcomeãã¼ã¸ã表示ããã¾ããã
ããããå ã¯ãã¥ã¼ããªã¢ã«ã«å¾ã£ã¦é²ããã ããªã®ã§å²æãã¾ãããéçºãé²ããã¨ããã«ä»¥ä¸ã®ããã±ã¼ã¸ãå¿ è¦ã«ãªãã®ã§ãããããã¤ã³ã¹ãã¼ã«ãã¦ããã¨ããããããã¾ããã
$ easy_install pysqlite $ easy_install Authkit
éæ
æ§ã ãªããã±ã¼ã¸ãçµã¿åããã¦ä½ãã¨ããããã³ã¼ãèªåçææ©è½ãéçºç¨ã®Webãµã¼ãæ©è½ãæä¾ãã¦ãããã¨ãªã©ãåãã¦ã§ããã¬ã¼ã ã¯ã¼ã¯ã§ããPerlã®Catalystã¨é°å²æ°ãä¼¼ã¦ãã¾ãããå®éã«ã³ã¼ããæ¸ãã¦ããã¨éãã¨ããããã£ã¦ãç¹ã«URLã¨ã³ã³ããã¼ã©ã®ãããã³ã°é¨åã¯ç¬ç¹ã§ããããã ã大æ ã§ã¯MVCã«åã£ã¦ããã®ã§ãä»ã®ã¦ã§ããã¬ã¼ã ã¯ã¼ã¯ã触ã£ããã¨ã®ãã人ãªãããã»ã©éåæãªã使ããã¨æãã¾ãï¼Ruby on Railsã¯è§¦ã£ããã¨ããªãã®ã§æ¯è¼ã§ããªãã®ã§ããã詳ãã人ã«è¨ãã¨ãPylonsã¯RoRã¨ä¼¼ã¦ãããCatalystã«ã¯ããã¾ãä¼¼ã¦ãªããã¨ã®ãã¨ã§ããï¼ã
ãã®MVCã®Vã®é¨åã§ããã³ãã¬ã¼ãã¨ã³ã¸ã³ã¯æ¨æºã®MyghtyããMakoãGenshiã®æ¹ãè¯ããããã§ããããã§ä¸åº¦Myghtyã§ä½ã£ãå¾ãMyghtyâMakoâGenshiã¨é çªã«ãã³ãã¬ã¼ãã¨ã³ã¸ã³ãå¤æ´ãã¦ã¿ãã¨ãããMakoã¯åãããã§ããGenshiã¯ããªã½ã¼ã¹ãè¦ã¤ãããªããã¨ãããããªã¨ã©ã¼ãåºã¦ã¾ã åããã¦ãã¾ããï¼ãã¶ããã³ãã¬ã¼ãã®å ´æããã¾ãæå®ã§ãã¦ããªãï¼ã
å®ã¯ä¸ã¶æã ãæ©ãã ã¨ããããã£ã¦ãBlogãä½ã(2)ãã¼ã¿ãã¼ã¹ã®è¨å®ã§ãã¢ãã«ã¯ã©ã¹ã¯ãblogtutorial/modelsã¢ã¸ã¥ã¼ã«ã«å®ç¾©ãã¾ãããã¨ç°¡åã«æ¸ããã¦ããã®ã§ãããPythonã®ç¥èãä¹ããã®ã§ãã®å®ç¾©ãã©ã®ãã¡ã¤ã«ã«æ¸ãã°ããã®ããåããã¾ããã§ãããæåblogtutorial/models.pyã¨ãããã¡ã¤ã«ãä½ã£ããã¢ã¸ã¥ã¼ã«ããã¼ãã§ããªãã¦ã代ããã«blogtutorial/models/post.pyã¨ãé©å½ã«ãã¡ã¤ã«ãä½ã£ã¦ã¿ããimportæãä¿®æ£ããå¿ è¦ããããã®ã®ã¨ããããåãã¾ããããã®å¾blogtutorial/models/__init__.pyã«æ¸ãããã«ãããimportæãä¿®æ£ããã«åãããã§ãããããã§æ£ããã®ãã¤ãã¤ãèªä¿¡ãããã¾ãããããããPythonã®ã¢ã¸ã¥ã¼ã«ã¨ããã®ãã©ããããã®ãªã®ãããã®è¾ºããç解ããå¿ è¦ãããããã§ãã
ã¨ããã§ãeasy_installã¨ãpasterã¨ãä¸è¬çãããååãä»ããäºã«å¯¾ãã¦Pythonã®äººéã¯æ°ã«ãªããªããã§ããããããã¼ãã³ã°ã»ã³ã¹ãæ¬ å¦ãã¦ããã®ãããã¨ãå¯æç¬å°ãªã®ãâ¦ã