本文整理匯總了Python中models.board.Board.solr方法的典型用法代碼示例。如果您正苦於以下問題:Python Board.solr方法的具體用法?Python Board.solr怎麽用?Python Board.solr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.board.Board
的用法示例。
在下文中一共展示了Board.solr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import solr [as 別名]
def get(self,key):
uri = self.request.uri
request = {}
board = Board()
pin_keys = board.allKey()
pin_count = len(pin_keys)
query = {}
query['q'] = "user:%s" % key
query['start'] = "0"
query['rows'] = globalSetting['max_index_board_rows']
query['sort'] = "follow"
if "page" in uri:
request = urldecode(uri)
page = int(request['page'])
query['start'] = query['rows']*page
#if pin_count < query['rows']*page:
# return ''
board_data = board.solr(query)
print len(board_data)
boards_dict = board.formatBoards(board_data)
if request:
#print request['callback']
#print request['page']
callback_result = {
'filter':'board:index',
'boards':boards_dict
}
callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
self.set_header("Content-Type", "text/html; charset=utf-8")
return self.write(callback_response)
else:
user = User()
boards = ''
for _board_t in boards_dict:
boards = self.render_string('board_unit.html',board=_board_t) + boards
u_user = user.getInfo(key)
userFollow = UserFollow()
counts = {}
counts['follow'] = len(userFollow.getByKeyValues("user", key))
counts['fans'] = len(userFollow.getByKeyValues("follow", key))
self.render('user_board.html',counts=counts,u_user=u_user,user=self.currentUserInfo(),boards=boards)
示例2: get
# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import solr [as 別名]
def get(self,key):
user_key = self.get_secure_cookie("user_key")
board = Board()
query = {}
query['q'] = "user:%s" % user_key
_data = board.solr(query)
thumb = Thumb()
pic = Pic()
pic_url = pic.get(key)['url']
thumb_url = thumb.get(key)['url']
self.render('repin.html',boards = _data,pic_url=pic_url,thumb_url=thumb_url)
示例3: get
# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import solr [as 別名]
def get(self):
uri = self.request.uri
request = {}
board = Board()
pin_keys = board.allKey()
query = {}
query['q'] = "public:1"
query['start'] = "0"
query['rows'] = globalSetting['max_index_board_rows']
query['sort'] = "follow"
if "page" in uri:
request = urldecode(uri)
page = int(request['page'])
query['start'] = query['rows']*page
#if pin_count < query['rows']*page:
# return ''
board_data = board.solr(query)
print len(board_data)
boards_dict = board.formatBoards(board_data)
if request:
#print request
callback_result = {
'filter':'board:index',
'boards':boards_dict
}
callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
self.set_header("Content-Type", "text/html; charset=utf-8")
return self.write(callback_response)
else:
boards = ''
for _board_t in boards_dict:
boards = self.render_string('board_unit.html',board=_board_t) + boards
self.render('board_pop.html',user=self.currentUserInfo(),boards=boards)
示例4: post
# 需要導入模塊: from models.board import Board [as 別名]
# 或者: from models.board.Board import solr [as 別名]
def post(self):
uri = self.request.uri
avatar_sha1=self.get_argument("f_file.sha1",None)
if avatar_sha1:
user_key = self.get_secure_cookie("user_key")
res = {}
upload_file_name=self.get_argument("f_file.name",None)
ext = upload_file_name.split('.')[1]
img_path_t=os.path.join("/tmp/upload_temp_dir/",str(avatar_sha1))
img_path = "%s.%s" % (img_path_t,ext)
upload_file_path=self.get_argument("f_file.path",None)
os .rename(upload_file_path,img_path)
client = Fdfs_client(globalSetting['fdfs_client_conf'])
ret = client.upload_by_filename(img_path)
remote_file_id = ret['Remote file_id']
storage_ip = ret['Storage IP']
pic_url = "http://%s:%d/%s" % (storage_ip,globalSetting['fdfsPort'],remote_file_id)
print pic_url
from models.avatar import Avatar
avatar = Avatar()
avatar.key = user_key
avatar.data['url'] = pic_url
avatar.post()
res['avatar'] = pic_url
res['error'] = ''
return self.dumpJson(res)
upload_file_sha1=self.get_argument("ifile.sha1",None)
#upload_file_size=self.get_argument("ifile.size",None)
upload_file_path=self.get_argument("ifile.path",None)
upload_file_name=self.get_argument("ifile.name",None)
print upload_file_name
ext = upload_file_name.split('.')[1]
img_path_t=os.path.join("/tmp/upload_temp_dir/",str(upload_file_sha1))
img_path = "%s.%s" % (img_path_t,ext)
img_path_170x170 = "%s_170x170.%s" % (img_path_t,ext)
try:
i=Img()
i.open('/usr/bin')
i.convert_resize(input_file=upload_file_path,output_file=img_path,output_size="500x")
i.convert_thumbnail(input_file=img_path,output_file=img_path_170x170,output_size="170x170")
except Exception as what:
#data=file(upload_file_path,'rb').close()
print what
pass
client = Fdfs_client(globalSetting['fdfs_client_conf'])
ret = client.upload_by_filename(img_path)
remote_file_id = ret['Remote file_id']
storage_ip = ret['Storage IP']
pic_url = "http://%s:%d/%s" % (storage_ip,globalSetting['fdfsPort'],remote_file_id)
ret = client.upload_by_filename(img_path_170x170)
remote_file_id = ret['Remote file_id']
storage_ip = ret['Storage IP']
thumb_url = "http://%s:%d/%s" % (storage_ip,globalSetting['fdfsPort'],remote_file_id)
user_key = self.get_secure_cookie("user_key")
board = Board()
query = {}
query['q'] = "user:%s" % user_key
_data = board.solr(query)
self.render('upload_form.html',boards = _data,pic_url=pic_url,thumb_url=thumb_url)