diff --git a/README.md b/README.md index a6eb09709d..fa88665206 100644 --- a/README.md +++ b/README.md @@ -10,27 +10,24 @@ To start a new project, in the application root: Install: -1. Install webnotes and treemapper +1. Go to the project folder +1. Install webnotes and your app: $ 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 + $ lib/wnf.py --build -1. Setup Apache Conf +1. Setup Apache Conf from `conf/apache.conf` + - Allow cgi to handle `.py` files + - Rewrite to make clean urls + - Note: the document root is the `public` folder in your project folder + +1. Give ownership of the project folder to apache user (`www-data` or `apache`) to make .pyc files and upload files. enjoy! - -#### Export - -Before pushing, export install fixtures - - $ lib/wnf.py --export_doclist "Website Settings" - app/startup/website_settings.json - $ lib/wnf.py --export_doclist "Style Settings" - app/startup/style_settings.json - $ lib/wnf.py --export_csv "Tree Species" app/startup/Tree_Species.csv - $ lib/wnf.py --export_csv "Tree Family" app/startup/Tree_Family.csv - ## wnf.py `$ lib/wnf.py --help` for more info diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index d6140890c6..c8ef2cc984 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -478,3 +478,22 @@ def import_file_by_path(path): print "Importing " + path with open(path, "r") as infile: upload(rows = read_csv_content(infile.read())) + +def export_csv(doctype, path): + with open(path, "w") as csvfile: + get_template(doctype=doctype, all_doctypes="Yes", with_data="Yes") + csvfile.write(webnotes.response.result) + +def export_json(doctype, name, path): + from webnotes.handler import json_handler + if not name or name=="-": + name = doctype + with open(path, "w") as outfile: + doclist = [d.fields for d in webnotes.bean(doctype, name).doclist] + for d in doclist: + if d.get("parent"): + del d["parent"] + del d["name"] + d["__islocal"] = 1 + outfile.write(json.dumps(doclist, default=json_handler, indent=1, sort_keys=True)) + \ No newline at end of file diff --git a/wnf.py b/wnf.py index b677995c63..b2fb8c18fe 100755 --- a/wnf.py +++ b/wnf.py @@ -523,24 +523,12 @@ def run(): write_static() elif options.export_doclist: - import json - from webnotes.handler import json_handler - args = list(options.export_doclist) - if args[1]=="-": args[1] = args[0] - with open(args[2], "w") as outfile: - doclist = [d.fields for d in webnotes.bean(args[0], args[1]).doclist] - for d in doclist: - if d.get("parent"): - del d["parent"] - del d["name"] - d["__islocal"] = 1 - outfile.write(json.dumps(doclist, default=json_handler, indent=1, sort_keys=True)) + from core.page.data_import_tool.data_import_tool import export_json + export_json(*list(options.export_doclist)) elif options.export_csv: - from core.page.data_import_tool.data_import_tool import get_template - with open(options.export_csv[1], "w") as csvfile: - get_template(doctype=options.export_csv[0], all_doctypes="Yes", with_data="Yes") - csvfile.write(webnotes.response.result) + from core.page.data_import_tool.data_import_tool import export_csv + export_csv(*options.export_csv) elif options.import_doclist: import json