@@ -1,6 +1,6 @@ | |||||
## wnframework | ## wnframework | ||||
Full-stack web application framework that uses python/mysql on the server side and a tightly integrated client side library. Primarily built for erpnext. | |||||
Full-stack web application framework that uses Python/MySql on the server side and a tightly integrated client side library. Primarily built for erpnext. | |||||
Projects: [erpnext](http://erpnext.org) | [webnotes/erpnext](https://github.com/webnotes/erpnext) | Projects: [erpnext](http://erpnext.org) | [webnotes/erpnext](https://github.com/webnotes/erpnext) | ||||
@@ -8,15 +8,17 @@ Projects: [erpnext](http://erpnext.org) | [webnotes/erpnext](https://github.com/ | |||||
To start a new project, in the application root: | To start a new project, in the application root: | ||||
1. Set wnframework folder as the `lib` folder. | |||||
1. Copy the following files from lib/conf: `index.cgi`, `build.json`, `conf.py`. | |||||
1. Create folders `js`, `css`, `modules`, `modules/startup`. These folders contain the js, css assets and modules folder is where all the new application modules will be created. | |||||
1. Update database name/password in conf.py and set modules folder to "modules". | |||||
1. Run `$ lib/wnf.py --install dbrootpassword newdbname lib/conf/Framework.sql` to install a fresh database. | |||||
1. Create `app.js` containing basic application info (see `lib/conf`) | |||||
1. Create empty files `__init__.py` and `event_handlers.py` in `modules/startup`. This is where you write all events (like, onlogin, onlogout etc) | |||||
1. Run `$ lib/wnf.py -b` to build js and css assets from `build.json`. | |||||
1. Go to the browser and go to your application folder. The admin username is "Administrator" and password is "admin" | |||||
Note: | |||||
1. wnframework must be called as `lib` | |||||
1. your application must be called as `app` | |||||
Finally: | |||||
$ git clone git@github.com:webnotes/wnframework lib | |||||
$ git clone git@github.com:webnotes/[your app] app | |||||
$ lib/wnf.py --make_conf | |||||
$ lib/wnf.py --reinstall | |||||
enjoy! | enjoy! | ||||
@@ -5,8 +5,8 @@ from __future__ import unicode_literals | |||||
# app configuration | # app configuration | ||||
# database config | # database config | ||||
db_name = 'yourdbname' | |||||
db_password = 'yourdbpassword' | |||||
db_name = '%(db_name)s' | |||||
db_password = '%(db_password)s' | |||||
# user attachments stored in | # user attachments stored in | ||||
files_path = 'public/files' | files_path = 'public/files' | ||||
@@ -15,10 +15,10 @@ files_path = 'public/files' | |||||
max_file_size = 1000000 | max_file_size = 1000000 | ||||
# generate schema (.txt files) | # generate schema (.txt files) | ||||
developer_mode = 0 | |||||
developer_mode = 1 | |||||
# clear cache on refresh | # clear cache on refresh | ||||
auto_cache_clear = 0 | |||||
auto_cache_clear = 1 | |||||
# email logs to admin (beta) | # email logs to admin (beta) | ||||
admin_email_notification = 0 | admin_email_notification = 0 | ||||
@@ -139,6 +139,9 @@ def setup_options(): | |||||
parser.add_option('--install_fresh', nargs=1, metavar = "NEW_DB_NAME", | parser.add_option('--install_fresh', nargs=1, metavar = "NEW_DB_NAME", | ||||
help="install fresh db") | help="install fresh db") | ||||
parser.add_option('--reinstall', default=False, action="store_true", | |||||
help="install fresh db in db_name specified in conf.py") | |||||
parser.add_option('--make_demo', default=False, action="store_true", | parser.add_option('--make_demo', default=False, action="store_true", | ||||
help="install in database 'demo'") | help="install in database 'demo'") | ||||
@@ -276,6 +279,9 @@ def setup_options(): | |||||
parser.add_option("--reset_perms", default=False, action="store_true", | parser.add_option("--reset_perms", default=False, action="store_true", | ||||
help="Reset permissions for all doctypes.") | help="Reset permissions for all doctypes.") | ||||
parser.add_option("--make_conf", default=False, action="store_true", | |||||
help="Create new conf.py file") | |||||
return parser.parse_args() | return parser.parse_args() | ||||
def run(): | def run(): | ||||
@@ -333,7 +339,7 @@ def run(): | |||||
webnotes.connect(options.db_name, options.password) | webnotes.connect(options.db_name, options.password) | ||||
else: | else: | ||||
webnotes.connect(options.db_name) | webnotes.connect(options.db_name) | ||||
elif not any([options.install, options.pull, options.install_fresh]): | |||||
elif not any([options.install, options.pull, options.install_fresh, options.reinstall, options.make_conf]): | |||||
webnotes.connect(conf.db_name) | webnotes.connect(conf.db_name) | ||||
if options.pull: | if options.pull: | ||||
@@ -397,6 +403,12 @@ def run(): | |||||
inst = Installer('root') | inst = Installer('root') | ||||
inst.import_from_db(options.install_fresh, verbose = 1) | inst.import_from_db(options.install_fresh, verbose = 1) | ||||
elif options.reinstall: | |||||
from webnotes.install_lib.install import Installer | |||||
inst = Installer('root') | |||||
import conf | |||||
inst.import_from_db(conf.db_name, verbose = 1) | |||||
elif options.make_demo: | elif options.make_demo: | ||||
import utilities.demo.make_demo | import utilities.demo.make_demo | ||||
utilities.demo.make_demo.make() | utilities.demo.make_demo.make() | ||||
@@ -507,6 +519,27 @@ def run(): | |||||
webnotes.reset_perms(d) | webnotes.reset_perms(d) | ||||
except: | except: | ||||
pass | pass | ||||
elif options.make_conf: | |||||
if os.path.exists("conf.py"): | |||||
os.system("mv conf.py conf.py.bak") | |||||
with open("lib/conf/conf.py", "r") as confsrc: | |||||
confstr = confsrc.read() | |||||
db_name = raw_input("Database Name: ") | |||||
if not db_name: | |||||
print "Database Name Required" | |||||
return | |||||
db_password = raw_input("Database Password: ") | |||||
if not db_password: | |||||
print "Database Name Required" | |||||
return | |||||
with open("conf.py", "w") as conftar: | |||||
conftar.write(confstr % {"db_name": db_name, "db_password": db_password }) | |||||
if __name__=='__main__': | if __name__=='__main__': | ||||