This commit is contained in:
parent
081739b10a
commit
c10db3efae
8 changed files with 18 additions and 20 deletions
|
|
@ -118,7 +118,7 @@ def serve(port=8000, profile=False, site=None, sites_path='.'):
|
|||
from werkzeug.serving import run_simple
|
||||
|
||||
if profile:
|
||||
application = ProfilerMiddleware(application)
|
||||
application = ProfilerMiddleware(application, sort_by=('tottime', 'calls'))
|
||||
|
||||
if not os.environ.get('NO_STATICS'):
|
||||
application = SharedDataMiddleware(application, {
|
||||
|
|
|
|||
|
|
@ -20,11 +20,8 @@ def get_bootinfo():
|
|||
# user
|
||||
get_user(bootinfo)
|
||||
|
||||
# control panel
|
||||
cp = frappe.get_doc('Control Panel')
|
||||
|
||||
# system info
|
||||
bootinfo['control_panel'] = frappe._dict(cp.as_dict())
|
||||
bootinfo['control_panel'] = frappe.get_doc('Control Panel')
|
||||
bootinfo['sysdefaults'] = frappe.defaults.get_defaults()
|
||||
bootinfo['server_date'] = frappe.utils.nowdate()
|
||||
bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Outgoing Email Settings",
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@ class MClient(memcache.Client):
|
|||
|
||||
def get_value(self, key, builder=None):
|
||||
val = frappe.local.cache.get(key)
|
||||
if not val:
|
||||
if val is None:
|
||||
val = self.get(self.n(key))
|
||||
if not val and builder:
|
||||
if val is None and builder:
|
||||
val = builder()
|
||||
self.set_value(key, val)
|
||||
else:
|
||||
frappe.local.cache[key] = val
|
||||
return val
|
||||
|
||||
def delete_value(self, keys):
|
||||
|
|
|
|||
|
|
@ -12,13 +12,11 @@ class BaseDocument(object):
|
|||
self.update(d)
|
||||
|
||||
def __getattr__(self, key):
|
||||
try:
|
||||
return super(BaseDocument, self).__getattr__(key)
|
||||
except AttributeError:
|
||||
if not key.startswith("__") and key not in ("doctype", "_meta", "meta") and key in self.meta.get_valid_columns():
|
||||
return None
|
||||
else:
|
||||
raise
|
||||
# this is called only when something is not found in dir or __dict__
|
||||
if not key.startswith("__") and key not in ("doctype", "_meta", "meta") and key in self.meta.get_valid_columns():
|
||||
return None
|
||||
else:
|
||||
raise AttributeError, key
|
||||
|
||||
@property
|
||||
def meta(self):
|
||||
|
|
@ -100,7 +98,7 @@ class BaseDocument(object):
|
|||
return value
|
||||
|
||||
def get_valid_dict(self):
|
||||
d = {}
|
||||
d = frappe._dict()
|
||||
for fieldname in self.meta.get_valid_columns():
|
||||
d[fieldname] = self.get(fieldname)
|
||||
return d
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ def get_meta(doctype, cached=True):
|
|||
class Meta(Document):
|
||||
_metaclass = True
|
||||
_fields = {}
|
||||
default_fields = default_fields[1:]
|
||||
def __init__(self, doctype):
|
||||
super(Meta, self).__init__("DocType", doctype)
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ class Meta(Document):
|
|||
if self.name in ("DocType", "DocField", "DocPerm"):
|
||||
self._valid_columns = frappe.db.get_table_columns(self.name)
|
||||
else:
|
||||
self._valid_columns = default_fields[1:] + \
|
||||
self._valid_columns = self.default_fields + \
|
||||
[df.fieldname for df in self.get("fields") if df.fieldtype in type_map]
|
||||
|
||||
return self._valid_columns
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ def get_context(context):
|
|||
doc = frappe.get_doc("Style Settings", "Style Settings")
|
||||
prepare(doc)
|
||||
|
||||
return { "doc": doc.fields }
|
||||
return { "doc": doc.as_dict() }
|
||||
|
||||
def prepare(doc):
|
||||
from frappe.utils import cint, cstr
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def get_website_settings():
|
|||
for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
|
||||
"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
|
||||
"disable_signup"]:
|
||||
if getattr(settings, k, None):
|
||||
if hasattr(settings, k):
|
||||
context[k] = settings.get(k)
|
||||
|
||||
if not context.get("favicon"):
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ def get_sitemap_options(path):
|
|||
return frappe._dict(sitemap_options)
|
||||
|
||||
def build_sitemap_options(path):
|
||||
sitemap_options = frappe._dict(frappe.get_doc("Website Route", path).as_dict())
|
||||
sitemap_options = frappe.get_doc("Website Route", path).as_dict()
|
||||
home_page = get_home_page()
|
||||
|
||||
sitemap_config = frappe.get_doc("Website Template",
|
||||
sitemap_options.get("website_template"))
|
||||
sitemap_options.get("website_template")).as_dict()
|
||||
|
||||
# get sitemap config fields too
|
||||
for fieldname in ("base_template_path", "template_path", "controller",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue