本文整理汇总了Python中net.sf.chellow.monad.Monad.getContext方法的典型用法代码示例。如果您正苦于以下问题:Python Monad.getContext方法的具体用法?Python Monad.getContext怎么用?Python Monad.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.chellow.monad.Monad
的用法示例。
在下文中一共展示了Monad.getContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: globals
# 需要导入模块: from net.sf.chellow.monad import Monad [as 别名]
# 或者: from net.sf.chellow.monad.Monad import getContext [as 别名]
interrupt_id = None
if inv.getRequest().getMethod() == "POST":
if inv.hasParameter("interrupt"):
interrupt_id = inv.getLong("thread-id")
Monad.getUtils()["imprt"](
globals(),
{
"db": ["HhDatum", "Site", "Supply", "set_read_write", "session"],
"utils": ["UserException", "HH", "form_date"],
"templater": ["render", "on_start_report", "get_report"],
},
)
elif inv.hasParameter("run_shutdown"):
shutdown_contract = Contract.getNonCoreContract("shutdown")
shutdown_contract.callFunction("on_shut_down", [Monad.getContext()])
source.appendChild(MonadMessage("Shut down successfully.").toXml(doc))
elif inv.hasParameter("run_startup"):
startup_contract = Contract.getNonCoreContract("startup")
startup_contract.callFunction("on_start_up", [Monad.getContext()])
elif inv.hasParameter("cancel_backend"):
backend_pid = inv.getLong("backend_pid")
con = Hiber.session().connection()
stmt = con.createStatement()
stmt.execute("select pg_terminate_backend(" + str(backend_pid) + ")")
stmt.close()
Hiber.commit()
source.appendChild(MonadMessage("Cancelled backend.").toXml(doc))
df = DecimalFormat("###,###,###,###,##0")
示例2: len
# 需要导入模块: from net.sf.chellow.monad import Monad [as 别名]
# 或者: from net.sf.chellow.monad.Monad import getContext [as 别名]
import collections
import pytz
import threading
import sys
import os
import os.path
import time
import datetime
import utils
Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater')
UserException = utils.UserException
if sys.platform.startswith('java'):
download_path = Monad.getContext().getRealPath("/downloads")
else:
import chellow
download_path = os.path.join(chellow.app.instance_path, 'downloads')
if not os.path.exists(download_path):
os.makedirs(download_path)
download_id = 0
lock = threading.Lock()
files = sorted(os.listdir(download_path), reverse=True)
if len(files) > 0:
download_id = int(files[0][:3]) + 1
示例3: sorted
# 需要导入模块: from net.sf.chellow.monad import Monad [as 别名]
# 或者: from net.sf.chellow.monad.Monad import getContext [as 别名]
files.append(
{
'name': fl,
'last_modified': datetime.datetime.utcfromtimestamp(
statinfo.st_mtime),
'size': statinfo.st_size,
'creation_date': datetime.datetime.utcfromtimestamp(
statinfo.st_ctime)})
mem_items = dloads.get_mem_items()
mem_keys = sorted(mem_items.keys())
return {
'files': files, 'messages': messages, 'mem_items': mem_items,
'mem_keys': mem_keys}
try:
lib_path = Monad.getContext().getRealPath("/WEB-INF/lib-python")
if inv.getRequest().getMethod() == 'GET':
templater.render(inv, template, make_fields(lib_path))
else:
if inv.hasParameter("delete"):
name = inv.getString("name")
shutil.rmtree(os.path.join(lib_path, name))
inv.sendSeeOther("/reports/103/output/")
else:
file_item = inv.getFileItem("import_file")
stream = file_item.getInputStream()
f = StringIO.StringIO()
bt = stream.read()
while bt != -1:
f.write(chr(bt))
bt = stream.read()
示例4: get_lib
# 需要导入模块: from net.sf.chellow.monad import Monad [as 别名]
# 或者: from net.sf.chellow.monad.Monad import getContext [as 别名]
def get_lib(lib_name):
return Monad.getContext().getAttribute("net.sf.chellow." + lib_name)