Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Đồ họa - Thiết kế - Flash
Web to py enterprise web framework - p 8
Đang chuẩn bị liên kết để tải về tài liệu:
Web to py enterprise web framework - p 8
Trung Dũng
77
10
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
FORM SELF-SUBMISSION 55 1 2 3 4 5 6 7 def first(): form = FORM(INPUT(_name='visitor_name', requires=IS_NOT_EMPTY()), INPUT(_type='submit')) if form.accepts(request.vars, session): session.visitor_name = form.vars.visitor_name redirect(URL(r=request, f='second')) return dict(form=form) where we are saying that the FORM tag contains two INPUT tags. The attributes of the input tags are specified by the named arguments starting with underscore. The requires argument is not a tag attribute (because it does not start by underscore) but it sets a validator for the value of visitor name. The form object can be easily serialized in HTML by embedding it in the "default/first.html" view. 1 2 3 {{extend 'layout.html'}} What is your name? {{=form}} The. | FORM SELF-SUBMISSION 55 1 2 3 4 5 6 7 1 2 3 def first form FORM INPUT _name visitor_name requires IS_NOT_EMPTY INPUT _type submit if form.accepts request.vars session session.visitor_name form.vars.visitor_name redirect URL r request f second return dict form form where we are saying that the FORM tag contains two INPUT tags. The attributes of the input tags are specified by the named arguments starting with underscore. The requires argument is not a tag attribute because it does not start by underscore but it sets a validator for the value of visitor_name. The form object can be easily serialized in HTML by embedding it in the default first.html view. extend layout.html What is your name form The form.accepts method applies the validators. If the self-submitted form passes validation it stores the variables in the session and redirects as before. If the form does not pass validation error messages are inserted in the form and shown to the user shown below In the next section we will show how forms can be generated automatically from a model. 56 OVERVIEW 3.6 An Image Blog Here as another example we wish to create a web application that allows the administrator to post images and give them a name and allows the visitors of the web site to view the images and submit comments. As before create the new application from the site page in admin and navigate to the EDIT page We start by creating a model a representation of the persistent data in the application the images to upload their names and the comments . First you need to create edit a model file which for lack of imagination we call db.py . Models and controllers must have a .py extension since they are Python code. If the extension is not provided it is appended by WEB2py. Views instead have a .html extension since they mainly contain HTML code. Edit the db.py file by clicking the corresponding edit button 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 AN IMAGE BLOG 57 and enter the following db DAL sqlite
TÀI LIỆU LIÊN QUAN
Web to py enterprise web framework - p 1
Web to py enterprise web framework - p 4
Web to py enterprise web framework - p 5
Web to py enterprise web framework - p 6
Web to py enterprise web framework - p 7
Web to py enterprise web framework - p 8
Web to py enterprise web framework - p 9
Web to py enterprise web framework - p 10
Web to py enterprise web framework - p 11
Web to py enterprise web framework - p 13
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.