本文整理汇总了Python中tornado.util.ObjectDict类的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict类的具体用法?Python ObjectDict怎么用?Python ObjectDict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectDict类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self):
data = self.application.data
lattice_ids = self.get_arguments("lattice")
if len(lattice_ids) < 2:
self.send_error(400, message="Must select two lattice for comparison")
return
lattice1 = yield data.find_lattice_by_id(lattice_ids[0])
if not lattice1:
self.send_error(400, message="Lattice (1) not found: " + lattice_ids[0])
return
lattice_elements1 = yield data.find_lattice_elements_by_lattice_id(lattice_ids[0])
lattice2 = yield data.find_lattice_by_id(lattice_ids[1])
if not lattice2:
self.send_error(400, message="Lattice (2) not found: " + lattice_ids[1])
return
lattice_elements2 = yield data.find_lattice_elements_by_lattice_id(lattice_ids[1])
ctx = ObjectDict()
ctx.lattice = (lattice1, lattice2)
n1 = len(lattice_elements1)
n2 = len(lattice_elements2)
ctx.lattice_elements = []
for idx in range(max(n1, n2)):
if idx < n1 and idx < n2:
ctx.lattice_elements.append((lattice_elements1[idx], lattice_elements2[idx]))
elif idx < n1:
ctx.lattice_elements.append((lattice_elements1[idx], None))
elif idx < n2:
ctx.lattice_elements.append((None, lattice_elements2[idx]))
ctx.particle_types = yield data.find_particle_types()
self.render("latticemodel/lattice_compare.html", **ctx)
开发者ID:frib-high-level-controls,项目名称:phyhlc,代码行数:35,代码来源:web.py
示例2: get
def get(self):
ctx = ObjectDict()
ctx.search_active = True
ctx.search = ObjectDict()
data = self.application.data
ctx.particle_types = yield data.find_particle_types()
self.render("latticemodel/lattice_search.html", **ctx)
开发者ID:frib-high-level-controls,项目名称:phyhlc,代码行数:7,代码来源:web.py
示例3: wrapper
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
logger.info(args)
logger.info(kwargs)
logger.info("====[EXIT]====")
# svc = args[0]
# # from code import interact
# # interact(local=locals())
# if isinstance(e, Exception):
# svc.db.rollback()
# logger.info("====[ROLLBACK]====")
# else:
# svc.db.commit()
# # svc.db.flush()
# logger.info("====[COMMIT]====")
# svc.db.remove()
# svc.db.close()
logger.info("====[CLOSE]====")
# svc = args[0]
# svc.db.close()
# svc.db.remove()
# logger.info(svc.db)
logThrown()
data = ObjectDict()
data.return_code = ERROR.system_err.errcode
data.return_message = e.__unicode__()
data.data = None
return data
开发者ID:finalbattle,项目名称:cloud-check,代码行数:30,代码来源:config.py
示例4: read_meta
def read_meta(path):
"""
:param path: path for the theme.
:return: Theme meta read in path.
"""
if not os.path.exists(path):
return
meta = os.path.join(path, 'theme.py')
if not os.path.exists(meta):
logging.warn("%s is not a catsup theme." % path)
return
theme = ObjectDict(
name='',
author='',
homepage='',
pages=[],
has_index=False,
path=path,
vars={},
)
execfile(meta, {}, theme)
templates_path = os.path.join(path, 'templates')
for page in theme.pages:
if page == 'page.html':
theme.has_index = True
# If your theme does not have index page,
# catsup will rename page/1.html to page.html.
if not os.path.exists(os.path.join(templates_path, page)):
logging.warning("%s announces a page %s"
" which not exists." % (theme.name, page))
theme.name = theme.name.lower()
return theme
开发者ID:chu888chu888,项目名称:Python-catsup,代码行数:32,代码来源:themes.py
示例5: get_resources_by_status
def get_resources_by_status(self):
logger.info("\t ==========[ get_resources_by_status ]==========")
conditions = and_()
or_conditions = or_()
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.APPLIED)
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.CHECKED)
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.PAYED)
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.CONFIRMPAYED)
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.STARTED)
or_conditions.append(Pro_Resource_Apply.status == STATUS_RESOURCE.CLOSED)
conditions.append(or_conditions)
res_status = self.params.get("res_status")
if res_status:
conditions.append(Pro_Resource_Apply.status == res_status)
env_id = self.params.get("env_id", 0)
if env_id:
conditions.append(Pro_Info.env_id == env_id)
logger.info("\t [res_status]: %s" % res_status)
resource_list = self.db.query(
Pro_Resource_Apply
).outerjoin(
Pro_Info, Pro_Info.id == Pro_Resource_Apply.pro_id
).filter(
conditions
).order_by(
Pro_Resource_Apply.create_time.desc()
).all()
# 按状态查询申请数量
status_counts = self.db.query(
Pro_Resource_Apply.status, func.count(Pro_Resource_Apply.id)
).filter(
or_conditions
).group_by(
Pro_Resource_Apply.status
).all()
status_counts = dict(status_counts)
logger.info("status_counts: %s" % status_counts)
# 按环境查询申请数量
env_counts = self.db.query(
Pro_Info.env_id, func.count(Pro_Resource_Apply.id)
).outerjoin(
Pro_Resource_Apply, Pro_Resource_Apply.pro_id == Pro_Info.id
).outerjoin(
Env_Info, Env_Info.id == Pro_Info.env_id
).filter(
or_conditions
).group_by(
Env_Info.id
).all()
env_counts = dict(env_counts)
logger.info("env_counts: %s" % env_counts)
data = ObjectDict()
data.resource_list = resource_list
data.status_counts = status_counts
data.env_counts = env_counts
return self.success(data=data)
开发者ID:finalbattle,项目名称:cloud-check,代码行数:59,代码来源:svc_pro_resource_apply.py
示例6: failures
def failures(self, failure_list, data=None):
result = ObjectDict()
result.return_code = ERROR.database_save_err.errcode
# result.return_message = u",".join(["(%s)%s" % (f.return_code, f.return_message) for f in failure_list])
result.return_message = u"\n,".join([f for f in failure_list])
result.return_messages = failure_list
result.data = data
return result
开发者ID:finalbattle,项目名称:cloud-check,代码行数:8,代码来源:base.py
示例7: _create_upload_context
def _create_upload_context(self):
data = self.application.data
ctx = ObjectDict()
ctx.upload_active = True
ctx.particle_types = yield data.find_particle_types()
ctx.lattice_types = yield data.find_lattice_types()
ctx.lattice = ObjectDict(lattice_type=self.type)
ctx.lattice_autoversion = True
ctx.errors = ObjectDict()
raise Return(ctx)
开发者ID:frib-high-level-controls,项目名称:phyhlc,代码行数:10,代码来源:impact.py
示例8: read
def read(self, phone):
endpoint = self.selector(phone)
if endpoint == self.bemuch.endpoint:
if phone in self.phonebook:
item = ObjectDict(self.phonebook[phone])
item.phone = phone
return item
else:
raise tornado.web.HTTPError(404)
else:
item = yield self.bemuch.call(endpoint, 'read', phone)
return item
开发者ID:Alesh,项目名称:BeMuch,代码行数:12,代码来源:phonebook.py
示例9: filter_list
def filter_list(self):
conditions = and_()
group_conditions = and_()
# if "pro_info.view" in self.handler.current_user.get_current_perms():
if not self.handler.current_user.imchecker:
conditions.append(Pro_Info.user_id == self.handler.current_user.id)
group_conditions.append(Pro_Info.user_id == self.handler.current_user.id)
env = self.params.get("env")
status = self.params.get("status")
if env:
conditions.append(Pro_Info.env_id == env)
if status:
conditions.append(Pro_Resource_Apply.status == status)
projects = self.db.query(
Pro_Info
).outerjoin(
Pro_Resource_Apply, Pro_Info.last_apply_id == Pro_Resource_Apply.id
).filter(
conditions
).order_by(
Pro_Info.id.desc()
).all()
# project_list = [i.as_dict() for i in projects]
# logger.info("project_list %s" % project_list)
# self.db.commit()
# self.db.remove()
projects_by_env = self.db.query(
Env_Info.id, Env_Info.name, func.count(Pro_Info.id)
).outerjoin(
Pro_Info, Env_Info.id == Pro_Info.env_id
).filter(
group_conditions
).group_by(
Env_Info.id
).all()
logger.info(projects_by_env)
projects_by_status = self.db.query(
Pro_Resource_Apply.status, func.count(Pro_Info.id)
).outerjoin(
Pro_Info, Pro_Resource_Apply.id == Pro_Info.last_apply_id
).filter(
group_conditions
).group_by(
Pro_Resource_Apply.status
).all()
logger.info(projects_by_status)
data = ObjectDict()
data.projects = projects
data.projects_by_env = projects_by_env
data.projects_by_status = projects_by_status
return self.success(data=data)
开发者ID:finalbattle,项目名称:cloud-check,代码行数:52,代码来源:svc_project.py
示例10: run_cmd
def run_cmd(self, payload):
host = payload['host']
request = ObjectDict(host=host)
request.track = ObjectDict(host=host)
uri = urlparse(payload['cmd'])
cmd = uri.path
if cmd == 'delete/module':
result = delete_module(request, parse_qs(uri.query)['name'])
log.debug('result: {0}'.format(result))
else:
raise HTTPServerError(title="command '{0}' is not supported".format(
cmd))
log.info('background processed command: {0}'.format(payload['cmd']))
开发者ID:JohnFDavenport,项目名称:stubo-app,代码行数:13,代码来源:command_queue.py
示例11: respond
def respond(data, msg=None):
parser = feedparser.parse(options.feed_url)
articles = []
i = 0
for entry in parser.entries:
if i > 9:
break
article = ObjectDict()
article.title = entry.title
article.description = entry.description[0:100]
article.url = entry.link
article.picurl = ''
articles.append(article)
i += 1
return articles
开发者ID:eclipse2x,项目名称:wechat-bot,代码行数:15,代码来源:feed.py
示例12: __init__
def __init__(self):
settings = ObjectDict()
settings.debug = options.debug
settings.autoescape = None
self.base_dir = os.path.abspath(os.path.dirname(__file__))
settings.template_path = os.path.join(self.base_dir, 'templates')
handlers = [
(r'/', IndexHandler),
(r'/api/torrent/link', TorrentLinkHandler),
(r'/api/torrent/file', TorrentFileHandler),
(r'/api/torrent/bttiantang', TorrentBTTianTangHandler),
]
super(Application, self).__init__(handlers, **settings)
开发者ID:cloverstd,项目名称:torrent2magnet,代码行数:16,代码来源:app.py
示例13: _find_user
def _find_user(self, account):
rs = self.db.query("SELECT * FROM users WHERE account=%s", account)
if not rs:
return None
r = rs[0]
d = copy.deepcopy(r)
d = ObjectDict(d)
d._id = d.id
del d['id']
del d['auth_time']
del d['ins_time']
d.user_no = str(d.user_no)
d.token = self._gen_token(d._id, d.user_no)
if d.ext_data:
d.ext_data = json.loads(d.ext_data)
d['class'] = 'user' # TODO class是python关键字,不建议用对象属性的方法赋值
return d
开发者ID:demotools,项目名称:dizigui-server,代码行数:17,代码来源:auth.py
示例14: __init__
def __init__(self):
settings = ObjectDict()
settings.debug = options.debug
settings.autoescape = None
self.base_dir = os.path.abspath(os.path.dirname(__file__))
settings.template_path = os.path.join(self.base_dir, 'templates')
settings.static_path = os.path.join(self.base_dir, 'static')
handlers = [
(r'/', IndexHandler),
(r'/upload', IndexHandler),
(r'/myfile', MyFileHandler),
(r'/myfile/list', ListRemoteFileHandler),
(r'/myfile/delete', DeleteRemoteFileHandler),
]
super(Application, self).__init__(handlers, **settings)
开发者ID:cloverstd,项目名称:qiniuimgbed,代码行数:17,代码来源:app.py
示例15: _on_github_request
def _on_github_request(future, response):
""" Parse the JSON from the API """
if response.error:
print response.error
future.set_exception(
AuthError("Error response {0!s} fetching {1!s}".format(response.error, response.request.url)))
return
result = ObjectDict(code=response.code, headers=response.headers, body=None)
try:
result.body = json_decode(response.body)
except Exception:
gen_log.warning("Invalid JSON from Github: %r", response.body)
future.set_result(result)
return
future.set_result(result)
开发者ID:runt18,项目名称:torngithub,代码行数:17,代码来源:torngithub.py
示例16: parse_user_msg
def parse_user_msg(xml):
if not xml:
return None
parser = ElementTree.fromstring(xml)
msg_type = decode(parser.find('MsgType').text)
touser = decode(parser.find('ToUserName').text)
fromuser = decode(parser.find('FromUserName').text)
create_at = int(parser.find('CreateTime').text)
msg = ObjectDict(
type=msg_type,
touser=touser,
fromuser=fromuser,
time=create_at
)
if msg_type == MSG_TYPE_TEXT:
msg.content = decode(parser.find('Content').text)
elif msg_type == MSG_TYPE_LOCATION:
msg.location_x = decode(parser.find('Location_X').text)
msg.location_y = decode(parser.find('Location_Y').text)
msg.scale = int(parser.find('Scale').text)
msg.label = decode(parser.find('Label').text)
elif msg_type == MSG_TYPE_IMAGE:
msg.picurl = decode(parser.find('PicUrl').text)
return msg
开发者ID:Dordorgum,项目名称:wechat-bot,代码行数:25,代码来源:wechat.py
示例17: respond
def respond(data, msg=None, bot=None, handler=None):
myfus = handler.get_user_follows(msg.fromuser)
post_query = handler.db.query(CoePost).filter(
CoePost.username.in_(myfus)
).order_by(CoePost.created.desc()).limit(9)
articles = []
for post in post_query:
if post.is_ignore == 1:
continue
article = ObjectDict()
article.title = post.topic
article.description = rtitle(post.content,79)
article.url = "%s/mps/post/%s?otoken=%s" % (handler.settings['server_base'],
post.post_id,handler.encrypt_otoken(bot.id))
article.picurl = handler.get_1img_from_content(post.content) or handler.settings['mps_default_bg']
articles.append(article)
return articles
开发者ID:talkincode,项目名称:comeonever,代码行数:18,代码来源:myfollows.py
示例18: torrent2magnet
def torrent2magnet(torrent, rich=False):
metadata = bencode.bdecode(torrent)
hashcontents = bencode.bencode(metadata['info'])
digest = hashlib.sha1(hashcontents).digest()
b32hash = base64.b32encode(digest)
magnet = 'magnet:?xt=urn:btih:{}'.format(b32hash)
if rich:
params = ObjectDict()
params.xt = 'urn:btih:{}'.format(b32hash)
params.dn = metadata['info']['name']
params.tr = metadata['announce']
if 'length' in metadata['info']:
params.xl = metadata['info']['length']
paramstr = urllib.urlencode(params)
magnet = 'magnet:?{}'.format(paramstr)
return magnet, metadata['info']
开发者ID:cloverstd,项目名称:torrent2magnet,代码行数:18,代码来源:app.py
示例19: respond
def respond(data, msg=None, bot=None, handler=None):
nodes = handler.db.query(CoeNode).filter(
CoeNode.is_top == 1).order_by(CoeNode.created.asc()).limit(9)
articles = []
for node in nodes:
if node.is_hide == 1:
continue
article = ObjectDict()
article.title = node.node_desc
article.description = rtitle(node.node_intro,79)
article.url = "%s/mps/post/new/%s?otoken=%s" % (
handler.settings['server_base'],
node.node_name,
handler.encrypt_otoken(bot.id))
article.picurl = ''
articles.append(article)
if len(articles)>1:
articles[0].picurl = handler.settings['mps_default_bg']
return articles
开发者ID:talkincode,项目名称:comeonever,代码行数:21,代码来源:post.py
示例20: load_config
def load_config(filename='config.py'):
catsup_path = os.path.dirname(__file__)
config = ObjectDict(
catsup_path=catsup_path,
posts_path=os.path.join(catsup_path, '_posts'),
common_template_path=os.path.join(catsup_path, 'template'),
deploy_path=os.path.join(catsup_path, 'deploy'),
disqus_shortname='catsup',
feed='feed.xml',
post_per_page=3,
gzip=True,
static_url='static',
theme_name='sealscript',
google_analytics=''
)
execfile(filename, {}, config)
if 'theme_path' not in config:
config.theme_path = os.path.join(catsup_path, 'themes',
config.theme_name)
if 'template_path' not in config:
config.template_path = os.path.join(config.theme_path, 'template')
if 'static_path' not in config:
config.static_path = os.path.join(config.theme_path, 'static')
if config.site_url.endswith('/'):
config.site_url = config.site_url[:-1]
if config.static_url.endswith('/'):
config.static_url = config.static_url[:-1]
return config
开发者ID:zhengjingren,项目名称:catsup,代码行数:35,代码来源:utils.py
注:本文中的tornado.util.ObjectDict类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论