python大會-uliweb比較與實(shí)踐_第1頁
python大會-uliweb比較與實(shí)踐_第2頁
python大會-uliweb比較與實(shí)踐_第3頁
python大會-uliweb比較與實(shí)踐_第4頁
python大會-uliweb比較與實(shí)踐_第5頁
已閱讀5頁,還剩60頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

2013年個(gè)人小結(jié)Uliweb與其它框架比較Uliweb的特殊功能介紹2013年個(gè)人小結(jié)Uliweb與其它框架比較Uliweb的特殊功能介紹Uliweb

發(fā)布到0.2.2par發(fā)布到0.9.3,parm

發(fā)布到0.6Win32-Process-Watcher

發(fā)布定制alembic并與Uliweb集成chatroom

實(shí)驗(yàn)使用Uliweb+gevnet-socketio寫的websocket的聊天程序,ws -web

sdesktopnotify

js庫,可以調(diào)瀏覽器notificationAPI對mmGrid添加樹,優(yōu)化多行表頭,無限翻頁等功能嘗試python3,創(chuàng)建2to6項(xiàng)目參加

組織的codepark編程公園活動,組織了3次全天的編程活動2013年個(gè)人小結(jié)Uliweb與其它框架比較Uliweb的特殊功能介紹怎么理解框架?需要框架嗎?(

)框架是經(jīng)驗(yàn)的總結(jié)框架是把設(shè)計(jì)思想(模式)、開發(fā)

、常見功能組織在一起的一種

**

**使用框架要按框架的要求來組織代碼,讓框架來調(diào)使用 是由你來組織如何使用使用框架表示你可能認(rèn)同它的設(shè)計(jì)思想需要框架嗎?.

/moin/FrameworksShow

/news/3092011.1

(1.0)第一個(gè)版本2005.11

(0.90)2008.12

(0.31)2009.10

(0.0.1)2010.4

(0.1)2009.10

(0.5.3)2010.07

(1.0.0)2007.10

(1.8)12344678時(shí)間VS組織方式APP,通過Blueprint來實(shí)現(xiàn)APP類似的功能APP時(shí)間-組織配置文件settings.py,多種格式支持,要先定義,py文件settings.ini,

local_setings.ini,app級別settings.ini時(shí)間-組織-配置文件配置文件語法變量大寫,Python語法變量大寫,Python語法,支持類的寫法Python語法大小寫都可以,Python語法時(shí)間-組織-配置文件程序結(jié)構(gòu)的創(chuàng)建makeproject手工手工makeproject,

makeapp時(shí)間-組織-配置文件-項(xiàng)目URL的定義集中式,urls.py,可以include,正則式在程序中分散定義,使用decorator,非正則主程序中集中定義,正則式在views.py中分散定義,使用decorator,同flask時(shí)間-組織-配置文件-項(xiàng)目-URLURL的反向獲取提供url_for,按名字獲取url_for,按名字獲取reverse_url,按名字提供url_for,url_for_static,按名字獲取時(shí)間-組織-配置文件-項(xiàng)目-URL模板支持block,代碼受限,可以定義filter,tagjinjia2,類django模塊,代碼限制較小類django,但是可以嵌入python表達(dá)式,導(dǎo)入等從web2py改造而來,支持block,可以直接嵌入python,pass表示縮近結(jié)束時(shí)間-組織-配置文件-項(xiàng)目-URL-模板模板文件關(guān)聯(lián)在render_to_template中指定在render_template中指定render中指定自動套用函數(shù),返回值為dict時(shí)或方法名或response.template中指定或expose中template時(shí)間-組織-配置文件-項(xiàng)目-URL-模板View方法函數(shù)和類,一個(gè)類只處理一個(gè)URL,需要從基類繼承函數(shù),類(需要從基類繼承),沒有對類的decorator的修飾函數(shù),一個(gè)類只處理一個(gè)URL類,一個(gè)類只處理一個(gè)URL,需要從基類繼承函數(shù)和類,一個(gè)類可以處理多個(gè)URL??梢栽陬惙椒ㄉ霞?/p>

expose,不需要特殊基類時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View常用對象的request是作為第一個(gè)參數(shù)導(dǎo)入綁定在類上自動注入和導(dǎo)入時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象Form處理內(nèi)置不提供,需要使用WTForms不提供內(nèi)置時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-FormORM內(nèi)置,自已實(shí)現(xiàn)不直接提供,通過Flask-SQLAlchemy不提供內(nèi)置,基于SQLAlchemy實(shí)現(xiàn)時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-ORM數(shù)據(jù)庫遷移間接通過south不提供不提供間接,集成了alembic時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-ORMi18n支持,通過xgettext提取支持,通過babel處理支持,通過xgettext提取支持,通過修改pygettext.py時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-i18n命令行工具提供,可以按app來自定義第無提供,可以按app來自定義時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-i18n-CMD異步處理支持第第內(nèi)置第時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-i18n-CMD-異步websocket第第內(nèi)置第時(shí)間-組織-配置文件-項(xiàng)目-URL-模板-View-常用對象-Form-i18n-CMD-異步比較內(nèi)容DjangoFlaskTornadoUliweb組織方式APPFree/Blueprint-APP配置文件py多種pyini配置文件語法pypypypy程序結(jié)構(gòu)創(chuàng)建cmd--cmdURL定義集中分散集中分散URL反向獲取√√√√模板繼承,受限繼承,受限繼承,繼承,模板調(diào)用手動手動手動套用/手動View函數(shù)/類函數(shù)/類類函數(shù)/類Url/View-Class1:11:11:1n:1request等對象參數(shù)導(dǎo)入綁定類注入/導(dǎo)入Form√√ORM√√比較總結(jié)(一)比較內(nèi)容DjangoFlaskTornadoUliweb數(shù)據(jù)庫遷移-/south-/Alembici18n√√√√命令行工具√√異步處理√websocket√比較總結(jié)(二)2013年個(gè)人小結(jié)Uliweb與其它框架比較Uliweb的特殊功能介紹可復(fù)用可配置可替換API如何簡單提供

的API的定義和使用方式?functions[FUNCTIONS]get_model

=

'uliweb.orm.get_model'get_object

=

'uliweb.orm.get_object'set_echo

=

'uliweb.orm.set_echo'from

uliweb

import

functionsUser

=

functions.get_model(‘user’)ModelModel能替換嗎?Model變了怎么方便處理?如何方便調(diào)試?配置化[MODELS]wikipage

=

'wiki.models.WikiPage'wikichangeset

=

'wiki.models.WikiChangeSet'get_model()from

uliweb

import

functionsUser

=

functions.get_model(‘user’)命令行uliweb

syncdb

-v[default]Creating[1/40,blog]blog_category...EXISTED[default]Creating[2/40,blog]blog...EXISTED[default]Creating[3/40,blog]blog_blog_tag_tags...EXISTED[default]Creating[4/40,blog]blog_tag...EXISTED[default]Creating[5/40,classes]

class_teacher...EXISTED[default]Creating[6/40,classes]

class_info...EXISTED命令行uliweb

dump

[appname,…]uliweb

dumptable

tablename[,

tablename]uliweb

reset

[appname,…]uliewb

resettable

tablename[,

tablename]uliweb

load

[appname,…]uliewb

loadtable

tablename[,

tablename]命令行uliweb

sqluliweb

sqltableCREATE

TABLE

forumcategory

(name

VARCHAR(100),description

TEXT,ordering

INTEGER,created_on

DATETIME,updated_on

DATETIME,id

INTEGER

NOT

NULL

AUTO_INCREMENT,PRIMARY

KEY

(id))CHARSET=utf8;命令行uliweb

sqlhtml命令行uliweb

sqldotAlembic集成uliweb

alembic

inituliweb

alembic

diffuliweb

alembic

upgrade調(diào)試set_echofunctions.set_echo(True,

time=0.001,

explain=True)===>>>

(d:/project/mywork/uliweb-git/uliweb/utils/generic:1916:objects)SELECT

tutorials.title,

tutorials.creator,

tutorials.create_date,

...,ments_count,

tutorials.idFROM

tutorialsWHERE

tutorials.deleted

=

false

ORDER

BY

tutorials.modified_date

DESCLIMIT

0,

10Explain:

id=1L,

select_type=u'SIMPLE',

table=u'tutorials',

type=u'ALL',possible_keys=None,

key=None,

key_len=None,

ref=None,

rows=8L,Extra=u'Using

where;

Using

filesort',===<<<

time

used

0.024000s調(diào)試SQLMonitorMiddle[MIDDLEWARES]sqlmonitor

='uliweb.contrib.orm.middle_sqlmonitor.SQLMonitorMiddle‘[ORM]SQL_MONITOR

=True======

sql

execution

count

10

</tutorial>

=======SELECT

tutorials.title,

tutorials.creator,

tutorials.create_date,t...

1

0.100SELECT

count(tutorials.id)

AS

tbl_row_count

FROM

tutorials

WHEREtu...

2

0.002SELECT

user.username,

user.nickname,

user. ,

user.password,use...

7

0.012模板如何方便 外部資源,不想寫<script>或<link>在模板繼承時(shí),如何處理新増資源模板如何調(diào)試?繼承,查找?定義1app/template_plugins/x.pydef

call(app,

var,

env,

version=None):from

uliweb

import

settingsa=

[]version

=

version

or

settings.UI_CONFIG.angularjs_versiona.append('angularjs/%s/angular-%s.min.js'

%

(version,version))a.append('jsutils/json2.js')return

{'toplinks':a}定義2settings.ini[TEMPLATE_USE]avalon

=

{'toplinks':['avalon/avalon.js','avalon/avalon_init.js']}使用use,

link‘uliweb.contrib.template’{{use“avalon”}}{{link

“test.js”}}<script

type="text/javascript"src="/static/avalon/avalon.js?ver=18"></script><script

type="text/javascript"src="/static/avalon/avalon_init.js?ver=18"></script>模板繼承的處理#layout.html<html><head>{{use

"bootstrap"}}</head><body>{{block

content}}{{end}}</body></html>#layout.html{{extend

“l(fā)ayout.html”}}{{block

content}}{{use

“avalon”}}{{end}}處理結(jié)果#layout.html<html><head>{{use

"bootstrap"}}{{use

“avalon”}}</head><body>{{block

content}}{{end}}</body></html>命令行調(diào)式uliweb

find

–t

templateD:\project\cc\

ks-master>uliweb

find

-t

index.htmlapps/newportal/templates/index.htmlapps/myportal/templates/index.htmlapps/Portal/templates/index.html命令行調(diào)式uliweb

find

–t

template

--treeD:\project\cc\

ks-master>uliweb

find

-t

index.html

--treeapps/newportal/templates/index.htmlTreeapps/theme/templates/theme/skeleton.html(extend)apps/theme/templates/theme/zebra.html->

(extend)apps/newportal/templates/index.html(include)apps/theme/templates/include/inc_userinfo.html(include)apps/theme/templates/include/inc_checklogin.html(include)apps/theme/templates/theme/utils.html(include)d:/project/mywork/plugs-git/plugs/ui/jquery/pnotify/templates/inc_show_flashes.html命令行調(diào)式uliwebfind

–t

template–block

–with-filenameBlockstitle

(apps/theme/templates/theme/zebra.html)meta

(apps/theme/templates/theme/skeleton.html)_css

(apps/newportal/templates/index.html)body_class

(apps/newportal/templates/index.html)before_header

(apps/theme/templates/theme/skeleton.html)header

(apps/theme/templates/theme/zebra.html)header_extra_class

(apps/theme/templates/theme/zebra.html)CSS,

JS合并<link

href="/static/bootstrap/2.2.0/bootstrap.min.css?ver=18"/><script

src="/static/bootstrap/2.2.0/js/bootstrap.min.js?ver=18"></script><link

href="/static/jquery/ui/css/redmond/jquery-ui-1.8.16.custom.css?ver=18"/><scriptsrc="/static/jquery/ui/js/jquery-ui-1.8.16.custom.min.js?ver=18"></script><script

src="/static/jquery/ui/js/jquery.ui.datepicker.zh.js?ver=18"></script><link

href="/static/theme/blove/index.css?ver=18"/><script

src="/static/jqutils/jquery.

.js?ver=18"></script><link

href="/static/poshytip/tip-

/tip-

.css?ver=18"/>初始CSS,

JS合并[

BINE]1

=

['jquery/jquery-1.7.2.min.js',

'jsutils/json2.js']#jquitls2

=

['jquery/ui/js/jquery-ui-1.8.16.custom.min.js','jquery/ui/js/jquery.ui.datepicker.zh.js','js

/

.js','poshytip/jquery.poshytip.js','jqutils/jqrselect.js','jqutils/jqutils.js','jqutils/jquery.hotkeys.js','jqutils/jquery.form.js','pnotify/1.2.0/jquery.pnotify.min.js',]配置CSS,

JS合并<link

href="/static/_cmb_3ab42e4ed430d339f6390330aa3e77b7.css?ver=15"/><scriptsrc="/static/_cmb_9ed3a8d3597e13abdd529ea9d4e6270f.js?ver=15"></script><link

href="/static/_cmb_88466a4a9313f6857d61aa632abf5054.css?ver=15"/><scriptsrc="/static/_cmb_c8a04bdfa7d2195d5f05c76a87a8767a.js?ver=15"></script>uliweb

exportstatic

–auto

staticGeneric如何快速處理CRUD操作流程定義為類AddViewEditViewDetailViewDeleteViewListView…操作流程定義為類AddView@expose(‘/blog’)class

BlogAdd(object):def

add(self):Blog

=functions.get_model(‘blog’)def

get_url(id):return

url_for(self.

class

.list)view

=

functions.AddView(Blog,

ok_url=get_url)return

view.run()操作流程定義為類form=make_form(Model)#根據(jù)Model自動生成Formif

method

==

‘GET’:return

{‘form’:form}#顯示頁面else:

#POSTif

form.validate(request.values):#表單校驗(yàn)

#成功save()#保存數(shù)據(jù)return

redirect(ok_url)#成功后跳轉(zhuǎn)else:return

{‘form’:form}#帶有出錯(cuò)信息返回顯示成功出錯(cuò)校驗(yàn)class

AddView(object):def

init

(self,

model,

ok_url=None,

ok_template=None,

form=None,success_msg=None,

fail_msg=None,

use_flash=True,data=None,

default_data=None,

fields=None,

form_cls=None,form_args=None,

static_fields=None,

hidden_fields=None,pre_save=None,

post_save=None,

post_created_form=None,layout=None,

file_replac

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論