Friday, October 28, 2016

Make a New App

Once the bench is installed, you will see two main folders, apps and sites. All the applications will be installed in apps.
To make a new application, go to your bench folder and run, bench new-app {app_name} and fill in details about the application. This will create a boilerplate application for you.
$ bench new-app library_management App Title (defaut: Lib Mgt): Library Management App Description: App for managing Articles, Members, Memberships and Transactions for Libraries App Publisher: Frappe App Email: info@frappe.io App Icon (default 'octicon octicon-file-directory'): octicon octicon-book App Color (default 'grey'): #589494 App License (default 'MIT'): GNU General Public License

App Structure
The application will be created in a folder called library_management and will have the following structure:
. ├── MANIFEST.in ├── README.md ├── library_management │   ├── __init__.py │   ├── config │   │   ├── __init__.py │   │   └── desktop.py │   ├── hooks.py │   ├── library_management │   │   └── __init__.py │   ├── modules.txt │   ├── patches.txt │   └── templates │   ├── __init__.py │   ├── generators │   │   └── __init__.py │   ├── pages │   │   └── __init__.py │   └── statics ├── license.txt ├── requirements.txt └── setup.py

  1. config folder contains application configuration info
  2. desktop.py is where desktop icons can be added to the Desk
  3. hooks.py is where integrations with the environment and other applications is mentioned.
  4. library_management (inner) is a module that is bootstrapped. In Frappe, a module is where model and controller files reside.
  5. modules.txt contains list of modules in the app. When you create a new module, it is required that you update it in this file.
  6. patches.txt is where migration patches are written. They are python module references using the dot notation.
  7. templates is the folder where web view templates are maintained. Templates for Login and other standard pages are bootstrapped in frappe.
  8. generators are where templates for models are maintained, where each model instance has a separte web route, for example a Blog Post where each post has its unique web url. In Frappe, the templating engine used is Jinja2
  9. pages is where single route templates are maintained. For example for a "/blog" type of page.

Frappé for Developers

A full-stack web framework based on Python and Javascript to help you build powerful business apps and nifty extensions.


An Application in Frappe is just a standard Python application. You can structure a Frappe Application the same way you structure a standard Python Application. For deployment, Frappe uses the standard Python Setuptools, so you can easily port and install the application on any machine.
Frappe Framework provides a WSGI interface and for development you can use the built-in Werkzeug server. For implementing in production, we recommend using nginx and gunicorn.

Frappe also has a multi-tenant architecture, grounds up. This means that you can run multiple "sites" in your setup, each could be serving a different set of applications and users. The database for each site is separate.

Easiest way to setup frappe on a Unix Like system is to use frappe-bench. Read the detailed instructions on how to install using Frappe Bench.
With Frappe Bench you will be able to setup and host multiple applications and sites and it will also setup a Python Virtualenv so that you can have an isolated environment to run your applications (and will not have version conflict with other development environments).
The bench command line tool will also be installed that will help you in development and management of the installation.