楼主: Lisrelchen
882 1

web2py:Complete Reference Manual, 6th Edition [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6306
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2016-2-6 09:33:27 |AI写论文
1论坛币
Table of Contents

I believe that the ability to easily build high quality web applications is of critical importance for the growth of a free and open society. This prevents the biggest players from monopolizing the flow of information.

Hence I started the web2py project in 2007, primarily as a teaching tool with the goal of making web development easier, faster, and more secure. Over time, it has managed to win the affection of thousands of knowledgeable users and hundreds of developers. Our collective effort has created one of the most full-featured Open Source Web Frameworks for enterprise web development.

As a result, in 2011, web2py won the Bossie Award for best Open Source Development Software, and in 2012 it won the Technology of the Year award from InfoWorld.

As you will learn in the following pages, web2py tries to lower the barrier of entry to web development by focusing on three main goals:

Ease of use. This means reducing the learning and deployment time as well as development and maintenance costs. This is why web2py is a full-stack framework without dependencies. It requires no installation and has no configuration files. Everything works out of the box, including a web server, database and a web-based IDE that gives access to all the main features. The API includes just 12 core objects, which are easy to work with and memorize. It can interoperate with most web servers, databases and all Python libraries.

Rapid development. Every function of web2py has a default behavior (which can be overridden). For example, as soon as you have specified your data models, you will have access to a web-based database administration panel. Also, web2py automatically generates forms for your data and it allows you to easily expose the data in HTML, XML, JSON, RSS, etc. web2py provides some high level widgets such as the wiki and the grid to rapidly build complex applications.

Security. The web2py Database Abstraction Layer (DAL) eliminates SQL Injections. The template language prevents Cross Site Scripting vulnerabilities. The forms generated by web2py provide field validation and block Cross Site Request Forgeries. Passwords are always stored hashed. Sessions are stored server-side by default to prevent Cookie Tampering. Session cookies are UUID to prevent Session Hijacking.

web2py is built from the user perspective and is constantly being optimized internally to become faster and leaner, whilst always maintainingbackwards compatibility.

web2py provides its users with the generous freedoms of the LGPL open source licence. If you benefit from it, I hope you will feel encouraged to pay it forward by contributing back to society in whatever form you choose.



关键词:Reference Complete Edition erence Manual critical database believe ability easily

沙发
Lisrelchen 发表于 2016-2-6 09:34:18
  1. Cookies
  2. web2py uses the Python cookies modules for handling cookies.

  3. Cookies from the browser are in request.cookies and cookies sent by the server are in response.cookies.

  4. You can set a cookie as follows:

  5. response.cookies['mycookie'] = 'somevalue'
  6. response.cookies['mycookie']['expires'] = 24 * 3600
  7. response.cookies['mycookie']['path'] = '/'
  8. The second line tells the browser to keep the cookie for 24 hours. The third line tells the browser to send the cookie back to any application (URL path) at the current domain. Note, if you do not specify a path for the cookie, the browser will assume the path of the URL that was requested, so the cookie will only be returned to the server when that same URL path is requested.

  9. The cookie can be made secure with:

  10. response.cookies['mycookie']['secure'] = True
  11. This tells the browser only to send the cookie back over HTTPS and not over HTTP.

  12. The cookie can be retrieved with:

  13. if request.cookies.has_key('mycookie'):
  14.     value = request.cookies['mycookie'].value
  15. Unless sessions are disabled, web2py, under the hood, sets the following cookie and uses it to handle sessions:

  16. response.cookies[response.session_id_name] = response.session_id
  17. response.cookies[response.session_id_name]['path'] = "/"
  18. Note, if a single application includes multiple subdomains, and you want to share the session across those subdomains (e.g., sub1.yourdomain.com, sub2.yourdomain.com, etc.), you must explicitly set the domain of the session cookie as follows:

  19. if not request.env.remote_addr in ['127.0.0.1', 'localhost']:
  20.     response.cookies[response.session_id_name]['domain'] = ".yourdomain.com"
  21. The above can be useful if, for example, you want to allow the user to remain logged in across subdomains.
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 22:57