欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  资讯频道

基于python的web2pyTM Enterprise Web Framework

程序员文章站 2022-04-17 12:04:27
...

python的WEB框架很多,这回又出来一个新的WEB框架:  
    web2py是一个开源的全站式企业敏捷开发框架,能够打造安全的数据库驱动的WEB应用程序.它基于PYTHON,是一个很有创意的新型的MVC WEB开发框架.
    web2py不用安装,不用配置,不用碰 command line,没有其它相关依赖,开个浏览器就可以在线编程.甚至可以运行在USB驱动器上.
    web2py是一站式的解决方案,整个开发过程都可以在游览器上进行,提供了WEB版的在线开发,HTML模版编写,静态文件的上传,数据库的编写.其它的还有日志功能,以及一个自动化的admin接口.
    下载web2py运行后会自动打开一个ADMIN界面,这个界面即用来开发web2py.可以在线创建多个web项目,并且可以把项目打包成.war,方便布署;也可以将整个项目在线编译成.pyc

 

web2py 看起來确实相当先进。差別只在 community 、信任度上 . 如果早一年出來可能注目度会完全不同,现在出來的话要给点时间 

 

官方:

http://mdp.cti.depaul.edu/

 

 

基于python的web2pyTM Enterprise Web Framework

 

 

Why web2py?

 

  • No installation, No configuration, No console scripting, No dependencies. It even runs off a USB drive.
  • Everything is done through the provided web interface (including development, debugging, testing, maintenantce, deployment, internationalization, and database administration)
  • It is portable. Runs on Windows, Mac, Linux, Unix and some cellphones.
  • No limitation on licensing of the applications you develop. web2py even allows you to bytecode compile them and distribute in closed-sorce format (as long they do not contain web2py source code, read the license)
  • web2py prevents the most common types of vulnerabilities: Cross Site Scripting, Injection Flaws, and Malicious File Execution.
  • web2py includes libraries to handle JSON, AJAX, RSS, ATOM, CSV, RTF, XML, XML-RPC, REST, and WIKI markup and can talk to SQLite, MySQL, PostgreSQL and Oracle databases.
  • web2py can handle upload and download of very large files.
  • web2py also works with third party python libraries. For example, it can talk to Falsh via PyAMF. Here is a tutorial.
  • web2py guides the developer to follow well established software engineering patterns such as the Model-View-Controller and testing.
  • web2py is really easy to use. To develop with web2py you only need to know Python (the easiest of programing languages) and HTML (compare web2py with PHP).
  • web2py includes a web interafce to doctests (the python testing library) which tests functions in your application and generates real-time reports.
  • web2py has an appliances repository where new free and ready to use apps are added daily.

A taste of web2py


Consider the following complete application which consists a model (which describes the data representation): db.py

1.
2.
db=SQLDB('sqlite://images.db')
db.define_table('image',SQLField('file','upload'))

a controller (which describes the application logic and workflow): images_examples.py

1.
2.
3.
4.
def index():
    form=SQLFORM(db.image)
    if form.accepts(request.vars,session): response.flash='image uploaded'
    return dict(form=form)

and a view (which describes the data presenation): images_examples/index.html:

1.
2.
3.
{{extend 'layout.html'}}
<h1>Upload page</h2>
{{=form}}

What does it do?

  • Creates the database db in file 'images.db'
  • Creates the table 'image' which contains a field called 'file'. If the table exists but does not match the definition it is altered accordingly.
  • Creates a web-based database administrative interface for db.image
  • Creates a web page called index with upload form for db.image. Try it here
  • On upload the file is renamed in a secure way, saved, and the name of the file is stored in a new field db.image record.