@@ -118,7 +118,7 @@ def serve(port=8000, profile=False, site=None, sites_path='.'): | |||||
from werkzeug.serving import run_simple | from werkzeug.serving import run_simple | ||||
if profile: | if profile: | ||||
application = ProfilerMiddleware(application) | |||||
application = ProfilerMiddleware(application, sort_by=('tottime', 'calls')) | |||||
if not os.environ.get('NO_STATICS'): | if not os.environ.get('NO_STATICS'): | ||||
application = SharedDataMiddleware(application, { | application = SharedDataMiddleware(application, { | ||||
@@ -20,11 +20,8 @@ def get_bootinfo(): | |||||
# user | # user | ||||
get_user(bootinfo) | get_user(bootinfo) | ||||
# control panel | |||||
cp = frappe.get_doc('Control Panel') | |||||
# system info | # 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['sysdefaults'] = frappe.defaults.get_defaults() | ||||
bootinfo['server_date'] = frappe.utils.nowdate() | bootinfo['server_date'] = frappe.utils.nowdate() | ||||
bootinfo["send_print_in_body_and_attachment"] = frappe.db.get_value("Outgoing Email Settings", | 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): | def get_value(self, key, builder=None): | ||||
val = frappe.local.cache.get(key) | val = frappe.local.cache.get(key) | ||||
if not val: | |||||
if val is None: | |||||
val = self.get(self.n(key)) | val = self.get(self.n(key)) | ||||
if not val and builder: | |||||
if val is None and builder: | |||||
val = builder() | val = builder() | ||||
self.set_value(key, val) | self.set_value(key, val) | ||||
else: | |||||
frappe.local.cache[key] = val | |||||
return val | return val | ||||
def delete_value(self, keys): | def delete_value(self, keys): | ||||
@@ -12,13 +12,11 @@ class BaseDocument(object): | |||||
self.update(d) | self.update(d) | ||||
def __getattr__(self, key): | 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 | @property | ||||
def meta(self): | def meta(self): | ||||
@@ -100,7 +98,7 @@ class BaseDocument(object): | |||||
return value | return value | ||||
def get_valid_dict(self): | def get_valid_dict(self): | ||||
d = {} | |||||
d = frappe._dict() | |||||
for fieldname in self.meta.get_valid_columns(): | for fieldname in self.meta.get_valid_columns(): | ||||
d[fieldname] = self.get(fieldname) | d[fieldname] = self.get(fieldname) | ||||
return d | return d | ||||
@@ -22,6 +22,7 @@ def get_meta(doctype, cached=True): | |||||
class Meta(Document): | class Meta(Document): | ||||
_metaclass = True | _metaclass = True | ||||
_fields = {} | _fields = {} | ||||
default_fields = default_fields[1:] | |||||
def __init__(self, doctype): | def __init__(self, doctype): | ||||
super(Meta, self).__init__("DocType", doctype) | super(Meta, self).__init__("DocType", doctype) | ||||
@@ -62,7 +63,7 @@ class Meta(Document): | |||||
if self.name in ("DocType", "DocField", "DocPerm"): | if self.name in ("DocType", "DocField", "DocPerm"): | ||||
self._valid_columns = frappe.db.get_table_columns(self.name) | self._valid_columns = frappe.db.get_table_columns(self.name) | ||||
else: | 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] | [df.fieldname for df in self.get("fields") if df.fieldtype in type_map] | ||||
return self._valid_columns | return self._valid_columns | ||||
@@ -12,7 +12,7 @@ def get_context(context): | |||||
doc = frappe.get_doc("Style Settings", "Style Settings") | doc = frappe.get_doc("Style Settings", "Style Settings") | ||||
prepare(doc) | prepare(doc) | ||||
return { "doc": doc.fields } | |||||
return { "doc": doc.as_dict() } | |||||
def prepare(doc): | def prepare(doc): | ||||
from frappe.utils import cint, cstr | 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", | for k in ["banner_html", "brand_html", "copyright", "twitter_share_via", | ||||
"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share", | "favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share", | ||||
"disable_signup"]: | "disable_signup"]: | ||||
if getattr(settings, k, None): | |||||
if hasattr(settings, k): | |||||
context[k] = settings.get(k) | context[k] = settings.get(k) | ||||
if not context.get("favicon"): | if not context.get("favicon"): | ||||
@@ -21,11 +21,11 @@ def get_sitemap_options(path): | |||||
return frappe._dict(sitemap_options) | return frappe._dict(sitemap_options) | ||||
def build_sitemap_options(path): | 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() | home_page = get_home_page() | ||||
sitemap_config = frappe.get_doc("Website Template", | sitemap_config = frappe.get_doc("Website Template", | ||||
sitemap_options.get("website_template")) | |||||
sitemap_options.get("website_template")).as_dict() | |||||
# get sitemap config fields too | # get sitemap config fields too | ||||
for fieldname in ("base_template_path", "template_path", "controller", | for fieldname in ("base_template_path", "template_path", "controller", | ||||