diff --git a/conf/conf.py b/conf/conf.py index b732ab3a5b..5356fc99a4 100644 --- a/conf/conf.py +++ b/conf/conf.py @@ -16,10 +16,10 @@ public_path = 'public' max_file_size = 1000000 # generate schema (.txt files) -developer_mode = 1 +developer_mode = 0 # clear cache on refresh -auto_cache_clear = 1 +auto_cache_clear = 0 # email logs to admin (beta) admin_email_notification = 0 diff --git a/core/doctype/documentation_tool/documentation_tool.py b/core/doctype/documentation_tool/documentation_tool.py index 02e4b639a9..d22d5b0ab8 100644 --- a/core/doctype/documentation_tool/documentation_tool.py +++ b/core/doctype/documentation_tool/documentation_tool.py @@ -8,7 +8,7 @@ from __future__ import unicode_literals import webnotes import inspect, os, json, datetime, shutil from webnotes.modules import get_doc_path, get_module_path, scrub -from webnotes.utils import get_path, get_base_path +from webnotes.utils import get_path, get_base_path, cstr class DocType: def __init__(self, d, dl): @@ -36,6 +36,7 @@ def get_static_pages(): for repo in ("lib", "app"): for basepath, folders, files in os.walk(get_path(repo, "docs")): for fname in files: + fname = cstr(fname) if fname.endswith(".md"): fpath = get_path(basepath, fname) with open(fpath, "r") as docfile: @@ -78,6 +79,7 @@ def get_docs_for(docs, name): mydocs["_toc"] = [] dirname = os.path.dirname(obj.__file__) for fname in os.listdir(dirname): + fname = cstr(fname) fpath = os.path.join(dirname, fname) if os.path.isdir(fpath): # append if package @@ -176,6 +178,7 @@ def get_modules(for_module=None): prefix = prefix + ".py_modules." for basepath, folders, files in os.walk(module_path): for f in files: + f = cstr(f) if f.endswith(".py") and \ (not f.split(".")[0] in os.path.split(basepath)) and \ (not f.startswith("__")): @@ -436,6 +439,7 @@ def write_docs(data, build_sitemap=None, domain=None): domain = domain + "/" content = "" for fname in os.listdir(get_path("public", "docs")): + fname = cstr(fname) if fname.endswith(".html"): content += sitemap_link_xml % (domain + fname, get_timestamp(get_path("public", "docs", fname))) diff --git a/public/js/legacy/form.js b/public/js/legacy/form.js index a5b931df9e..30fc41318d 100644 --- a/public/js/legacy/form.js +++ b/public/js/legacy/form.js @@ -131,6 +131,7 @@ _f.Frm.prototype.watch_model_updates = function() { wn.model.on(me.doctype, "*", function(fieldname, value, doc) { // set input if(doc.name===me.docname) { + me.dirty(); me.fields_dict[fieldname] && me.fields_dict[fieldname].refresh(fieldname); me.refresh_dependency(); @@ -142,6 +143,7 @@ _f.Frm.prototype.watch_model_updates = function() { $.each(wn.model.get("DocField", {fieldtype:"Table", parent: me.doctype}), function(i, df) { wn.model.on(df.options, "*", function(fieldname, value, doc) { if(doc.parent===me.docname && doc.parentfield===df.fieldname) { + me.dirty(); me.fields_dict[df.fieldname].grid.set_value(fieldname, value, doc); me.script_manager.trigger(fieldname, doc.doctype, doc.name); } diff --git a/public/js/wn/form/control.js b/public/js/wn/form/control.js index cf0c057caf..7d30f2eb4f 100644 --- a/public/js/wn/form/control.js +++ b/public/js/wn/form/control.js @@ -76,7 +76,6 @@ wn.ui.form.Control = Class.extend({ set_model_value: function(value) { if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname, value, this.df.fieldtype)) { - this.frm && this.frm.dirty(); this.last_value = value; } }, diff --git a/public/js/wn/form/grid.js b/public/js/wn/form/grid.js index df17afd835..31f29ade7e 100644 --- a/public/js/wn/form/grid.js +++ b/public/js/wn/form/grid.js @@ -47,7 +47,9 @@ wn.ui.form.Grid = Class.extend({ this.docfields = wn.meta.get_docfields(this.doctype, this.frm.docname); this.display_status = wn.perm.get_field_display_status(this.df, this.frm.doc, this.perm); - + + if(this.display_status==="None") return; + if(!force && this.data_rows_are_same(data)) { // soft refresh this.header_row.refresh(); @@ -146,7 +148,8 @@ wn.ui.form.Grid = Class.extend({ return this.fieldinfo[fieldname]; }, set_value: function(fieldname, value, doc) { - this.grid_rows_by_docname[doc.name].refresh_field(fieldname); + if(this.display_status!=="None") + this.grid_rows_by_docname[doc.name].refresh_field(fieldname); }, add_new_row: function(idx, callback, show) { if(this.is_editable()) { diff --git a/public/js/wn/model/model.js b/public/js/wn/model/model.js index 8c93e4db3d..9f8a41fa9f 100644 --- a/public/js/wn/model/model.js +++ b/public/js/wn/model/model.js @@ -207,18 +207,19 @@ $.extend(wn.model, { }, trigger: function(fieldname, value, doc) { - var run = function(events) { + var run = function(events, event_doc) { $.each(events || [], function(i, fn) { - fn && fn(fieldname, value, doc); + fn && fn(fieldname, value, event_doc || doc); }); }; if(wn.model.events[doc.doctype]) { - // doctype-level - run(wn.model.events[doc.doctype]['*']); - + // field-level run(wn.model.events[doc.doctype][fieldname]); + + // doctype-level + run(wn.model.events[doc.doctype]['*']); }; }, diff --git a/requirements.txt b/requirements.txt index fee04c1c93..908fe0ea1a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,17 @@ -Jinja2==2.7.1 -MySQL-python==1.2.4 -chardet==2.1.1 -dropbox==1.6 -google-api-python-client==1.2 -httplib2==0.8 -markdown2==2.1.0 -pygeoip==0.2.7 -python-dateutil==2.1 -python-memcached==1.53 +Jinja2 +MarkupSafe +MySQL-python +chardet +dropbox +google-api-python-client +httplib2 +markdown2 +pygeoip +python-dateutil +python-memcached pytz==2013d -requests==1.2.3 -six==1.4.0 -termcolor==1.1.0 -Werkzeug==0.9.4 -gunicorn==18.0 \ No newline at end of file +requests +six +termcolor +Werkzeug +gunicorn \ No newline at end of file diff --git a/webnotes/install_lib/install.py b/webnotes/install_lib/install.py index 70a7123bbb..17a19563a9 100755 --- a/webnotes/install_lib/install.py +++ b/webnotes/install_lib/install.py @@ -13,6 +13,7 @@ import getpass from webnotes.model.db_schema import DbManager from webnotes.model.sync import sync_for +from webnotes.utils import cstr class Installer: def __init__(self, root_login, root_password=None, db_name=None, site=None): @@ -126,7 +127,6 @@ class Installer: _update_password("Administrator", webnotes.conf.get("admin_password") or password) webnotes.conn.commit() - def import_core_docs(self): install_docs = [ # profiles @@ -245,6 +245,7 @@ def install_fixtures(): print "Importing install fixtures..." for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")): for f in files: + f = cstr(f) if f.endswith(".json"): print "Importing " + f with open(os.path.join(basepath, f), "r") as infile: diff --git a/webnotes/model/bean.py b/webnotes/model/bean.py index 18f85596a2..e6c6c78960 100644 --- a/webnotes/model/bean.py +++ b/webnotes/model/bean.py @@ -404,7 +404,7 @@ class Bean: elif doc.fields.get(df.fieldname) is None: msg = _("Error") + ": " if doc.parentfield: - msg += _("Row") + (" # %d: " % doc.idx) + msg += _("Row") + (" # %s: " % (doc.idx,)) msg += _("Value missing for") + ": " + _(df.label) diff --git a/webnotes/model/sync.py b/webnotes/model/sync.py index 67ba987ee4..75f6a4b858 100644 --- a/webnotes/model/sync.py +++ b/webnotes/model/sync.py @@ -9,7 +9,7 @@ from __future__ import unicode_literals import webnotes import os from webnotes.modules.import_file import import_file -from webnotes.utils import get_path +from webnotes.utils import get_path, cstr def sync_all(force=0): sync_for("lib", force) @@ -32,6 +32,7 @@ def walk_and_sync(start_path, force=0, sync_everything = False): if sync_everything or (os.path.basename(os.path.dirname(path)) in document_type): for f in files: + f = cstr(f) if f.endswith(".txt"): doc_name = f.split(".txt")[0] if doc_name == os.path.basename(path): diff --git a/webnotes/modules/utils.py b/webnotes/modules/utils.py index 4bc2de2c8d..ba6e8aca10 100644 --- a/webnotes/modules/utils.py +++ b/webnotes/modules/utils.py @@ -4,6 +4,9 @@ from __future__ import unicode_literals import webnotes, os +import webnotes.modules +from webnotes.utils import cstr +from webnotes.modules import export_doc, get_module_path, scrub def listfolders(path, only_name=0): """ @@ -13,11 +16,12 @@ def listfolders(path, only_name=0): out = [] for each in os.listdir(path): + each = cstr(each) dirname = each.split(os.path.sep)[-1] fullpath = os.path.join(path, dirname) if os.path.isdir(fullpath) and not dirname.startswith('.'): - out.append(only_name and dirname or fullname) + out.append(only_name and dirname or fullpath) return out def switch_module(dt, dn, to, frm=None, export=None): diff --git a/webnotes/test_runner.py b/webnotes/test_runner.py index ed5b00f55f..2622d3be38 100644 --- a/webnotes/test_runner.py +++ b/webnotes/test_runner.py @@ -13,6 +13,7 @@ import unittest from webnotes.model.meta import has_field from webnotes.model.code import load_doctype_module, get_module_name from webnotes.model.doctype import get_link_fields +from webnotes.utils import cstr def make_test_records(doctype, verbose=0): @@ -148,6 +149,7 @@ def run_all_tests(verbose): for path, folders, files in os.walk("."): # print path for filename in files: + filename = cstr(filename) if filename.startswith("test_") and filename.endswith(".py"): print filename[:-3] webnotes.session.user = "Administrator" diff --git a/webnotes/translate.py b/webnotes/translate.py index d1d3013907..25bfe0bf2b 100644 --- a/webnotes/translate.py +++ b/webnotes/translate.py @@ -17,7 +17,7 @@ import json import re from csv import reader from webnotes.modules import get_doc_path -from webnotes.utils import get_base_path +from webnotes.utils import get_base_path, cstr def translate(lang=None): languages = [lang] @@ -114,6 +114,7 @@ def build_for_pages(path): if os.path.basename(os.path.dirname(basepath))=="page": messages_js, messages_py = [], [] for fname in files: + fname = cstr(fname) if fname.endswith('.js'): messages_js += get_message_list(os.path.join(basepath, fname)) if fname.endswith('.py'): @@ -165,6 +166,7 @@ def build_for_framework(path, mtype, with_doctype_names = False): messages = [] for (basepath, folders, files) in os.walk(path): for fname in files: + fname = cstr(fname) if fname.endswith('.' + mtype): messages += get_message_list(os.path.join(basepath, fname)) @@ -190,6 +192,7 @@ def build_from_doctype_code(path): messagespy = [] messagesjs = [] for fname in files: + fname = cstr(fname) if fname.endswith('py'): messagespy += get_message_list(os.path.join(basepath, fname)) if fname.endswith('js'): diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index fff4b3f08e..caa43dd4f1 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -13,7 +13,7 @@ from __future__ import unicode_literals #Imports import os, webnotes from datetime import datetime - +from webnotes.utils import cstr #Global constants verbose = 0 @@ -62,6 +62,7 @@ class BackupGenerator: def get_recent_backup(self, older_than): file_list = os.listdir(get_backup_path()) for this_file in file_list: + this_file = cstr(this_file) this_file_path = os.path.join(get_backup_path(), this_file) if not is_file_old(this_file_path, older_than): if "_files" in this_file_path: diff --git a/webnotes/utils/email_lib/receive.py b/webnotes/utils/email_lib/receive.py index fe101ee2c4..2d760c054b 100644 --- a/webnotes/utils/email_lib/receive.py +++ b/webnotes/utils/email_lib/receive.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now +from webnotes.utils import extract_email_id, convert_utc_to_user_timezone, now, cint class IncomingMail: """ @@ -130,7 +130,7 @@ class POP3Mailbox: def connect(self): import poplib - if self.settings.use_ssl: + if cint(self.settings.use_ssl): self.pop = poplib.POP3_SSL(self.settings.host) else: self.pop = poplib.POP3(self.settings.host) diff --git a/webnotes/utils/file_manager.py b/webnotes/utils/file_manager.py index fba49cbefe..36a671dcc7 100644 --- a/webnotes/utils/file_manager.py +++ b/webnotes/utils/file_manager.py @@ -74,7 +74,7 @@ def save_file(fname, content, dt, dn): file_size = check_max_file_size(content) temp_fname = write_file(content, files_path) fname = scrub_file_name(fname) - fpath = os.path.join(files_path, fname).encode("utf-8") + fpath = os.path.join(files_path, fname) fname_parts = fname.split(".", -1) main = ".".join(fname_parts[:-1]) @@ -96,10 +96,10 @@ def save_file(fname, content, dt, dn): fname = get_new_fname_based_on_version(files_path, main, extn, versions) # rename - os.rename(temp_fname, fpath) + os.rename(temp_fname, fpath.encode("utf-8")) else: # rename new file - os.rename(temp_fname, fpath) + os.rename(temp_fname, fpath.encode("utf-8")) f = webnotes.bean({ "doctype": "File Data", @@ -114,7 +114,12 @@ def save_file(fname, content, dt, dn): return f.doc def get_file_versions(files_path, main, extn): - return filter(lambda f: f.startswith(main) and f.endswith(extn), os.listdir(files_path)) + out = [] + for f in os.listdir(files_path): + f = cstr(f) + if f.startswith(main) and f.endswith(extn): + out.append(f) + return out def get_new_fname_based_on_version(files_path, main, extn, versions): versions.sort() @@ -190,6 +195,7 @@ def get_file(fname): # check in folders for basepath, folders, files in os.walk(files_path): if file_name in files: + file_name = cstr(file_name) file_path = os.path.join(basepath, file_name) break diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index b17c5ec7f3..f6722e892a 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -107,7 +107,9 @@ def report_errors(): errors = [("""
Time: %(modified)s
%(error)s""" % d) for d in webnotes.conn.sql("""select modified, error
- from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1 limit 10""", as_dict=True)]
+ from `tabScheduler Log` where DATEDIFF(NOW(), modified) < 1
+ and error not like '%%[Errno 110] Connection timed out%%'
+ limit 10""", as_dict=True)]
if errors:
sendmail_to_system_managers("ERPNext Scheduler Failure Report", ("""
diff --git a/webnotes/webutils.py b/webnotes/webutils.py
index ccac9e02b4..705195783a 100644
--- a/webnotes/webutils.py
+++ b/webnotes/webutils.py
@@ -190,6 +190,7 @@ def build_website_sitemap_config():
for path, folders, files in os.walk(basepath, followlinks=True):
if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates":
for fname in files:
+ fname = webnotes.utils.cstr(fname)
if fname.split(".")[-1] in ("html", "xml", "js", "css"):
options = get_options(path, fname)
config["pages"][options.link_name] = options