Pārlūkot izejas kodu

[minor] fixes for import conf

version-14
Anand Doshi pirms 11 gadiem
vecāks
revīzija
cd67dad3c5
22 mainītis faili ar 50 papildinājumiem un 45 dzēšanām
  1. +1
    -1
      core/doctype/doctype/doctype.py
  2. +3
    -2
      core/doctype/print_format/print_format.py
  3. +1
    -1
      core/doctype/profile/profile.py
  4. +3
    -3
      core/doctype/report/report.py
  5. +1
    -1
      core/page/update_manager/update_manager.py
  6. +3
    -5
      webnotes/__init__.py
  7. +1
    -1
      webnotes/boot.py
  8. +2
    -2
      webnotes/db.py
  9. +3
    -2
      webnotes/handler.py
  10. +4
    -4
      webnotes/install_lib/install.py
  11. +1
    -1
      webnotes/memc.py
  12. +3
    -2
      webnotes/model/doctype.py
  13. +2
    -1
      webnotes/modules/__init__.py
  14. +2
    -1
      webnotes/tests/__init__.py
  15. +2
    -1
      webnotes/translate.py
  16. +2
    -1
      webnotes/utils/backups.py
  17. +2
    -1
      webnotes/utils/email_lib/__init__.py
  18. +4
    -3
      webnotes/utils/email_lib/bulk.py
  19. +8
    -8
      webnotes/utils/email_lib/smtp.py
  20. +1
    -1
      webnotes/utils/file_manager.py
  21. +1
    -1
      webnotes/webutils.py
  22. +0
    -2
      website/templates/includes/login.js

+ 1
- 1
core/doctype/doctype/doctype.py Parādīt failu

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


+ 3
- 2
core/doctype/print_format/print_format.py Parādīt failu

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


+ 1
- 1
core/doctype/profile/profile.py Parādīt failu

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


+ 3
- 3
core/doctype/report/report.py Parādīt failu

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

+ 1
- 1
core/page/update_manager/update_manager.py Parādīt failu

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


+ 3
- 5
webnotes/__init__.py Parādīt failu

@@ -137,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
@@ -216,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:


+ 1
- 1
webnotes/boot.py Parādīt failu

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


+ 2
- 2
webnotes/db.py Parādīt failu

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


+ 3
- 2
webnotes/handler.py Parādīt failu

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


+ 4
- 4
webnotes/install_lib/install.py Parādīt failu

@@ -18,7 +18,7 @@ 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: ")
@@ -104,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()
@@ -127,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):


+ 1
- 1
webnotes/memc.py Parādīt failu

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


+ 3
- 2
webnotes/model/doctype.py Parādīt failu

@@ -21,7 +21,7 @@ import webnotes.model.doclist
from webnotes.utils import cint

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,


+ 2
- 1
webnotes/modules/__init__.py Parādīt failu

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


+ 2
- 1
webnotes/tests/__init__.py Parādīt failu

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



+ 2
- 1
webnotes/translate.py Parādīt failu

@@ -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 = {}


+ 2
- 1
webnotes/utils/backups.py Parādīt failu

@@ -185,7 +185,8 @@ backup_path = None
def get_backup_path():
global backup_path
if not backup_path:
import os, conf
import os
from webnotes import conf
# TODO Use get_storage_base_path
backup_path = os.path.join(os.path.dirname(os.path.abspath(conf.__file__)),
'public', 'backups')


+ 2
- 1
webnotes/utils/email_lib/__init__.py Parādīt failu

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


+ 4
- 3
webnotes/utils/email_lib/bulk.py Parādīt failu

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



+ 8
- 8
webnotes/utils/email_lib/smtp.py Parādīt failu

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


+ 1
- 1
webnotes/utils/file_manager.py Parādīt failu

@@ -140,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:


+ 1
- 1
webnotes/webutils.py Parādīt failu

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



+ 0
- 2
website/templates/includes/login.js Parādīt failu

@@ -123,7 +123,5 @@ login.show_forgot_password = function() {
}

login.set_message = function(message, color) {
wn.msgprint(html);
return;
$('#login_message').html(message).toggle(true);
}

Notiek ielāde…
Atcelt
Saglabāt