make bean pickleable

This commit is contained in:
Rushabh Mehta 2014-02-13 12:05:37 +05:30
parent 929ef59df9
commit 19c6dc2d57
5 changed files with 10 additions and 6 deletions

View file

@ -22,7 +22,10 @@ local = Local()
class _dict(dict):
"""dict like object that exposes keys as attributes"""
def __getattr__(self, key):
return self.get(key)
ret = self.get(key)
if not ret and key.startswith("__"):
raise AttributeError()
return ret
def __setattr__(self, key, value):
self[key] = value
def __getstate__(self):

View file

@ -69,7 +69,6 @@ def get_bootinfo():
from webnotes.model.utils import compress
bootinfo['docs'] = compress(bootinfo['docs'])
# deal with __slots__ in lang
if bootinfo.lang:
bootinfo.lang = unicode(bootinfo.lang)

View file

@ -240,7 +240,6 @@ def use():
@cmd
def install(db_name, root_login="root", root_password=None, source_sql=None,
admin_password = 'admin', verbose=True, force=False, site_config=None, reinstall=False):
print db_name, source_sql
from webnotes.installer import install_db, install_app, make_site_dirs
install_db(root_login=root_login, root_password=root_password, db_name=db_name, source_sql=source_sql,
admin_password = admin_password, verbose=verbose, force=force, site_config=site_config, reinstall=reinstall)

View file

@ -178,6 +178,8 @@ class Document:
elif self.fields.has_key(name):
return self.fields[name]
else:
if name.startswith("__"):
raise AttributeError()
return ''
def get(self, name, value=None):

View file

@ -86,11 +86,13 @@ def build_page(path):
def get_context(path):
context = None
cache_key = "page_context:{}".format(path)
from pickle import dump
from StringIO import StringIO
# try from memcache
if can_cache():
context = webnotes.cache().get_value(cache_key)
if not context:
context = get_sitemap_options(path)
@ -99,8 +101,7 @@ def get_context(path):
context = build_context(context)
if can_cache(context.no_cache):
del context["access"]
if can_cache(context.no_cache):
webnotes.cache().set_value(cache_key, context)
else: