Applications
Applications developed in web2py are composed of the following parts:
- models describe a representation of the data as database tables and relations between tables.
- controllers describe the application logic and workflow.
- views describe how data should be presented to the user using HTML and JavaScript.
- languages describe how to translate strings in the application into various supported languages.
- static files do not require processing (e.g. images, CSS stylesheets, etc).
- ABOUT and LICENSE documents are self-explanatory.
- errors store error reports generated by the application.
- sessions store information related to each particular user.
- databases store SQLite databases and additional table information.
- cache store cached application items.
- modules are other optional Python modules.
- private files are accessed by the controllers but not directly by the developer.
- uploads files are accessed by the models but not directly by the developer (e.g., files uploaded by users of the application).
- tests is a directory for storing test scripts, fixtures and mocks.
Models, views, controllers, languages, and static files are accessible via the web administration [design] interface. ABOUT, README, and errors are also accessible via the administration interface through the corresponding menu items. Sessions, cache, modules and private files are accessible to the applications but not via the administration interface.
Everything is neatly organized in a clear directory structure that is replicated for every installed web2py application, although the user never needs to access the filesystem directly:
__init__.py ABOUT LICENSE models views
controllers modules private tests cron
cache errors upload sessions static
“__init__.py” is an empty file which is required in order to allow Python (and web2py) to import the modules in the modules
directory.
Notice that the admin application simply provides a web interface to web2py applications on the server file system. web2py applications can also be created and developed from the command-line or your preferred text editor/IDE; you don’t have to use the browser admin interface. A new application can be created manually by replicating the above directory structure under ,e.g., “applications/newapp/“ (or simply untar the welcome.w2p
file into your new application directory). Application files can also be created and edited from the command-line without having to use the web admin interface.