ไปสักพัก คราวนี้เกิดอะไรขึ้นทำไมต้องใช้ eclipse
ก็เนื่องจาก javascript นี่สิที่เป็นปัญหา ต้องยอมรับว่า tool ฟรี หาได้บน eclipse
จริง ๆ ใช้ JSLint ในการ validate javascript syntax
แล้ว project ที่ใช้ก็คือ Turbogears2 เอาไงดี ใหน ๆ ก็พี่งพา tool ระดับเทพ
นี้แล้วก็ต้องใช้ให้มันคุ้มกับความหน่วง เลยไปเจอวิธีมา ว่าจะ run project ที่เป็น
Turbogear ได้อย่างไร ก็ไปเจอวิธีมา ตามนี้ครับ
สิ่งที่ต้องทำแล้ว
1. install Python 2.5, 2.6
2. install Turbogears 2.0
3. install Eclipse 3.4+
ส่วนแรก เป็นการ
install PyDev(tool ที่ทำให้ eclipse รู้จักภาษา python)
1) ที่ menu bar เลือก Help >> Install New Software >> Add...
2) set Name : Pydev
3) set Location : http://pydev.org/updates/ and click button ok
4) check box PyDev only and click button Next>
5) download and install by click button Finish
6) restart eclipse after add plugin
setup PyDev(ชี้ไปยัง paht python ที่ทำการ install)
1) ที่ menu bar เลือก Window >> Preference
2) ที่ menu ด้านซ้ายมือ เลือก Pydev >> Interpreter - Python
3) ด้านขวามือจะขึ้น Python Interpreters ให้ Click New... ให้เลือก path python
<< path install >>\tg2env\Scripts\python.exe
ในส่วนนี้จะเลือก python จาก turbogear environment เป็นหลัก เพราะ tool บางตัว เช่น cx_Oracle ของ windows บังคับให้ลงที่เดียว และต้องไว้ใน env ของ tg2 ด้วยครับ เคยกล่าวไว้ใน post เก่าลองไปดูกันได้ แล้วจึง Click New... ให้เลือก path python
C:\Python25\python.exe
เป็นรองครับ ลงมาเพราะต้องใช้ tool บางอย่างบน env python
ขั้นตอนต่อไปคือ
สร้าง project ด้วย tg2 หรือเป็น project ที่มีอยู่เดิมแล้ว
ให้ใช้คำสั่ง (ถ้าเคยทำแล้วอาจไม่ต้องทำอีกครับ)
ทำการ set env turbogear โดนเข้าไปที่
cd << << path install >>\tg2env\Scripts\
activate
เข้าไปที่ path project จะเจอ file setup.py
python setup.py install
หรือ ถ้า error ฟ้องให้ใช้ develop ก็เปลี่ยนเป็น
python setup.py develop
เสมอ เพื่อให้ project มีการ load resource และจัดเตรียมอะไรบางอย่างให้พร้อมครับ
ในส่วนที่สอง เป็นการ set run-script turbogear2 on eclipse
For TG2, provided pydev is setup.
1) Under Run->External Tool->External Tools Configurations
2) Create a "New Launch Configuration"
3) On the Main Tab
Name: TG2 App Start
Location: /usr/local/devenv/tg2env/bin/paster (Your Path to
paster)
Working Directory: ${project_loc}
Arguments: serve --reload development.ini
4) On the Common Tab
Check "Display in favorites menu" > External Tools
5) Apply and close
6) In Navigator Window, highlight the project folder.
7) Under Run->External Tool->External You can select the new "TG2 App
Start"
ถ้าไม่ติดปัญหาอะไร ที่ console ของ eclipse จะขึ้น log เวลาที่เราเข้า
localhost:8080 << ตัวอย่าง url ที่ set ไว้สำหรับใช้งน