Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tutorial / Pyramid Framework

Pyramid Framework

包括 Kotti 內容管理系統

檔案系統 O'Reilly Video Tutorial @pythonfinland Video: blog,

Gluino: port of web2py libs to bottle, flask, pyramid, tornado (includes copy of modules from the web2py framework)

Flask vs. Django vs. Pyramid vs. Plone Django vs Pyramid Pyramid vs Django vs Flask 5 Frameworks

Plone vs Django vs Tornado vs Pyramid vs Flask: Tornado 缺乏 404 error 處理機制,適合非同步存取機制的大型網站。

subprocess_middleware was built to support rendering Python generated JSON into HTML using a nodejs.

serve up different templates based on different routes Serve with Twisted Scaling with Multiple Client Instances TALES Template 執行效率比 Python Expression 來得差

範例

REST API with Ramses marioidival LiveCoding awesome pyramid pyramid_packages_domo Quick Project Startup with Cookiecutters 在 Kotti 1.3 透過 pcreate -s kotti 來建立專案骨架是不錯的起點, 需要調整 setup.py w.r.t. trove 並把 u'' 刪除. 或是試 https://github.com/Kotti/kotti-cookiecutter

Google App Engine Kiwi PyCon 2013 Tim Knapp: slide video github

Long Polling Channels

TicTacToe and Long Polling

Sphinx Documentation Integration KARL project case

Porting an Existing Application

Windows + MySQL

Deployment: Gunicorn

身份驗證與授權

種類很多oAuth 是常見的驗證服務,可以使用 Velruse 作為認證模組,或是使用 pyramid-oauth2 模組。其他的模組像 PersonaMACAuth

Heroku

https://github.com/GlossProject/gloss-backend-kotti-heroku

$ git clone 
$ ./prepare.sh 
Creating app... done, ⬢ whispering-bastion-51176
https://whispering-bastion-51176.herokuapp.com/ | https://git.heroku.com/whispering-bastion-51176.git
Creating heroku-postgresql:hobby-dev on ⬢ whispering-bastion-51176... free
Database has been created and is available
 ! This database is empty. If upgrading, you can transfer
 ! data from another database with pg:copy
Created postgresql-round-32274 as DATABASE_URL
Use heroku addons:docs heroku-postgresql to view documentation
Scaling dynos... !
 ▸    Couldn't find that process type.

Code Fellows 401 Tutorial Pyramid on Heroku

Google App Engine

通常有兩種方式

buildout 記得確認 SDK 下載版本號碼,雖然 bin/buildout 成功了,但 ../../bin/python setup.py test 遇到 ImportError: No module named mock (/home/marr/kotti_site/local/lib/python2.7/site-packages/kotti/tests/__init__.py)

Kotti

2.0.0a1 (只)支援 Python 3.5 以上版本,其餘和 1.3.1 相同。2.0.0b2 和 1.3.2 則加上 CSRF 修訂。

first step 起手文件 Kotti 角色類似 Zope2 CMF,不過只存在一個網站物件,存取方式較 Plone 簡化許多。

$ conda create --name kotti_py36 python=3.6
$ source activate kotti_py36
$ mkdir kotti_py36; cd kotti_py36
$ pip install -r https://github.com/Kotti/Kotti/raw/master/requirements.txt
...
Successfully installed Babel-2.5.3 ...
$ pip install Kotti
...
Successfully installed Kotti

發現 Kotti 安裝版本 1.3.2 想換成 2.0.0b2 執行 pip install --upgrade Kotti==2.0.0b2

如果想加 diazo 要再 pip install diazo repoze.xmliter pytest,不過還沒確認 https://github.com/GlossProject/gloss-backend-kotti-heroku 是否適用於 Python 3 環境,很可能要換掉 Paste 之類。

傳回項目清單來顯示的範例

from pyramid.view import view_config
from kotti.resources import Document

@view_config(name='myview', renderer='mytemplate.pt', ...)
def myview(context, request):
  documents = Document.query.filter(<whatever your criteria are>)
  return {'documents': documents}
<li tal:repeat="d documents"><a href="request.resource_url(d)">${document.title}</a></li>

在 app.ini 檔案 kotti.site_title 可以使用中文標題,但有辦法做到 multilingual 嗎?

Eucalyptus Management Console Command Line Script Tool

https://devcenter.heroku.com/articles/creating-apps
https://devcenter.heroku.com/articles/git

使用者資料欄位客製化可以修改 Principals Ordering Fields in colander based Schemas

Relation 範例 kotti_image ElasticSearch

https://github.com/koansys/heroku-kotti 太舊了

Andreas Kaiser: zope.testbrowser wsgi_intercept are the Python 2 only requirements

參與貢獻

http://docs.pylonsproject.org/en/latest/#contributing

http://docs.pylonsproject.org/en/latest/community/featuresbugs.html#working-on-code

Kotti CMS like Plomino Intranet AngularJS with Kotti

frontend decoupled from backend: 1 2