{{extend 'layout.html'}}
It is a software engineering design that separates your code for the data representation (model), data presentation (view) and application logic (controller)
Try it. You would not trust me any other way.
I will just say that while all these systems are designed for developing web applications, web2py is a web applications itself, the competitors are not (except Zope). Moreover web2py is the only one that allows you to distribute byte-code compiled versions of your applications and the only one to provide a ticketing system to report errors.
Edit a controller default.py and type in it:
{{=CODE("""def hello: return dict(message="Hello")""")}}message here is a user defined variables that is being passed to the view.
web2py is not an AJAX framework but it works with AJAX frameworks. For examples scriptaculous works great with web2py. You may also use Web2py controllers to handle JSON request/response messages. Web2py also come with some a view called "web2py_ajax.html" included by "layout.html" that provides popup, collapse, fade effects and an "ajax" function that performs can asynchronous web2py connections (see the examples).
Yes. Views can extend and import other views in a tree like structure. The root of the tree is what we call a layout view. It is just an HTML file that you can edit as any other view using the administrative interface.
You just overwrite filed. None of your apps, including the administrative interface and the examples will be updated. If you want to update those. Unzip the new version and move your applications from old_web2py/applications/ to new_web2py/applications.
Use request.vars.your_variable both for GET and POST. If you try a variable that is not there, you get None, you do not get an Exception.
Use request.get_vars.your_variable
Use request.post_vars.your_variable
It should return a dictionary containing a definition of those variables you want to pass to the view. By default a function() in controller.py will be rendered by a view called controller/function.html. If this view is not found the generic.html view renders the variables in the dictionary.
A controller function can also return a string. In this case the view is not executed and the string is returned instead.
If you really must, yes, but the database administration part of the administrative interface will not work with it and the automatic generation of forms and tables will not work. You will miss about 50% of what web2py does for you. The web2py ORM was written from scratch in order to provide that functionality and its is faster than SQLAlchmey.
Yes and you should in a production environment! There are two ways. The easy way: install mod_proxy and send all your requests to the web2py web server. You would put something like this in your /etc/apache2/sites-available/default (some users have reported they also had to install mod_proxy_http to get the code below to work):
{{=CODE("""NameVirtualHost *:80or you can use mod_swgi. web2py is wsgi compliant. This requires that you use the source version of web2py and you read the mod_wsgi documentation.
Yes. The handler is in wsgihandler.py in the main web2py folder.
Yes. The handler is in fcgihandler.py in the main web2py folder.
Yes. Try web2py.py -h for more information. Notice that you want to run both HTTP and HTTPS you need to run two copies of web2py.
You can deploy multiple installations of web2py behind a NAT server that provides load balancing. The applications/ folder has to be NFS mounted and you need to backup that as well as your database. Do not use sqllite but connect to a postgresql database. Your bottleneck will be the database, as with any other web application. To avoid complications turn the administrative interface OFF when in production (do not give it a password) and set migrate=False.
Every application folder has a modules subfolder. You can place python modules in there. You can access them from models/views/controllers with {{=CODE("""import applications.[youapp].modules.[yourmodule] as [yourmodule]""")}}