Python 웹 개발 프레임 워 크 Pylons
3. Pylons
3.1. Getting Started with Pylons
3.1.1. Installing
[neo@development ~]$ curl http://pylonshq.com/download/1.0/go-pylons.py | python - mydevenv
[neo@development ~]$ source mydevenv/bin/activate
(mydevenv)[neo@development ~]$
(mydevenv)[neo@development ~]$ paster create -t pylons helloworld
Running the application
(mydevenv)[neo@development ~]$ cd helloworld
(mydevenv)[neo@development helloworld]$ paster serve --reload development.ini
Starting subprocess with file monitor
Starting server in PID 26895.
16:38:39,051 INFO [paste.httpserver.ThreadPool] Cannot use kill_thread_limit as ctypes/killthread is not available
serving on http://127.0.0.1:5000
create a controller
(mydevenv)[neo@development helloworld]$ paster controller hello
Creating /home/neo/helloworld/helloworld/controllers/hello.py
Creating /home/neo/helloworld/helloworld/tests/functional/test_hello.py
http://192.168.3.9:5000/hello/index
3.1.2. Debian/Ubuntu
$ sudo apt-cache search pylons
$ sudo apt-get install python-pylons
$ paster create -t pylons helloworld
/usr/lib/pymodules/python2.6/pylons/templating.py:610: UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)
Engine = entry_point.load()
Selected and implied templates:
Pylons#pylons Pylons application template
Variables:
egg: helloworld
package: helloworld
project: helloworld
Enter template_engine (mako/genshi/jinja2/etc: Template language) ['mako']:
Enter sqlalchemy (True/False: Include SQLAlchemy 0.5 configuration) [False]: True
Creating template pylons
Creating directory ./helloworld
Recursing into +package+
Creating ./helloworld/helloworld/
Copying __init__.py_tmpl to ./helloworld/helloworld/__init__.py
Recursing into config
Creating ./helloworld/helloworld/config/
Copying __init__.py_tmpl to ./helloworld/helloworld/config/__init__.py
Copying deployment.ini_tmpl_tmpl to ./helloworld/helloworld/config/deployment.ini_tmpl
Copying environment.py_tmpl to ./helloworld/helloworld/config/environment.py
Copying middleware.py_tmpl to ./helloworld/helloworld/config/middleware.py
Copying routing.py_tmpl to ./helloworld/helloworld/config/routing.py
Recursing into controllers
Creating ./helloworld/helloworld/controllers/
Copying __init__.py_tmpl to ./helloworld/helloworld/controllers/__init__.py
Copying error.py_tmpl to ./helloworld/helloworld/controllers/error.py
Recursing into lib
Creating ./helloworld/helloworld/lib/
Copying __init__.py_tmpl to ./helloworld/helloworld/lib/__init__.py
Copying app_globals.py_tmpl to ./helloworld/helloworld/lib/app_globals.py
Copying base.py_tmpl to ./helloworld/helloworld/lib/base.py
Copying helpers.py_tmpl to ./helloworld/helloworld/lib/helpers.py
Recursing into model
Creating ./helloworld/helloworld/model/
Copying __init__.py_tmpl to ./helloworld/helloworld/model/__init__.py
Copying meta.py_tmpl to ./helloworld/helloworld/model/meta.py
Recursing into public
Creating ./helloworld/helloworld/public/
Copying bg.png to ./helloworld/helloworld/public/bg.png
Copying favicon.ico to ./helloworld/helloworld/public/favicon.ico
Copying index.html_tmpl to ./helloworld/helloworld/public/index.html
Copying pylons-logo.gif to ./helloworld/helloworld/public/pylons-logo.gif
Recursing into templates
Creating ./helloworld/helloworld/templates/
Recursing into tests
Creating ./helloworld/helloworld/tests/
Copying __init__.py_tmpl to ./helloworld/helloworld/tests/__init__.py
Recursing into functional
Creating ./helloworld/helloworld/tests/functional/
Copying __init__.py_tmpl to ./helloworld/helloworld/tests/functional/__init__.py
Copying test_models.py_tmpl to ./helloworld/helloworld/tests/test_models.py
Copying websetup.py_tmpl to ./helloworld/helloworld/websetup.py
Copying MANIFEST.in_tmpl to ./helloworld/MANIFEST.in
Copying README.txt_tmpl to ./helloworld/README.txt
Copying development.ini_tmpl to ./helloworld/development.ini
Recursing into docs
Creating ./helloworld/docs/
Copying index.txt_tmpl to ./helloworld/docs/index.txt
Copying ez_setup.py to ./helloworld/ez_setup.py
Copying setup.cfg_tmpl to ./helloworld/setup.cfg
Copying setup.py_tmpl to ./helloworld/setup.py
Copying test.ini_tmpl to ./helloworld/test.ini
Running /usr/bin/python setup.py egg_info
host 감청 주소 설정
$ cd helloworld
$ vim development.ini
host = 0.0.0.0
시작 서비스
$ paster serve --reload development.ini
3.2. config/routing.py
url routing 은 정적 으로 모든 접 두 사 를.html 로 추가 합 니 다.
(mydevenv)[neo@development helloworld]$ vim helloworld/config/routing.py
map.connect('/{controller}/{action}.html')
map.connect('/{controller}/{action}/{id}.html')
3.3. mako template
http://www.makotemplates.org/
3.3.1. include
<%include file="header.html"/>
hello world
<%include file="footer.html"/>
전달 매개 변수
<%include file="toolbar.html" args="current_section='members', username='ed'"/>
3.3.2. inherit
<%inherit file="base.html"/>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.