Преглед на файлове

Merge branch 'master' of github.com:webnotes/wnframework into wsgi

Conflicts:
	requirements.txt
	webnotes/handler.py
	webnotes/install_lib/install.py
	webnotes/model/sync.py
	webnotes/webutils.py
version-14
Anand Doshi преди 11 години
родител
ревизия
c7253a830a
променени са 18 файла, в които са добавени 70 реда и са изтрити 39 реда
  1. +2
    -2
      conf/conf.py
  2. +5
    -1
      core/doctype/documentation_tool/documentation_tool.py
  3. +2
    -0
      public/js/legacy/form.js
  4. +0
    -1
      public/js/wn/form/control.js
  5. +5
    -2
      public/js/wn/form/grid.js
  6. +6
    -5
      public/js/wn/model/model.js
  7. +16
    -15
      requirements.txt
  8. +2
    -1
      webnotes/install_lib/install.py
  9. +1
    -1
      webnotes/model/bean.py
  10. +2
    -1
      webnotes/model/sync.py
  11. +5
    -1
      webnotes/modules/utils.py
  12. +2
    -0
      webnotes/test_runner.py
  13. +4
    -1
      webnotes/translate.py
  14. +2
    -1
      webnotes/utils/backups.py
  15. +2
    -2
      webnotes/utils/email_lib/receive.py
  16. +10
    -4
      webnotes/utils/file_manager.py
  17. +3
    -1
      webnotes/utils/scheduler.py
  18. +1
    -0
      webnotes/webutils.py

+ 2
- 2
conf/conf.py Целия файл

@@ -16,10 +16,10 @@ public_path = 'public'
max_file_size = 1000000 max_file_size = 1000000


# generate schema (.txt files) # generate schema (.txt files)
developer_mode = 1
developer_mode = 0


# clear cache on refresh # clear cache on refresh
auto_cache_clear = 1
auto_cache_clear = 0


# email logs to admin (beta) # email logs to admin (beta)
admin_email_notification = 0 admin_email_notification = 0


+ 5
- 1
core/doctype/documentation_tool/documentation_tool.py Целия файл

@@ -8,7 +8,7 @@ from __future__ import unicode_literals
import webnotes import webnotes
import inspect, os, json, datetime, shutil import inspect, os, json, datetime, shutil
from webnotes.modules import get_doc_path, get_module_path, scrub 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: class DocType:
def __init__(self, d, dl): def __init__(self, d, dl):
@@ -36,6 +36,7 @@ def get_static_pages():
for repo in ("lib", "app"): for repo in ("lib", "app"):
for basepath, folders, files in os.walk(get_path(repo, "docs")): for basepath, folders, files in os.walk(get_path(repo, "docs")):
for fname in files: for fname in files:
fname = cstr(fname)
if fname.endswith(".md"): if fname.endswith(".md"):
fpath = get_path(basepath, fname) fpath = get_path(basepath, fname)
with open(fpath, "r") as docfile: with open(fpath, "r") as docfile:
@@ -78,6 +79,7 @@ def get_docs_for(docs, name):
mydocs["_toc"] = [] mydocs["_toc"] = []
dirname = os.path.dirname(obj.__file__) dirname = os.path.dirname(obj.__file__)
for fname in os.listdir(dirname): for fname in os.listdir(dirname):
fname = cstr(fname)
fpath = os.path.join(dirname, fname) fpath = os.path.join(dirname, fname)
if os.path.isdir(fpath): if os.path.isdir(fpath):
# append if package # append if package
@@ -176,6 +178,7 @@ def get_modules(for_module=None):
prefix = prefix + ".py_modules." prefix = prefix + ".py_modules."
for basepath, folders, files in os.walk(module_path): for basepath, folders, files in os.walk(module_path):
for f in files: for f in files:
f = cstr(f)
if f.endswith(".py") and \ if f.endswith(".py") and \
(not f.split(".")[0] in os.path.split(basepath)) and \ (not f.split(".")[0] in os.path.split(basepath)) and \
(not f.startswith("__")): (not f.startswith("__")):
@@ -436,6 +439,7 @@ def write_docs(data, build_sitemap=None, domain=None):
domain = domain + "/" domain = domain + "/"
content = "" content = ""
for fname in os.listdir(get_path("public", "docs")): for fname in os.listdir(get_path("public", "docs")):
fname = cstr(fname)
if fname.endswith(".html"): if fname.endswith(".html"):
content += sitemap_link_xml % (domain + fname, content += sitemap_link_xml % (domain + fname,
get_timestamp(get_path("public", "docs", fname))) get_timestamp(get_path("public", "docs", fname)))


+ 2
- 0
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) { wn.model.on(me.doctype, "*", function(fieldname, value, doc) {
// set input // set input
if(doc.name===me.docname) { if(doc.name===me.docname) {
me.dirty();
me.fields_dict[fieldname] me.fields_dict[fieldname]
&& me.fields_dict[fieldname].refresh(fieldname); && me.fields_dict[fieldname].refresh(fieldname);
me.refresh_dependency(); 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) { $.each(wn.model.get("DocField", {fieldtype:"Table", parent: me.doctype}), function(i, df) {
wn.model.on(df.options, "*", function(fieldname, value, doc) { wn.model.on(df.options, "*", function(fieldname, value, doc) {
if(doc.parent===me.docname && doc.parentfield===df.fieldname) { if(doc.parent===me.docname && doc.parentfield===df.fieldname) {
me.dirty();
me.fields_dict[df.fieldname].grid.set_value(fieldname, value, doc); me.fields_dict[df.fieldname].grid.set_value(fieldname, value, doc);
me.script_manager.trigger(fieldname, doc.doctype, doc.name); me.script_manager.trigger(fieldname, doc.doctype, doc.name);
} }


+ 0
- 1
public/js/wn/form/control.js Целия файл

@@ -76,7 +76,6 @@ wn.ui.form.Control = Class.extend({
set_model_value: function(value) { set_model_value: function(value) {
if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname, if(wn.model.set_value(this.doctype, this.docname, this.df.fieldname,
value, this.df.fieldtype)) { value, this.df.fieldtype)) {
this.frm && this.frm.dirty();
this.last_value = value; this.last_value = value;
} }
}, },


+ 5
- 2
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.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.display_status = wn.perm.get_field_display_status(this.df, this.frm.doc,
this.perm); this.perm);

if(this.display_status==="None") return;
if(!force && this.data_rows_are_same(data)) { if(!force && this.data_rows_are_same(data)) {
// soft refresh // soft refresh
this.header_row.refresh(); this.header_row.refresh();
@@ -146,7 +148,8 @@ wn.ui.form.Grid = Class.extend({
return this.fieldinfo[fieldname]; return this.fieldinfo[fieldname];
}, },
set_value: function(fieldname, value, doc) { 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) { add_new_row: function(idx, callback, show) {
if(this.is_editable()) { if(this.is_editable()) {


+ 6
- 5
public/js/wn/model/model.js Целия файл

@@ -207,18 +207,19 @@ $.extend(wn.model, {
}, },
trigger: function(fieldname, value, doc) { trigger: function(fieldname, value, doc) {
var run = function(events) {
var run = function(events, event_doc) {
$.each(events || [], function(i, fn) { $.each(events || [], function(i, fn) {
fn && fn(fieldname, value, doc);
fn && fn(fieldname, value, event_doc || doc);
}); });
}; };
if(wn.model.events[doc.doctype]) { if(wn.model.events[doc.doctype]) {
// doctype-level
run(wn.model.events[doc.doctype]['*']);
// field-level // field-level
run(wn.model.events[doc.doctype][fieldname]); run(wn.model.events[doc.doctype][fieldname]);

// doctype-level
run(wn.model.events[doc.doctype]['*']);
}; };
}, },


+ 16
- 15
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 pytz==2013d
requests==1.2.3
six==1.4.0
termcolor==1.1.0
Werkzeug==0.9.4
gunicorn==18.0
requests
six
termcolor
Werkzeug
gunicorn

+ 2
- 1
webnotes/install_lib/install.py Целия файл

@@ -13,6 +13,7 @@ import getpass


from webnotes.model.db_schema import DbManager from webnotes.model.db_schema import DbManager
from webnotes.model.sync import sync_for from webnotes.model.sync import sync_for
from webnotes.utils import cstr


class Installer: class Installer:
def __init__(self, root_login, root_password=None, db_name=None, site=None): 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) _update_password("Administrator", webnotes.conf.get("admin_password") or password)
webnotes.conn.commit() webnotes.conn.commit()
def import_core_docs(self): def import_core_docs(self):
install_docs = [ install_docs = [
# profiles # profiles
@@ -245,6 +245,7 @@ def install_fixtures():
print "Importing install fixtures..." print "Importing install fixtures..."
for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")): for basepath, folders, files in os.walk(os.path.join("app", "startup", "install_fixtures")):
for f in files: for f in files:
f = cstr(f)
if f.endswith(".json"): if f.endswith(".json"):
print "Importing " + f print "Importing " + f
with open(os.path.join(basepath, f), "r") as infile: with open(os.path.join(basepath, f), "r") as infile:


+ 1
- 1
webnotes/model/bean.py Целия файл

@@ -404,7 +404,7 @@ class Bean:
elif doc.fields.get(df.fieldname) is None: elif doc.fields.get(df.fieldname) is None:
msg = _("Error") + ": " msg = _("Error") + ": "
if doc.parentfield: if doc.parentfield:
msg += _("Row") + (" # %d: " % doc.idx)
msg += _("Row") + (" # %s: " % (doc.idx,))
msg += _("Value missing for") + ": " + _(df.label) msg += _("Value missing for") + ": " + _(df.label)


+ 2
- 1
webnotes/model/sync.py Целия файл

@@ -9,7 +9,7 @@ from __future__ import unicode_literals
import webnotes import webnotes
import os import os
from webnotes.modules.import_file import import_file 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): def sync_all(force=0):
sync_for("lib", force) 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): if sync_everything or (os.path.basename(os.path.dirname(path)) in document_type):
for f in files: for f in files:
f = cstr(f)
if f.endswith(".txt"): if f.endswith(".txt"):
doc_name = f.split(".txt")[0] doc_name = f.split(".txt")[0]
if doc_name == os.path.basename(path): if doc_name == os.path.basename(path):


+ 5
- 1
webnotes/modules/utils.py Целия файл

@@ -4,6 +4,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals


import webnotes, os 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): def listfolders(path, only_name=0):
""" """
@@ -13,11 +16,12 @@ def listfolders(path, only_name=0):


out = [] out = []
for each in os.listdir(path): for each in os.listdir(path):
each = cstr(each)
dirname = each.split(os.path.sep)[-1] dirname = each.split(os.path.sep)[-1]
fullpath = os.path.join(path, dirname) fullpath = os.path.join(path, dirname)


if os.path.isdir(fullpath) and not dirname.startswith('.'): 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 return out


def switch_module(dt, dn, to, frm=None, export=None): def switch_module(dt, dn, to, frm=None, export=None):


+ 2
- 0
webnotes/test_runner.py Целия файл

@@ -13,6 +13,7 @@ import unittest
from webnotes.model.meta import has_field from webnotes.model.meta import has_field
from webnotes.model.code import load_doctype_module, get_module_name from webnotes.model.code import load_doctype_module, get_module_name
from webnotes.model.doctype import get_link_fields from webnotes.model.doctype import get_link_fields
from webnotes.utils import cstr




def make_test_records(doctype, verbose=0): def make_test_records(doctype, verbose=0):
@@ -148,6 +149,7 @@ def run_all_tests(verbose):
for path, folders, files in os.walk("."): for path, folders, files in os.walk("."):
# print path # print path
for filename in files: for filename in files:
filename = cstr(filename)
if filename.startswith("test_") and filename.endswith(".py"): if filename.startswith("test_") and filename.endswith(".py"):
print filename[:-3] print filename[:-3]
webnotes.session.user = "Administrator" webnotes.session.user = "Administrator"


+ 4
- 1
webnotes/translate.py Целия файл

@@ -17,7 +17,7 @@ import json
import re import re
from csv import reader from csv import reader
from webnotes.modules import get_doc_path 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): def translate(lang=None):
languages = [lang] languages = [lang]
@@ -114,6 +114,7 @@ def build_for_pages(path):
if os.path.basename(os.path.dirname(basepath))=="page": if os.path.basename(os.path.dirname(basepath))=="page":
messages_js, messages_py = [], [] messages_js, messages_py = [], []
for fname in files: for fname in files:
fname = cstr(fname)
if fname.endswith('.js'): if fname.endswith('.js'):
messages_js += get_message_list(os.path.join(basepath, fname)) messages_js += get_message_list(os.path.join(basepath, fname))
if fname.endswith('.py'): if fname.endswith('.py'):
@@ -165,6 +166,7 @@ def build_for_framework(path, mtype, with_doctype_names = False):
messages = [] messages = []
for (basepath, folders, files) in os.walk(path): for (basepath, folders, files) in os.walk(path):
for fname in files: for fname in files:
fname = cstr(fname)
if fname.endswith('.' + mtype): if fname.endswith('.' + mtype):
messages += get_message_list(os.path.join(basepath, fname)) messages += get_message_list(os.path.join(basepath, fname))
@@ -190,6 +192,7 @@ def build_from_doctype_code(path):
messagespy = [] messagespy = []
messagesjs = [] messagesjs = []
for fname in files: for fname in files:
fname = cstr(fname)
if fname.endswith('py'): if fname.endswith('py'):
messagespy += get_message_list(os.path.join(basepath, fname)) messagespy += get_message_list(os.path.join(basepath, fname))
if fname.endswith('js'): if fname.endswith('js'):


+ 2
- 1
webnotes/utils/backups.py Целия файл

@@ -13,7 +13,7 @@ from __future__ import unicode_literals
#Imports #Imports
import os, webnotes import os, webnotes
from datetime import datetime from datetime import datetime
from webnotes.utils import cstr


#Global constants #Global constants
verbose = 0 verbose = 0
@@ -62,6 +62,7 @@ class BackupGenerator:
def get_recent_backup(self, older_than): def get_recent_backup(self, older_than):
file_list = os.listdir(get_backup_path()) file_list = os.listdir(get_backup_path())
for this_file in file_list: for this_file in file_list:
this_file = cstr(this_file)
this_file_path = os.path.join(get_backup_path(), this_file) this_file_path = os.path.join(get_backup_path(), this_file)
if not is_file_old(this_file_path, older_than): if not is_file_old(this_file_path, older_than):
if "_files" in this_file_path: if "_files" in this_file_path:


+ 2
- 2
webnotes/utils/email_lib/receive.py Целия файл

@@ -3,7 +3,7 @@


from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes 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: class IncomingMail:
""" """
@@ -130,7 +130,7 @@ class POP3Mailbox:
def connect(self): def connect(self):
import poplib import poplib
if self.settings.use_ssl:
if cint(self.settings.use_ssl):
self.pop = poplib.POP3_SSL(self.settings.host) self.pop = poplib.POP3_SSL(self.settings.host)
else: else:
self.pop = poplib.POP3(self.settings.host) self.pop = poplib.POP3(self.settings.host)


+ 10
- 4
webnotes/utils/file_manager.py Целия файл

@@ -74,7 +74,7 @@ def save_file(fname, content, dt, dn):
file_size = check_max_file_size(content) file_size = check_max_file_size(content)
temp_fname = write_file(content, files_path) temp_fname = write_file(content, files_path)
fname = scrub_file_name(fname) 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) fname_parts = fname.split(".", -1)
main = ".".join(fname_parts[:-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) fname = get_new_fname_based_on_version(files_path, main, extn, versions)
# rename # rename
os.rename(temp_fname, fpath)
os.rename(temp_fname, fpath.encode("utf-8"))
else: else:
# rename new file # rename new file
os.rename(temp_fname, fpath)
os.rename(temp_fname, fpath.encode("utf-8"))


f = webnotes.bean({ f = webnotes.bean({
"doctype": "File Data", "doctype": "File Data",
@@ -114,7 +114,12 @@ def save_file(fname, content, dt, dn):
return f.doc return f.doc


def get_file_versions(files_path, main, extn): 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): def get_new_fname_based_on_version(files_path, main, extn, versions):
versions.sort() versions.sort()
@@ -190,6 +195,7 @@ def get_file(fname):
# check in folders # check in folders
for basepath, folders, files in os.walk(files_path): for basepath, folders, files in os.walk(files_path):
if file_name in files: if file_name in files:
file_name = cstr(file_name)
file_path = os.path.join(basepath, file_name) file_path = os.path.join(basepath, file_name)
break break


+ 3
- 1
webnotes/utils/scheduler.py Целия файл

@@ -107,7 +107,9 @@ def report_errors():
errors = [("""<p>Time: %(modified)s</p> errors = [("""<p>Time: %(modified)s</p>
<pre><code>%(error)s</code></pre>""" % d) for d in webnotes.conn.sql("""select modified, error <pre><code>%(error)s</code></pre>""" % 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: if errors:
sendmail_to_system_managers("ERPNext Scheduler Failure Report", (""" sendmail_to_system_managers("ERPNext Scheduler Failure Report", ("""


+ 1
- 0
webnotes/webutils.py Целия файл

@@ -190,6 +190,7 @@ def build_website_sitemap_config():
for path, folders, files in os.walk(basepath, followlinks=True): 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": if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates":
for fname in files: for fname in files:
fname = webnotes.utils.cstr(fname)
if fname.split(".")[-1] in ("html", "xml", "js", "css"): if fname.split(".")[-1] in ("html", "xml", "js", "css"):
options = get_options(path, fname) options = get_options(path, fname)
config["pages"][options.link_name] = options config["pages"][options.link_name] = options


Зареждане…
Отказ
Запис