diff --git a/conf/conf.py b/conf/conf.py index 0de8a0297a..b732ab3a5b 100644 --- a/conf/conf.py +++ b/conf/conf.py @@ -10,6 +10,7 @@ db_password = '%(db_password)s' # user attachments stored in files_path = 'public/files' +public_path = 'public' # max file attachment size (default 1MB) max_file_size = 1000000 diff --git a/core/doctype/doctype/doctype.py b/core/doctype/doctype/doctype.py index ea7bb6f4e6..817df0ee8c 100644 --- a/core/doctype/doctype/doctype.py +++ b/core/doctype/doctype/doctype.py @@ -77,7 +77,7 @@ class DocType: make_module_and_roles(self.doclist) from webnotes import conf - if (not webnotes.in_import) and getattr(conf, 'developer_mode', 0): + if (not webnotes.in_import) and conf.get('developer_mode') or 0: self.export_doc() self.make_controller_template() diff --git a/core/doctype/file_data/file_data.py b/core/doctype/file_data/file_data.py index e2645ac0e7..a1354435fe 100644 --- a/core/doctype/file_data/file_data.py +++ b/core/doctype/file_data/file_data.py @@ -9,6 +9,7 @@ naming for same name files: file.gif, file-1.gif, file-2.gif etc """ import webnotes, webnotes.utils, os +from webnotes import conf class DocType(): def __init__(self, d, dl): @@ -28,7 +29,7 @@ class DocType(): def on_trash(self): if self.doc.file_name and webnotes.conn.sql("""select count(*) from `tabFile Data` where file_name=%s""", self.doc.file_name)[0][0]==1: - path = webnotes.utils.get_path("public", "files", self.doc.file_name) + path = webnotes.utils.get_storage_path(conf.files_path, self.doc.file_name) if os.path.exists(path): os.remove(path) @@ -38,4 +39,4 @@ class DocType(): "write", self.doc.attached_to_name): webnotes.msgprint(webnotes._("No permission to write / remove."), raise_exception=True) - \ No newline at end of file + diff --git a/core/doctype/print_format/print_format.py b/core/doctype/print_format/print_format.py index 3124cad595..48f78fc869 100644 --- a/core/doctype/print_format/print_format.py +++ b/core/doctype/print_format/print_format.py @@ -2,7 +2,8 @@ # MIT License. See license.txt from __future__ import unicode_literals -import webnotes, conf, os +import webnotes, os +from webnotes import conf import webnotes.utils from webnotes.utils import get_base_path from webnotes.modules import get_doc_path @@ -29,7 +30,7 @@ class DocType: def export_doc(self): # export - if self.doc.standard == 'Yes' and getattr(conf, 'developer_mode', 0) == 1: + if self.doc.standard == 'Yes' and (conf.get('developer_mode') or 0) == 1: from webnotes.modules.export_file import export_to_files export_to_files(record_list=[['Print Format', self.doc.name]], record_module=self.doc.module) diff --git a/core/doctype/profile/profile.py b/core/doctype/profile/profile.py index 9485339cdf..2e9dd38f41 100644 --- a/core/doctype/profile/profile.py +++ b/core/doctype/profile/profile.py @@ -54,7 +54,7 @@ class DocType: """don't allow more than max users if set in conf""" from webnotes import conf # check only when enabling a user - if hasattr(conf, 'max_users') and self.doc.enabled and \ + if 'max_users' in conf and self.doc.enabled and \ self.doc.name not in ["Administrator", "Guest"] and \ cstr(self.doc.user_type).strip() in ("", "System User"): active_users = webnotes.conn.sql("""select count(*) from tabProfile diff --git a/core/doctype/report/report.py b/core/doctype/report/report.py index 74258eff84..ec4c9635db 100644 --- a/core/doctype/report/report.py +++ b/core/doctype/report/report.py @@ -2,8 +2,8 @@ # MIT License. See license.txt from __future__ import unicode_literals -import webnotes, conf -from webnotes import _ +import webnotes +from webnotes import conf, _ class DocType: def __init__(self, doc, doclist): @@ -30,7 +30,7 @@ class DocType: def export_doc(self): # export - if self.doc.is_standard == 'Yes' and getattr(conf, 'developer_mode', 0) == 1: + if self.doc.is_standard == 'Yes' and (conf.get('developer_mode') or 0) == 1: from webnotes.modules.export_file import export_to_files export_to_files(record_list=[['Report', self.doc.name]], record_module=webnotes.conn.get_value("DocType", self.doc.ref_doctype, "module")) \ No newline at end of file diff --git a/core/page/update_manager/update_manager.py b/core/page/update_manager/update_manager.py index 8a2a6fd2ae..ffd9ec11e3 100644 --- a/core/page/update_manager/update_manager.py +++ b/core/page/update_manager/update_manager.py @@ -10,7 +10,7 @@ from webnotes import _ @webnotes.whitelist(allow_roles=["System Manager", "Administrator"]) def update_this_app(): from webnotes import conf - if hasattr(conf, "expires_on"): + if "expires_on" in conf: return _("This feature is only applicable to self hosted instances") from webnotes.utils import execute_in_shell, cstr, get_base_path diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 25fb8a654a..9703f3706d 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -8,6 +8,7 @@ globals attached to webnotes module from __future__ import unicode_literals from werkzeug.local import Local +from werkzeug.exceptions import NotFound import os import json @@ -32,7 +33,7 @@ class _dict(dict): return _dict(super(_dict, self).copy()) def __getattr__(self, key): - return webnotes.local.get("key", None) + return local.get("key", None) def _(msg): """translate object in current lang, if exists""" @@ -73,6 +74,9 @@ message_log = local("message_log") lang = local("lang") def init(site=None): + if getattr(local, "initialised", None): + return + local.error_log = [] local.message_log = [] local.debug_log = [] @@ -80,6 +84,14 @@ def init(site=None): local.lang = "en" local.request_method = request.method if request else None local.conf = get_conf(site) + local.initialised = True + +def destroy(): + """closes connection and releases werkzeug local""" + webnotes.conn.close() + + from werkzeug.local import release_local + release_local(local) _memc = None mute_emails = False @@ -125,7 +137,7 @@ def errprint(msg): def log(msg): if not request: import conf - if getattr(conf, "logging", False): + if conf.get("logging") or False: print repr(msg) from utils import cstr @@ -183,8 +195,9 @@ def remove_file(path): if e.args[0]!=2: raise e -def connect(db_name=None, password=None): +def connect(db_name=None, password=None, site=None): import webnotes.db + init(site=site) local.conn = webnotes.db.Database(user=db_name, password=password) local.session = _dict({'user':'Administrator'}) local.response = _dict() @@ -203,12 +216,10 @@ logger = None def get_db_password(db_name): """get db password from conf""" - import conf - - if hasattr(conf, 'get_db_password'): + if 'get_db_password' in conf: return conf.get_db_password(db_name) - elif hasattr(conf, 'db_password'): + elif 'db_password' in conf: return conf.db_password else: @@ -521,13 +532,21 @@ def get_config(): return _config def get_conf(site): + # TODO Should be heavily cached! import conf from webnotes.utils import get_storage_base_path conf = _dict(conf.__dict__) if conf.sites_dir and site: - with open(os.path.join(get_storage_base_path(conf.sites_dir, site), 'site_config.json'), 'r') as f: - site_config = json.load(f) - site_config.update(conf.__dict__) - return _dict(site_config) + conf_path = os.path.join(get_storage_base_path(sites_dir=conf.sites_dir, hostname=site), 'site_config.json') + if os.path.exists(conf_path): + with open(conf_path, 'r') as f: + site_config = json.load(f) + site_config.update(conf) + site_config['site'] = site + return _dict(site_config) + + else: + raise NotFound() + else: return conf diff --git a/webnotes/app.py b/webnotes/app.py index b3a74c4421..74d627d900 100644 --- a/webnotes/app.py +++ b/webnotes/app.py @@ -8,6 +8,7 @@ sys.path.insert(0, 'lib') from werkzeug.wrappers import Request, Response from werkzeug.local import LocalManager from werkzeug.wsgi import SharedDataMiddleware +from werkzeug.exceptions import HTTPException from webnotes import get_config import mimetypes @@ -22,22 +23,29 @@ local_manager = LocalManager([webnotes.local]) def application(request): webnotes.local.request = request - webnotes.init(site=request.host) - - webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \ - for k, v in (request.form or request.args).iteritems() }) - - webnotes.local._response = Response() - try: - webnotes.http_request = webnotes.auth.HTTPRequest() - except webnotes.AuthenticationError, e: - pass - - if webnotes.form_dict.cmd: - webnotes.handler.handle() - else: - webnotes.webutils.render(webnotes.request.path[1:]) + webnotes.init(site=request.host) + + webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \ + for k, v in (request.form or request.args).iteritems() }) + + webnotes.local._response = Response() + + try: + webnotes.http_request = webnotes.auth.HTTPRequest() + except webnotes.AuthenticationError, e: + pass + + if webnotes.form_dict.cmd: + webnotes.handler.handle() + else: + webnotes.webutils.render(webnotes.request.path[1:]) + + if webnotes.conn: + webnotes.conn.close() + + except HTTPException, e: + return e return webnotes._response diff --git a/webnotes/boot.py b/webnotes/boot.py index 322a3d6d91..85dbd8e5bc 100644 --- a/webnotes/boot.py +++ b/webnotes/boot.py @@ -71,7 +71,7 @@ def get_bootinfo(): def load_conf_settings(bootinfo): from webnotes import conf for key in ['developer_mode']: - if hasattr(conf, key): bootinfo[key] = getattr(conf, key) + if key in conf: bootinfo[key] = conf.get(key) def add_allowed_pages(bootinfo): bootinfo.page_info = dict(webnotes.conn.sql("""select distinct parent, modified from `tabPage Role` diff --git a/webnotes/db.py b/webnotes/db.py index 024f792e6a..ad09b1299f 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -84,7 +84,7 @@ class Database: webnotes.errprint(query % values) except TypeError: webnotes.errprint([query, values]) - if getattr(conf, "logging", False)==2: + if (conf.get("logging") or False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log("with values:") @@ -97,7 +97,7 @@ class Database: if debug: self.explain_query(query) webnotes.errprint(query) - if getattr(conf, "logging", False)==2: + if (conf.get("logging") or False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log(">>>>") diff --git a/webnotes/handler.py b/webnotes/handler.py index 1c2953eb72..cb46608aee 100755 --- a/webnotes/handler.py +++ b/webnotes/handler.py @@ -175,7 +175,8 @@ def print_raw(): def make_logs(): """make strings for msgprint and errprint""" - import json, conf + import json + from webnotes import conf from webnotes.utils import cstr if webnotes.error_log: # webnotes.response['exc'] = json.dumps("\n".join([cstr(d) for d in webnotes.error_log])) @@ -184,7 +185,7 @@ def make_logs(): if webnotes.message_log: webnotes.response['_server_messages'] = json.dumps([cstr(d) for d in webnotes.message_log]) - if webnotes.debug_log and getattr(conf, "logging", False): + if webnotes.debug_log and conf.get("logging") or False: webnotes.response['_debug_messages'] = json.dumps(webnotes.debug_log) def print_zip(response): diff --git a/webnotes/install_lib/install.py b/webnotes/install_lib/install.py index 3c0dc2c8be..27c0d1047b 100755 --- a/webnotes/install_lib/install.py +++ b/webnotes/install_lib/install.py @@ -7,7 +7,8 @@ from __future__ import unicode_literals import os, sys, json -import webnotes, conf +import webnotes +from webnotes import conf import webnotes.db import getpass from webnotes.model.db_schema import DbManager @@ -17,15 +18,16 @@ class Installer: def __init__(self, root_login, root_password=None): if root_login: if not root_password: - root_password = getattr(conf, "root_password", None) + root_password = conf.get("root_password") or None if not root_password: root_password = getpass.getpass("MySQL root password: ") self.root_password = root_password - self.conn = webnotes.db.Database(user=root_login, password=root_password) - webnotes.conn=self.conn - webnotes.session= webnotes._dict({'user':'Administrator'}) + + webnotes.local.conn = self.conn + webnotes.local.session = webnotes._dict({'user':'Administrator'}) + self.dbman = DbManager(self.conn) def import_from_db(self, target, source_path='', password = 'admin', verbose=0): @@ -73,6 +75,8 @@ class Installer: # update admin password self.create_auth_table() self.update_admin_password(password) + + self.conn.close() return target @@ -100,7 +104,7 @@ class Installer: def update_admin_password(self, password): from webnotes.auth import _update_password webnotes.conn.begin() - _update_password("Administrator", getattr(conf, "admin_password", password)) + _update_password("Administrator", conf.get("admin_password") or password) webnotes.conn.commit() @@ -123,8 +127,8 @@ class Installer: webnotes.conn.begin() for d in install_docs: - doc = webnotes.doc(fielddata=d) - doc.insert() + bean = webnotes.bean(d) + bean.insert() webnotes.conn.commit() def set_all_patches_as_completed(self): diff --git a/webnotes/memc.py b/webnotes/memc.py index bb383c2649..42909f4e55 100644 --- a/webnotes/memc.py +++ b/webnotes/memc.py @@ -14,7 +14,7 @@ class MClient(memcache.Client): self.set(self.n(key), val) def get_value(self, key, builder=None): - if builder and getattr(conf, "auto_cache_clear", False): + if builder and conf.get("auto_cache_clear") or False: return builder() val = self.get(self.n(key)) diff --git a/webnotes/model/doctype.py b/webnotes/model/doctype.py index 7076cef665..c5e0d172ad 100644 --- a/webnotes/model/doctype.py +++ b/webnotes/model/doctype.py @@ -18,10 +18,10 @@ import webnotes import webnotes.model import webnotes.model.doc import webnotes.model.doclist -from webnotes.utils import cint +from webnotes.utils import cint, get_base_path doctype_cache = webnotes.local('doctype_doctype_cache') -docfield_types = webnotes.local('doctype_doctype_cache') +docfield_types = webnotes.local('doctype_docfield_types') # doctype_cache = {} # docfield_types = None @@ -272,7 +272,8 @@ def add_code(doctype, doclist): def add_embedded_js(doc): """embed all require files""" - import re, os, conf + import re, os + from webnotes import conf # custom script custom = webnotes.conn.get_value("Custom Script", {"dt": doc.name, @@ -280,7 +281,7 @@ def add_embedded_js(doc): doc.fields['__js'] = ((doc.fields.get('__js') or '') + '\n' + custom).encode("utf-8") def _sub(match): - fpath = os.path.join(os.path.dirname(conf.__file__), \ + fpath = os.path.join(get_base_path(), \ re.search('["\'][^"\']*["\']', match.group(0)).group(0)[1:-1]) if os.path.exists(fpath): with open(fpath, 'r') as f: diff --git a/webnotes/model/sync.py b/webnotes/model/sync.py index 82f284c02c..7392696263 100644 --- a/webnotes/model/sync.py +++ b/webnotes/model/sync.py @@ -10,6 +10,7 @@ import webnotes import os import conf from webnotes.modules.import_file import import_file +from webntoes.utils import get_base_path def sync_all(force=0): sync_for("lib", force) @@ -17,7 +18,7 @@ def sync_all(force=0): webnotes.clear_cache() def sync_for(folder, force=0, sync_everything = False): - return walk_and_sync(os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), + return walk_and_sync(os.path.join(get_base_path(), folder), force, sync_everything) def walk_and_sync(start_path, force=0, sync_everything = False): @@ -46,4 +47,4 @@ def walk_and_sync(start_path, force=0, sync_everything = False): webnotes.conn.commit() - return modules \ No newline at end of file + return modules diff --git a/webnotes/modules/__init__.py b/webnotes/modules/__init__.py index 921ad37577..b0d97a9408 100644 --- a/webnotes/modules/__init__.py +++ b/webnotes/modules/__init__.py @@ -5,7 +5,8 @@ from __future__ import unicode_literals """ Utilities for using modules """ -import webnotes, os, conf +import webnotes, os +from webnotes import conf lower_case_files_for = ['DocType', 'Page', 'Report', "Workflow", 'Module Def', 'Desktop Item', 'Workflow State', 'Workflow Action'] @@ -25,7 +26,7 @@ def get_module_path(module): """Returns path of the given module""" m = scrub(module) - app_path = os.path.dirname(conf.__file__) + app_path = webnotes.utils.get_base_path() if m in ('core', 'website'): return os.path.join(app_path, 'lib', m) @@ -49,4 +50,4 @@ def export_doc(doctype, name, module=None): write_document_file(webnotes.model.doc.get(doctype, name), module) def get_doctype_module(doctype): - return webnotes.conn.get_value('DocType', doctype, 'module') \ No newline at end of file + return webnotes.conn.get_value('DocType', doctype, 'module') diff --git a/webnotes/tests/__init__.py b/webnotes/tests/__init__.py index 15be347679..634d8f05c3 100644 --- a/webnotes/tests/__init__.py +++ b/webnotes/tests/__init__.py @@ -14,7 +14,8 @@ def insert_test_data(doctype, sort_fn=None): def get_test_doclist(doctype, name=None): """get test doclist, collection of doclists""" - import os, conf, webnotes + import os, webnotes + from webnotes import conf from webnotes.modules.utils import peval_doclist from webnotes.modules import scrub diff --git a/webnotes/translate.py b/webnotes/translate.py index 860eac48ba..43541a58c1 100644 --- a/webnotes/translate.py +++ b/webnotes/translate.py @@ -363,7 +363,8 @@ def google_translate(lang, infile, outfile): """translate objects using Google API. Add you own API key for translation""" data = get_all_messages_from_file(infile) - import requests, conf + import requests + from webnotes import conf old_translations = {} diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index bb21548b1d..5daf3d82d4 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -810,18 +810,26 @@ def filter_strip_join(some_list, sep): """given a list, filter None values, strip spaces and join""" return (cstr(sep)).join((cstr(a).strip() for a in filter(None, some_list))) -def get_path(*path): +def get_path(base=None, *path): + if not base: + base = get_base_path() import os - return os.path.join(get_base_path(), *path) + return os.path.join(base, *path) def get_base_path(): import conf import os return os.path.dirname(os.path.abspath(conf.__file__)) -def get_storage_base_path(sites_dir, hostname): +def get_storage_base_path(sites_dir=None, hostname=None): import os + if not sites_dir and not hostname: + sites_dir = conf.sites_dir + hostname = conf.site return os.path.join(sites_dir, hostname) + +def get_storage_path(*path): + return get_path(base=get_storage_base_path(), *path) def get_url(uri=None): url = get_request_site_address() diff --git a/webnotes/utils/backups.py b/webnotes/utils/backups.py index 9b25b3f63d..07421d4b6e 100644 --- a/webnotes/utils/backups.py +++ b/webnotes/utils/backups.py @@ -17,7 +17,7 @@ from datetime import datetime #Global constants verbose = 0 -import conf +from webnotes import conf #------------------------------------------------------------------------------- class BackupGenerator: """ @@ -70,8 +70,7 @@ class BackupGenerator: self.backup_path_db = this_file_path def zip_files(self): - # TODO use get_storage_base_path - files_path = os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), 'public', 'files') + files_path = webnotes.utils.get_storage_path(conf.files_path) cmd_string = """tar -cf %s %s""" % (self.backup_path_files, files_path) err, out = webnotes.utils.execute_in_shell(cmd_string) @@ -185,10 +184,9 @@ backup_path = None def get_backup_path(): global backup_path if not backup_path: - import os, conf + import os # TODO Use get_storage_base_path - backup_path = os.path.join(os.path.dirname(os.path.abspath(conf.__file__)), - 'public', 'backups') + backup_path = webnotes.utils.get_storage_path(conf.backup_path) return backup_path #------------------------------------------------------------------------------- diff --git a/webnotes/utils/email_lib/__init__.py b/webnotes/utils/email_lib/__init__.py index 726b0a9ec3..0374284947 100644 --- a/webnotes/utils/email_lib/__init__.py +++ b/webnotes/utils/email_lib/__init__.py @@ -2,7 +2,8 @@ # MIT License. See license.txt from __future__ import unicode_literals -import webnotes, conf +import webnotes +from webnotes import conf def sendmail_md(recipients, sender=None, msg=None, subject=None): """send markdown email""" diff --git a/webnotes/utils/email_lib/bulk.py b/webnotes/utils/email_lib/bulk.py index f9cf29d84d..e11caeecde 100644 --- a/webnotes/utils/email_lib/bulk.py +++ b/webnotes/utils/email_lib/bulk.py @@ -27,7 +27,7 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email', if hasattr(startup, 'get_monthly_bulk_mail_limit'): monthly_bulk_mail_limit = startup.get_monthly_bulk_mail_limit() else: - monthly_bulk_mail_limit = getattr(conf, 'monthly_bulk_mail_limit', 500) + monthly_bulk_mail_limit = conf.get('monthly_bulk_mail_limit') or 500 if this_month + len(recipients) > monthly_bulk_mail_limit: webnotes.msgprint("""Monthly Bulk Mail Limit (%s) Crossed""" % monthly_bulk_mail_limit, @@ -111,14 +111,15 @@ def unsubscribe(): def flush(from_test=False): """flush email queue, every time: called from scheduler""" - import webnotes, conf + import webnotes + from webnotes import conf from webnotes.utils.email_lib.smtp import SMTPServer, get_email smptserver = SMTPServer() auto_commit = not from_test - if webnotes.mute_emails or getattr(conf, "mute_emails", False): + if webnotes.mute_emails or conf.get("mute_emails") or False: webnotes.msgprint("Emails are muted") from_test = True diff --git a/webnotes/utils/email_lib/smtp.py b/webnotes/utils/email_lib/smtp.py index 5900a2cf21..bb316495f4 100644 --- a/webnotes/utils/email_lib/smtp.py +++ b/webnotes/utils/email_lib/smtp.py @@ -171,11 +171,11 @@ class EMail: if not self.sender: self.sender = webnotes.conn.get_value('Email Settings', None, - 'auto_email_id') or getattr(conf, 'auto_email_id', None) + 'auto_email_id') or conf.get('auto_email_id') or None if not self.sender: webnotes.msgprint("""Please specify 'Auto Email Id' \ in Setup > Email Settings""") - if not hasattr(conf, "expires_on"): + if not "expires_on" in conf: webnotes.msgprint("""Alternatively, \ you can also specify 'auto_email_id' in conf.py""") raise webnotes.ValidationError @@ -205,7 +205,7 @@ class EMail: def send(self, as_bulk=False): """send the message or add it to Outbox Email""" - if webnotes.mute_emails or getattr(conf, "mute_emails", False): + if webnotes.mute_emails or conf.get("mute_emails") or False: webnotes.msgprint("Emails are muted") return @@ -254,11 +254,11 @@ class SMTPServer: self.password = es.mail_password self.always_use_login_id_as_sender = es.always_use_login_id_as_sender else: - self.server = getattr(conf, "mail_server", "") - self.port = getattr(conf, "mail_port", None) - self.use_ssl = cint(getattr(conf, "use_ssl", 0)) - self.login = getattr(conf, "mail_login", "") - self.password = getattr(conf, "mail_password", "") + self.server = conf.get("mail_server") or "" + self.port = conf.get("mail_port") or None + self.use_ssl = cint(conf.get("use_ssl") or 0) + self.login = conf.get("mail_login") or "" + self.password = conf.get("mail_password") or "" @property def sess(self): diff --git a/webnotes/utils/file_manager.py b/webnotes/utils/file_manager.py index 4de0230cae..9d6c3c1334 100644 --- a/webnotes/utils/file_manager.py +++ b/webnotes/utils/file_manager.py @@ -3,9 +3,10 @@ from __future__ import unicode_literals import webnotes -import os, conf -from webnotes.utils import cstr, get_path, cint +import os +from webnotes.utils import cstr, cint, get_storage_path from webnotes import _ +from webnotes import conf class MaxFileSizeReachedError(webnotes.ValidationError): pass @@ -64,7 +65,7 @@ def get_uploaded_content(): def save_file(fname, content, dt, dn): import filecmp from webnotes.model.code import load_doctype_module - files_path = get_path("public", "files") + files_path = get_storage_path(conf.public_path) module = load_doctype_module(dt, webnotes.conn.get_value("DocType", dt, "module")) if hasattr(module, "attachments_folder"): @@ -102,7 +103,7 @@ def save_file(fname, content, dt, dn): f = webnotes.bean({ "doctype": "File Data", - "file_name": os.path.relpath(os.path.join(files_path, fname), get_path("public")), + "file_name": os.path.relpath(os.path.join(files_path, fname), get_storage_path(conf.public_path)), "attached_to_doctype": dt, "attached_to_name": dn, "file_size": file_size @@ -139,7 +140,7 @@ def scrub_file_name(fname): return fname def check_max_file_size(content): - max_file_size = getattr(conf, 'max_file_size', 1000000) + max_file_size = conf.get('max_file_size') or 1000000 file_size = len(content) if file_size > max_file_size: @@ -183,7 +184,7 @@ def get_file(fname): # read the file import os - files_path = get_path("public", "files") + files_path = get_storage_path(conf.files_path) file_path = os.path.join(files_path, file_name) if not os.path.exists(file_path): # check in folders diff --git a/webnotes/webutils.py b/webnotes/webutils.py index c1110affb7..3ae7c93996 100644 --- a/webnotes/webutils.py +++ b/webnotes/webutils.py @@ -28,7 +28,7 @@ def render_page(page_name): page_name = scrub_page_name(page_name) html = '' - if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0): + if not ('auto_cache_clear') and conf.auto_cache_clear or 0 in conf: html = webnotes.cache().get_value("page:" + page_name) from_cache = True diff --git a/website/templates/includes/login.js b/website/templates/includes/login.js index 6521d9ee98..4368628d39 100644 --- a/website/templates/includes/login.js +++ b/website/templates/includes/login.js @@ -125,5 +125,5 @@ login.show_forgot_password = function() { login.set_message = function(message, color) { wn.msgprint(message); return; - $('#login_message').html(message).toggle(true); + //$('#login_message').html(message).toggle(true); } \ No newline at end of file