瀏覽代碼

make bean pickleable

version-14
Rushabh Mehta 11 年之前
父節點
當前提交
19c6dc2d57
共有 5 個文件被更改,包括 10 次插入6 次删除
  1. +4
    -1
      webnotes/__init__.py
  2. +0
    -1
      webnotes/boot.py
  3. +0
    -1
      webnotes/cli.py
  4. +2
    -0
      webnotes/model/doc.py
  5. +4
    -3
      webnotes/webutils.py

+ 4
- 1
webnotes/__init__.py 查看文件

@@ -22,7 +22,10 @@ local = Local()
class _dict(dict): class _dict(dict):
"""dict like object that exposes keys as attributes""" """dict like object that exposes keys as attributes"""
def __getattr__(self, key): 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): def __setattr__(self, key, value):
self[key] = value self[key] = value
def __getstate__(self): def __getstate__(self):


+ 0
- 1
webnotes/boot.py 查看文件

@@ -69,7 +69,6 @@ def get_bootinfo():
from webnotes.model.utils import compress from webnotes.model.utils import compress
bootinfo['docs'] = compress(bootinfo['docs']) bootinfo['docs'] = compress(bootinfo['docs'])


# deal with __slots__ in lang
if bootinfo.lang: if bootinfo.lang:
bootinfo.lang = unicode(bootinfo.lang) bootinfo.lang = unicode(bootinfo.lang)


+ 0
- 1
webnotes/cli.py 查看文件

@@ -240,7 +240,6 @@ def use():
@cmd @cmd
def install(db_name, root_login="root", root_password=None, source_sql=None, 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): 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 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, 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) admin_password = admin_password, verbose=verbose, force=force, site_config=site_config, reinstall=reinstall)


+ 2
- 0
webnotes/model/doc.py 查看文件

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


+ 4
- 3
webnotes/webutils.py 查看文件

@@ -86,11 +86,13 @@ def build_page(path):
def get_context(path): def get_context(path):
context = None context = None
cache_key = "page_context:{}".format(path) cache_key = "page_context:{}".format(path)
from pickle import dump
from StringIO import StringIO
# try from memcache # try from memcache
if can_cache(): if can_cache():
context = webnotes.cache().get_value(cache_key) context = webnotes.cache().get_value(cache_key)
if not context: if not context:
context = get_sitemap_options(path) context = get_sitemap_options(path)


@@ -99,8 +101,7 @@ def get_context(path):


context = build_context(context) 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) webnotes.cache().set_value(cache_key, context)


else: else:


Loading…
取消
儲存