visitor through Ajax without cleaning rod and the barrel hitting the entire page. This is an application that allows modular design through a load helper; it is discussed in chapter three in the context of the wiki, in some detail, in the last chapter of the book.This sixth edition of the book describes the Web2py 2.4.1 and later versions.PrinciplePython programming usually follows these basic principles:D
Web2py -------------- example of using web2py to write django, web2pydjango
We created a data model and then presented the page this time.
1. Here is the control of the List page.
Here is the dal syntax
There are only two rows
The first line is to query all the problems, that is, the problem id is greater than 0.
The second row is the list of returned problems.
Here is the view
In view, we only need a for
We built the data model, and this time we're going to show the page.1, here is the control of the list pageHere's the DAL syntax.Only two linesThe first line is to query for all problems, that is, the ID of the problem is greater than 0The second line is the list of returned questionsHere is the viewWe only need a for loop in view to actually show all the data,But you need to use if to determine whether it is empty, attentive to deal with the situation is not emptyAttention:Logical label for eac
Web2py -------------- example of using web2py to write django, web2pydjango
Model Creation
Under models and where polls. py
The file content is as follows:
1 #-*-coding: UTF-8-*-2 pollsdb = DAL (uri = 'sqlite: // polls. db') 3 4 pollsdb. define_table ('Question ', 5 Field ('Question _ text', 'string', length = 200), 6 Field ('pub _ date', 'datetime '), 7 format = '% (question_text) s') 8 9 pollsdb. define_
Web2py -------------- example of using web2py to write django, web2pydjango
Follow the previous article to create an app named polls.
The file structure is as follows:
Then web2py automatically adds some code to it.
We need to remove some, such as the controllers and defualt. py index methods;
Corresponding to default/index.html under the views folder
In fa
Follow the previous article we created a new app called pollsThen the file structure is as followsThen web2py will automatically add some code to the inside.We need to remove some, such as this controllers, Defualt.py's index method;The corresponding is the Views folder under Default/index.htmlIn fact, it is not difficult to see Web2py controller and views of the corresponding relationshipThe file under the
Let's start with the well-known example of XI.The official example, I will give the code at the end;============================ Environment ===================The compiler uses VS code, the plugin is only Python,powershell, and the second plugin is not used in this tutorial,In order not to create confusion, do not use the version manager,PY version 2.7.12,System, WIN10Web2py version 2.14.6-stable+timestamp.2016.05.10.00.21.47Currently the latest versionIf you need to clean a bit, choose source
URL ing of web2py
1) ing of http: // 127.0.0.1: 8000/A/C/f.html
The URL ing rule of web2py maps http: // 127.0.0.1: 8000/A/C/f.html to the function (F) of controller (C) of application (). If function (f) does not exist, it is mapped to the function (INDEX) function of controller (c. If controller (c) does not exist, web2py maps to Controller (default) by def
Execution environment of a web2py ApplicationIn the execution environment where models, controllers, and views are located, the following objects have been imported by default:
Global Objects:Request, response, session, Cache
Navigation:Redirect, HTTP
Internationalization:T
Helpers:XML, URL, beautifya, B, beautify, body, BR, center, code, Div, em, embed, fieldset, form, H1, H2, H3, H4, H5, H6, head, HR, HTML, I, IFRAME, IMG, input, label, lege
Web2py is a free open-source Web framework written in Python. It is designed to develop Web applications quickly and quickly, with fast, scalable, secure, and portable database-driven applications. Follow the LGPLv3 protocol. The current available version is 2.3.2. Web2py can be run without configuration, installation, no other dependencies, or even on a USB drive.
Web2
Although web2py is recommended to use doctest to test the controller in the document, I am not familiar with doctest, and I only perform test coverage on the Controller layer. Although it is comprehensive, the test granularity is too large, the measurement is not detailed enough for me.
MeThe design habit is that the controller layer only performs simple call conversion, and the actual business logic is placed in the module layer (Note: not the model
In general, if you do a project, you may need the IDE, need good tools, web2py self-contained a web-based development tool, but not very good editor
The second can be pycharm, using Pycharm to create a web2py Web project that supports web2py way of code completion
Pycharm was previously known as a Django development tool, and later supported flask and, of c
Open to Pycharm Create the Web2py Project following:As shown above:Application Name:main represents the application created by the main stationUse local web2py: can be developed using the source code of the web2py you downloadBy default, WEB2PY will be downloaded from the official website.Startweb2py.pyThe initial laun
Learning Python was meant to be fun, but it was found that the language was as simple as people's, so that the block was close to human language, which brought great benefits to the developers themselves.Anyway is learning to play, I will start from the web framework web2py directly to learn.First, when we set up a good python environment, directly using Pycharm to operate the WEB2PY project, and then run,
Python Basicspython Language Web development Framework web2pyCreate a project:650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/B3/wKiom1WDAWrRgyGIAAErQBwh84g410.jpg "title=" Qq20150619012934.jpg "alt=" Wkiom1wdawrrgygiaaerqbwh84g410.jpg "/>Project Name set to MyWebAfter the creation is complete, it runs:650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/B4/wKiom1WDEFuzipI0AAILzoIZWxU024.jpg "title=" Qq20150619023815.jpg "alt=" Wkiom1wdefuzipi0aailzoizwxu024.jpg "/>Working
lightweight, open-source Python web framework that is part of the pylons project. Pyramid can only be run on Python 2.x or later versions of 2.4. There is no need to declare when using back-end databases, and some specific templating systems are not enforced at development time.: Http://www.pylonsproject.org/projects/pyramid/download5.DjangoDjango is an open-source web framework and uses MVC design patterns. It uses a very broad Python web framework, including many very useful libraries to acce
Python is a dynamic, object-oriented language. It was originally designed as an object-oriented language, and later added some more advanced features. In addition to the language itself, the Python standard library is well worth praising, and Python even has its own servers. In other ways, Python has plenty of free data libraries, free Web page template systems, and libraries that interact with Web servers that can be designed into your Web application.
In this article, we'll review the Pytho
Learn more, you can easily write your own code later.For various web frameworks, this is also the time to hit a foundation.Believe that the introduction of learning, PHP, Java Web Framework, are able to understand more deeply.defindex ():"""example action using the internationalization operator T and flash rendered by views/default/index.html or view s/generic.html If you need a simple wiki simply replace the lines below With:return Auth.wiki ()""" if notSession.counter:session.counter= 1Els
Book inventory plays an important key business data for warehouse management operations in books. Development at any age now promotes blood circulation in books, book types and update speed are just as fast rising.In order to ensure a foothold in the book industry, to ensure the correct purchase and inventory control and delivery. In order to avoid the backlog of
The code and tools usedSample site source + Framework + book pdf+ Chapter codeLink: https://pan.baidu.com/s/1miHjIYk Password: af35Environmentpython2.7Win7x64Sample Site SetupWswp-places.zip in the book site source codeFrames used by the Web2py_src.zip site1 Decompression Web2py_src.zip2 then go to the Web2py/applications directory3 Extract the Wswp-places.zip to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.