Kaynağa Gözat

[import/export] [minor] cleanup

version-14
Rushabh Mehta 11 yıl önce
ebeveyn
işleme
d74a13a4f1
3 değiştirilmiş dosya ile 32 ekleme ve 28 silme
  1. +9
    -12
      README.md
  2. +19
    -0
      core/page/data_import_tool/data_import_tool.py
  3. +4
    -16
      wnf.py

+ 9
- 12
README.md Dosyayı Görüntüle

@@ -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


+ 19
- 0
core/page/data_import_tool/data_import_tool.py Dosyayı Görüntüle

@@ -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))

+ 4
- 16
wnf.py Dosyayı Görüntüle

@@ -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


Yükleniyor…
İptal
Kaydet