本文整理汇总了Python中cyclone.util.ObjectDict类的典型用法代码示例。如果您正苦于以下问题:Python ObjectDict类的具体用法?Python ObjectDict怎么用?Python ObjectDict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectDict类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_current_user
def get_current_user(self):
session_opr = ObjectDict()
session_opr.username = 'api'
session_opr.ipaddr = self.request.remote_ip
session_opr.opr_type = 0
session_opr.login_time = utils.get_currtime()
return session_opr
示例2: get_current_user
def get_current_user(self):
username = self.get_secure_cookie("portal_user")
if not username: return None
ipaddr = self.request.remote_ip
rad_session_user = self.db.query(models.SlcRadOnline).filter_by(
account_number = username,
framed_ipaddr = ipaddr
).first()
if not rad_session_user:
return None
print rad_session_user
raduser = self.db.query(models.SlcRadAccount).filter_by(
account_number = username
).first()
print raduser
user = ObjectDict()
user.username = username
user.ipaddr = rad_session_user.framed_ipaddr
user.times = rad_session_user.billing_times
user.balance = raduser.balance
print repr(user)
return user
示例3: set_session_user
def set_session_user(self, username, ipaddr, login_time):
session_user = ObjectDict()
session_user.username = username
session_user.ipaddr = ipaddr
session_user.login_time = login_time
self.session['session_user'] = session_user
self.session.save()
示例4: set_session_user
def set_session_user(self, customer, ipaddr, login_time):
session_user = ObjectDict()
session_user.username = customer.customer_name
session_user.cid = customer.customer_id
session_user.ipaddr = ipaddr
session_user.login_time = login_time
self.session['session_user'] = session_user
self.session.save()
示例5: test_object_dict
def test_object_dict(self):
od = ObjectDict()
self.assertRaises(AttributeError, getattr, od, "something")
od["foo"] = "bar"
self.assertEqual(od['foo'], "bar")
self.assertEqual(od.foo, "bar")
od.rah = "meow"
self.assertEqual(od['rah'], "meow")
示例6: get_current_user
def get_current_user(self):
username = self.get_secure_cookie("portal_user")
if not username: return None
ipaddr = self.get_secure_cookie("portal_user_ip")
user = ObjectDict()
user.username = username
user.ipaddr = ipaddr
return user
示例7: set_session_user
def set_session_user(self, username, ipaddr, opr_type, login_time):
session_opr = ObjectDict()
session_opr.username = username
session_opr.ipaddr = ipaddr
session_opr.opr_type = opr_type
session_opr.login_time = login_time
self.session['session_opr'] = session_opr
self.session.save()
示例8: get_current_user
def get_current_user(self):
return self.session.get("session_user")
if not username: return None
user = ObjectDict()
user.username = username
user.ipaddr = self.session.get("tr_login_ip")
user.login_time = self.session.get("tr_login_time")
return user
示例9: get_current_user
def get_current_user(self):
username = self.get_secure_cookie("tra_user")
if not username: return None
ipaddr = self.get_secure_cookie("tra_login_ip")
user = ObjectDict()
user.username = username
user.ipaddr = ipaddr
user.opr_type = self.get_secure_cookie("tra_opr_type")
user.login_time = self.get_secure_cookie("tra_login_time")
return user
示例10: get_current_user
def get_current_user(self):
username = self.get_secure_cookie("opr_name")
if not username: return None
ipaddr = self.get_secure_cookie("opr_login_ip")
opr_type = int(self.get_secure_cookie("opr_type"))
login_time = self.get_secure_cookie("opr_login_time")
user = ObjectDict()
user.username = username
user.ipaddr = ipaddr
user.opr_type = opr_type
user.login_time = login_time
return user
示例11: get_wlannotify
def get_wlannotify():
articles =[]
article1=ObjectDict()
article1.title=u"无线上网"
article1.description=u"当您已经连接Wi-Fi信号时,点击即可免费联入网络。"
article1.url = "%s/mplogin?mp_openid=%s&product_id=%s&node_id=%s" % (
config.get('mps','server_base'),
msg.fromuser,
config.get('mps','wlan_product_id'),
config.get('mps','wlan_node_id')
)
article1.picurl = '%s/static/img/wlan.jpg' % config.get('mps','server_base')
articles.append(article1)
return articles
示例12: respond
def respond(data, msg=None,db=None,config=None,mpsapi=None,**kwargs):
products = db.query(models.SlcRadProduct).filter(
models.SlcRadProduct.mps_flag == 1,
models.SlcRadProduct.product_status == 0
).limit(7)
articles =[]
for item in products:
article=ObjectDict()
article.title= item.product_name
article.description = ''
article.url = "%s/order?openid=%s&product_id=%s" % (
config.get('mps','server_base'),
msg.fromuser,
item.id
)
article.picurl = '%s/static/img/mps/order_online.jpg' % config.get('mps','server_base')
articles.append(article)
return articles
示例13: respond
def respond(data, msg=None,db=None,config=None,mpsapi=None,**kwargs):
member = db.query(models.SlcMember).filter(
models.SlcMember.weixin_id==msg.fromuser).first()
if not member:
return u"您当前还未绑定账号"
articles =[]
article=ObjectDict()
article.title= u"我的工单"
article.description = ''
article.url = "%s/issues?openid=%s&member_id=%s" % (
config.get('mps','server_base'),
msg.fromuser,
member.member_id
)
article.picurl = '%s/static/img/mps/issues_query.jpg' % config.get('mps','server_base')
articles.append(article)
return articles
示例14: set_session_user
def set_session_user(self, username, ipaddr, opr_type, login_time):
session_opr = ObjectDict()
session_opr.username = username
session_opr.ipaddr = ipaddr
session_opr.opr_type = opr_type
session_opr.login_time = login_time
session_opr.resources = [r.rule_path for r in self.db.query(models.TrOperatorRule).filter_by(operator_name=username)]
self.session['session_opr'] = session_opr
self.session.save()
示例15: fetch_docs
def fetch_docs(self, query, categories=()):
page = self.get_arg('page', self.page)
try:
self.page = int(page)
except ValueError:
self.page = 1
offset = self.limit * (self.page - 1)
try:
data = yield self.client.search(query, categories,
offset=offset, limit=self.limit)
except Exception as e:
self.logerr('error while retrieveing results for {!r}'.format(query))
self.render_error()
defer.returnValue(None)
if 'error' in data:
self.logerr('error from search search: {!r}'.format(data))
self.render_error()
defer.returnValue(None)
results = []
for ret in data['docs']:
info = self.corpus_db.get(ret['id'])
if not info:
self.log('document key without record {!r}'.format(ret))
continue
if any(f not in info for f in ('headline', 'body', 'url')):
self.log("Document with missing fields: {!r}".format(info))
break
doc = ObjectDict((k,v) for (k,v) in ret.items()
if not k.startswith('_'))
doc.update(info)
results.append(doc)
defer.returnValue((data['total'], results))