Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PyCon2012ChinaBj-UliWeb
Search
Zoom.Quiet
October 20, 2012
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PyCon2012ChinaBj-UliWeb
http://cn.pycon.org/2012/schedulebj
Zoom.Quiet
October 20, 2012
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
200
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
180
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
150
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
150
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
140
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
160
PyCon2014China-Zhuhai-jeff
zoomquiet
0
150
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
180
DevFest2014-Zhuhai-Polymer
zoomquiet
0
480
Other Decks in Programming
See All in Programming
Claude Team Plan導入・ガイド
tk3fftk
0
220
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
150
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.6k
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
150
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
200
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
130
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
初めてのKubernetes 本番運用でハマった話
oku053
0
130
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
0
220
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
110
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.6k
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
220
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.7k
How to Talk to Developers About Accessibility
jct
2
420
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
640
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
How to Ace a Technical Interview
jacobian
281
24k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
370
Google's AI Overviews - The New Search
badams
0
1.1k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
500
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
Fireside Chat
paigeccino
42
4k
Crafting Experiences
bethany
1
230
Transcript
又一年,Uliweb发展纪事 李迎辉(
[email protected]
) 2012/10/20
Uliweb 转到github,同时在 code.google.com Uliweb-doc为专门的Uliweb文档项目 Plugs集成越来越多的组件,包括JQuery, Bootstrap, AngularJS等 Ver 0.1.6 Ver
0.1.4 在多个场合介绍Uliweb,如:《我们的开源项目》 UliwebZone项目,由何家胜部署在 http://uliweb.clkg.org 2012 cn.pycon.org 官网开发
UliwebZone的实战
Uliweb Plugs SQLAlchemy par - MarkDown解释器,加入bootstrap的语法支持 JQuery + 插件 AngularJS
论坛
论坛
教程
教程
教程
课程
课程
消息
管理
AngularJS
Javascript MVC框架 基于DOM的模板引擎 双向数据绑定 Dirty data check 模块化 控制器 Directive
HTML标签扩展 。。。
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class=“btn btn-primary” ng-click=“add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 装入相关的资源 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 设置App和Controller Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()">添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 绑定变量 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 绑定click事件 Template
{{use "angularjs"}} {{use "jquery"}} <div ng-app="AdminApp" id="ng-app" ng-controller="adminCtrl"> <form class="form-inline">
<input ng-model="topictype_name" placeholder="新课程分类名称"></input> <a class="btn btn-primary" ng-click="add_category()“>添加</a> </form> <table class="table table-bordered table-header"> <tbody> <tr ng-repeat="c in objects|orderBy:Ordering"> <td>{% c.name %}</td> <td> <a ng-click="edit_category(c.id)"> <i class="icon-edit" title="编辑"></i> </a> <a ng-click="remove_category(c.id)"> <i class="icon-remove" title="删除"></i> </a> </td> </tr> </tbody> </table> </div> 对objects进行循环 在DOM显示变量值(表达式) 绑定click事件进行编辑 绑定click事件进行删除 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 初始化angularjs标签 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 从后台装入数据(只会执行一次) Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 设置排序字段 Template
var app = angular.module('AdminApp', []).config(function ($interpolateProvider) { $interpolateProvider.startSymbol('{%'); $interpolateProvider.endSymbol('%}'); });
function adminCtrl($scope) { $.get('/class/admin/category/query') .success(function(data, status, headers, config){ $scope.objects = data.rows; $scope.$apply(); }); $scope.ordering = „name‟; $scope.add_category = function(){ var v = $('#field_category').val(); if (!v){ show_message('课程分类名称不能为空', 'error'); }else{ $.post('/class/admin/category/add', {'name':v}) .success(function(data){ if (data.success) $scope.objects.push(data.data); else show_message(data.message, 'error'); $scope.$apply(); }); } } } 添加数据处理,界面自动刷新 Template
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 导入常用函数
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 设置Class的URL
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 初始化
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 执行Class方法 前的处理
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 返回数据处理
#coding=utf8 from uliweb import expose, functions from uliweb.orm import get_model
@expose('/class/admin/category') class ClassCategoryAdminView(object): def __init__(self): self.model = get_model('class_category') def __begin__(self): functions.require_login() if not functions.has_role(request.user, 'superuser'): error("你没有权限访问此页面") def query(self): view = functions.ListView(self.model, pagination=False) return json(view.json()) def add(self): view = functions.AddView(self.model, success_data=True) return view.run(json_result=True) View 新增的处理
代码框架自动生成 处理常见的:List, Add, Edit, Delete, View 目前支持angularjs,html等以后还要支持其它模式
谢谢!明年再见!