本文整理汇总了Python中tornado.util.ObjectDict.title方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict.title方法的具体用法?Python ObjectDict.title怎么用?Python ObjectDict.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.util.ObjectDict
的用法示例。
在下文中一共展示了ObjectDict.title方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
def post(self):
o = ObjectDict()
o.title = self.get_argument("title", None)
o.slug = self.get_argument("slug", None)
o.avatar = self.get_argument("avatar", None)
o.description = self.get_argument("description", None)
o.fgcolor = self.get_argument("fgcolor", None)
o.bgcolor = self.get_argument("bgcolor", None)
o.header = self.get_argument("header", None)
o.sidebar = self.get_argument("sidebar", None)
o.footer = self.get_argument("footer", None)
try:
o.limit_reputation = int(self.get_argument("reputation", 0))
except:
o.limit_reputation = 0
try:
o.limit_role = int(self.get_argument("role", 0))
except:
o.limit_role = 0
if not (o.slug and o.title and o.description):
self._context.message = "Please fill the required field"
self.render("dashboard_node.html", node=o)
return
node = Node(**o)
self.db.add(node)
self.db.commit()
self.redirect("/node/%s" % o.slug)
示例2: parse_msg
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
def parse_msg(xml):
if not xml:
return None
parser = ElementTree.fromstring(xml)
id_node = parser.find('MsgId')
msg_id = id_node and int(id_node.text) or 0
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(
mid=msg_id,
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)
elif msg_type == MSG_TYPE_LINK:
msg.title = decode(parser.find('Title').text)
msg.description = decode(parser.find('Description').text)
msg.url = decode(parser.find('Url').text)
elif msg_type == MSG_TYPE_EVENT:
msg.event = decode(parser.find('Event').text)
msg.event_key = decode(parser.find('EventKey').text)
return msg
示例3: respond
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
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
示例4: respond
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
def respond(data, msg=None):
res = requests.get("http://www.v2ex.com/api/topics/latest.json")
topics = json_decode(res.text)
articles = []
i = 0
while i < 10:
article = ObjectDict()
article.title = topics[i]['title']
article.url = topics[i]['url']
if i == 0:
article.picurl = 'http://openoceans.de/img/v2ex_logo_uranium.png'
else:
article.picurl = ''
article.description = topics[i]['content_rendered'][0:100]
articles.append(article)
i += 1
return articles
示例5: respond
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
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
示例6: parse_msg
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
def parse_msg(xml):
if not xml:
return None
parser = ElementTree.fromstring(xml)
msg_id = parse_node(parser, 'MsgId', get_uuid())
msg_type = parse_node(parser, 'MsgType')
touser = parse_node(parser, 'ToUserName')
fromuser = parse_node(parser, 'FromUserName')
create_at = int(parse_node(parser, 'CreateTime', 0))
msg = ObjectDict(
mid=msg_id,
type=msg_type,
touser=touser,
fromuser=fromuser,
time=create_at
)
if msg_type == MSG_TYPE_TEXT:
msg.content = parse_node(parser, 'Content')
elif msg_type == MSG_TYPE_LOCATION:
msg.location_x = parse_node(parser, 'Location_X')
msg.location_y = parse_node(parser, 'Location_Y')
msg.scale = int(parse_node(parser, 'Scale'))
msg.label = parse_node(parser, 'Label')
elif msg_type == MSG_TYPE_IMAGE:
msg.picurl = parse_node(parser, 'PicUrl')
elif msg_type == MSG_TYPE_VOICE:
msg.media_id = parse_node(parser, 'MediaId')
msg.format = parse_node(parser, 'Format')
elif msg_type == MSG_TYPE_VIDEO:
msg.media_id = parse_node(parser, 'MediaId')
msg.thumb = parse_node(parser, 'ThumbMediaId')
elif msg_type == MSG_TYPE_LINK:
msg.title = parse_node(parser, 'Title')
msg.description = parser.find('Description').text
msg.url = parse_node(parser, 'Url')
elif msg_type == MSG_TYPE_EVENT:
msg.event = parse_node(parser, 'Event')
msg.event_key = parse_node(parser, 'EventKey')
msg.ticket = parse_node(parser, 'Ticket')
if msg.event == 'LOCATION':
msg.latitude = parse_node(parser, 'Latitude')
msg.longitude = parse_node(parser, 'Longitude')
msg.precision = parse_node(parser, 'Precision')
return msg
示例7: respond
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
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
示例8: respond
# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import title [as 别名]
def respond(data, msg=None, bot=None):
headers = {
'Host' : 'www.oschina.net',
'Connection' : 'Keep-Alive',
'User-Agent' : 'OSChina.NET/1.7.4_1/Android/4.1/Nexus S/12345678'
}
res = requests.get("http://www.oschina.net/action/api/news_list",
headers=headers)
parser = ElementTree.fromstring(res.content)
news_list = parser.find('newslist')
articles = []
i = 0
for news in news_list.iter('news'):
if i > 9:
break
article = ObjectDict()
article.title = news.find('title').text
article.description = article.title
article.url = "http://www.oschina.net/news/%s" % news.find('id').text
article.picurl = ''
articles.append(article)
i += 1
return articles