本文整理汇总了Python中warara.warara_middleware.get_server函数的典型用法代码示例。如果您正苦于以下问题:Python get_server函数的具体用法?Python get_server怎么用?Python get_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_server函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: login
def login(request):
if request.method != 'POST':
return HttpResponseRedirect('/')
if request.POST.get('precheck', 0):
return login_precheck(request)
# 가끔 username / password 를 아예 안 넣는 경우가 있다.
username = request.POST.get('username', None)
password = request.POST.get('password', None)
if username == None or password == None:
# XXX 2010.07.02. 사실 합당한 에러를 만들어야 하는데 ...
raise NotLoggedIn()
# 로그인 요청을 수행한 url 을 current_page 로 설정한다
# 해당되는 url 이 없을 경우 /main/ 을 기본값으로 설정한다
current_page = request.POST.get('current_page_url', '/main/')
client_ip = request.META['REMOTE_ADDR']
server = warara_middleware.get_server()
try:
session_key = server.login_manager.login(username, password, client_ip)
except InvalidOperation, e:
#XXX: (pipoket) Ugly hack for showing nickname while not logged in.
# print e.why
splited = e.why.splitlines()
if splited[0] == 'not activated':
username = splited[1]
nickname = splited[2]
rendered = render_to_string('account/mail_confirm.html', {
'username': username, 'nickname': nickname})
return HttpResponse(rendered)
else:
return HttpResponse('<script>alert("Login failed!"); history.back()</script>');
开发者ID:hodduc,项目名称:arara,代码行数:35,代码来源:views.py
示例2: index
def index(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
category_list = server.board_manager.get_category_list()
r['category_list'] = category_list + [{'category_name':'None'}]
board_list = server.board_manager.get_board_list()
for board in board_list:
for category in category_list:
if board.category_id == category.id:
board.category_name = category.category_name
r['board_list'] = board_list
bbs_managers_list = []
for board in board_list:
bbs_managers = server.board_manager.get_bbs_managers(board.board_name)
bbs_managers_list.append({'board': board, 'managers': bbs_managers})
r['bbs_managers_list'] = bbs_managers_list
# TODO: 배너를 단순히 나열하기보다는 배너의 날짜 등을 함께 표시하는 것이 어떨까?
banner_list = server.notice_manager.list_banner(sess)
r['banner_list'] = banner_list
rendered = render_to_string('sysop/index.html', r)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:28,代码来源:views.py
示例3: write_
def write_(request, board_name):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
article_dic = {}
r['url'] = ''.join(['/board/', board_name, '/'])
article_dic['content'] = request.POST.get('text', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
article_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_dic['title'] = request.POST.get('title', '')
article_dic['heading'] = request.POST.get('heading', '') # Heading !!!
if request.POST.get('write_type', 0) == 'modify':
article_no = request.POST.get('article_no', 0)
article_id = server.article_manager.modify_article(sess, board_name, int(article_no), WrittenArticle(**article_dic))
delete_file = request.POST.get('delete_file', 0) #delete_file
if delete_file:
delete_file = delete_file[1:]
delete_file = delete_file.split('&')
for file_id in delete_file:
file = server.file_manager.delete_file(sess, int(article_no), int(file_id))
os.remove("%s/%s/%s" % (FILE_DIR, file.file_path, file.saved_filename))
else:
article_id = server.article_manager.write_article(sess, board_name, WrittenArticle(**article_dic))
#upload file
if request.FILES:
_upload_file(server, sess, article_id, request.FILES)
if request.POST.get('write_type', 0) == 'modify':
return HttpResponseRedirect('/board/%s/%s#%s' % (board_name, request.POST.get('root_id', article_id), article_id))
else:
return HttpResponseRedirect('/board/%s/%s' % (board_name, str(article_id)))
开发者ID:hodduc,项目名称:arara,代码行数:34,代码来源:views.py
示例4: rss
def rss(request, board_name):
'''
주어진 게시판에 대한 RSS 파일을 제공한다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: 검색하려는 글이 있는 board name
'''
from django.utils import feedgenerator
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
feed = feedgenerator.Atom1Feed(title = u'ARA/%s' % board_name, link = u'/board/%s/rss/' % board_name, description = u'A RSS of all articles in %s board' % board_name)
page_no = 1
page_length = 20
article_list = server.article_manager.article_list(sess, board_name, None, page_no, page_length, True).hit
fake_author(article_list, False)
for article in article_list:
if article.heading:
article_title = u'[%s] %s' % (article.heading, article.title)
else:
article_title = u'%s' % article.title
feed.add_item(title=article_title,
link=u'/board/%s/%d/' % (board_name, article.id),
author_name=article.author_nickname,
pubdate=datetime.datetime.fromtimestamp(article.date),
description=u'author : %s date : %s' % (article.author_nickname, datetime.datetime.fromtimestamp(article.date)))
return HttpResponse(feed.writeString('utf-8'), mimetype=feedgenerator.Atom1Feed.mime_type)
开发者ID:hodduc,项目名称:arara,代码行数:34,代码来源:views.py
示例5: read
def read(request, message_list_type, message_id):
server = warara_middleware.get_server()
sess, _ = warara.check_logged_in(request)
r = {}
r["logged_in"] = True
r["page_length"] = request.GET.get("page_length", 10)
r["page_no"] = request.GET.get("page_no", 1)
message_id = int(message_id)
if message_list_type == "inbox":
r["message"] = server.messaging_manager.read_received_message(sess, message_id)
elif message_list_type == "outbox":
r["message"] = server.messaging_manager.read_sent_message(sess, message_id)
r["message"].sent_time = datetime.datetime.fromtimestamp(r["message"].sent_time)
r["message_id"] = message_id
r["message_list_type"] = message_list_type
if message_list_type == "inbox":
r["person_type"] = "sender"
r["person"] = r["message"].from_
elif message_list_type == "outbox":
r["person_type"] = "receiver"
r["person"] = r["message"].to
rendered = render_to_string("message/read.html", r)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:27,代码来源:views.py
示例6: password_recovery
def password_recovery(request, username, token_code):
sess, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
if r['logged_in'] == True:
raise InvalidOperation("Already logged in!")
if request.method == 'POST':
new_password = request.POST.get('password', '')
new_password_check = request.POST.get('re_password', '')
error_msg = ''
if new_password != new_password_check:
error_msg = 'Passwords are not agree.'
if new_password == '':
error_msg = 'Password cannot be empty.'
if error_msg:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % error_msg)
user_password_dic = {'username':username, 'current_password':u'', 'new_password':new_password}
try:
server.member_manager.modify_password_with_token(UserPasswordInfo(**user_password_dic), token_code)
except InvalidOperation, e:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % e.why)
return HttpResponseRedirect("/")
开发者ID:hodduc,项目名称:arara,代码行数:25,代码来源:views.py
示例7: refresh_weather
def refresh_weather(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
server.bot_manager.refresh_weather_info()
return HttpResponseRedirect('/sysop/')
开发者ID:hodduc,项目名称:arara,代码行数:7,代码来源:views.py
示例8: render
def render(self, ctx):
server = warara_middleware.get_server()
# XXX(hodduc) : wairara.check_logged_in을 거쳤음에도 불구하고 Context를 따로 만들어서 쓰는 view가 너무 많다.
# 하나로 통일하는 것이 깔끔해 보인다
if not 'arara_session' in ctx:
return ''
sess = ctx['arara_session']
# Get Weather info
if warara_settings.USE_WEATHER_FORECAST:
ctx['weather_info'] = server.bot_manager.get_weather_info(sess)
if ctx['weather_info'].city == None:
ctx['has_weather'] = False
else:
if ctx['weather_info'].city.lower() == 'daejeon':
ctx['weather_info'].city = u'대전'
elif ctx['weather_info'].city.lower() == 'seoul':
ctx['weather_info'].city = u'서울'
ctx['weather_info'].current_icon_url = weather_icon_replace(ctx['weather_info'].current_icon_url)
ctx['weather_info'].tomorrow_icon_url = weather_icon_replace(ctx['weather_info'].tomorrow_icon_url)
ctx['weather_info'].day_after_tomorrow_icon_url = weather_icon_replace(ctx['weather_info'].day_after_tomorrow_icon_url)
ctx['has_weather'] = True
else:
ctx['has_weather'] = False
return ""
开发者ID:hodduc,项目名称:arara,代码行数:26,代码来源:arara_tags.py
示例9: read_root
def read_root(request, board_name, article_id):
'''
주어진 게시판의 주어진 글이 답글인 경우 root글의 주소로 읽어온다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: 읽고자 하는 글이 있는 Board Name
@type article_id: string (int)
@param article_id: 읽고자 하는 글의 번호
'''
server = warara_middleware.get_server() #
sess, r = warara.check_logged_in(request) #
r['mode'] = 'board'
article_list = server.article_manager.read_article(sess, board_name, int(article_id))
root_article_id = article_list[0].root_id
# 글의 정보를 r 에 저장
_read(request, r, sess, board_name, root_article_id)
# 화면 하단의 글목록의 정보를 r 에 저장
get_article_list(request, r, 'read')
fake_author(r['article_read_list'])
fake_author(r['article_list'], False)
rendered = render_to_string('board/read.html', r)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例10: _reply
def _reply(request, board_name, article_id):
'''
주어진 게시판의 주어진 글에 실제로 reply 를 단다.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: reply를 달고자 하는 글이 있는 board name
@type article_id: string (int)
@param article_id: reply를 달고자 하는 글의 번호
@rtype: int
@return: reply 가 달리는 글의 root id
'''
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
reply_dic = {}
reply_dic['content'] = request.POST.get('content', '')
reply_dic['title'] = request.POST.get('title', '')
reply_dic['heading'] = request.POST.get('heading', '') # TODO: HEADING !!
root_id = request.POST.get('root_id', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
reply_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_id = server.article_manager.write_reply(sess, board_name, int(article_id), WrittenArticle(**reply_dic))
#upload file
if request.FILES:
_upload_file(server, sess, article_id, request.FILES)
return root_id
开发者ID:hodduc,项目名称:arara,代码行数:32,代码来源:views.py
示例11: _relay_fiction_reply
def _relay_fiction_reply(request, board_name, article_id):
'''
이벤트용 임시 답글 함수.
@type request: Django Request
@param request: Request
@type board_name: string
@param board_name: reply를 달고자 하는 글이 있는 board name
@type article_id: string (int)
@param article_id: reply를 달고자 하는 글의 번호
@rtype: int
@return: reply 가 달리는 글의 root id
'''
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
reply_dic = {}
color = request.POST.get('color', '#000000')
reply_dic['content'] = '<font color=\"' + color + '\">' + request.POST.get('content', '') + '</font>'
reply_dic['title'] = request.POST.get('title', '')
reply_dic['heading'] = request.POST.get('heading', '') # TODO: HEADING !!
root_id = request.POST.get('root_id', '')
use_signature = request.POST.get('signature_check', None)
if use_signature:
reply_dic['content'] += '\n\n' + request.POST.get('signature', '')
article_id = server.article_manager.write_reply(sess, board_name, int(article_id), WrittenArticle(**reply_dic))
return root_id
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例12: check_logged_in
def check_logged_in(request):
r = {}
if "arara_session_key" in request.session:
sess = request.session['arara_session_key']
username = request.session['arara_username']
checksum = hashlib.sha1(sess+"@"+username).hexdigest()
if request.COOKIES.get('arara_checksum', '') != checksum:
from warara import warara_middleware
server = warara_middleware.get_server()
User_Info = server.member_manager.get_info(sess)
server.login_manager.debug__check_session(sess, username, request.META['REMOTE_ADDR'], User_Info)
request.session.flush()
sess = ""
r['logged_in'] = False
r['username'] = ""
request.session['django_language']="en"
else:
r['arara_session'] = sess
r['logged_in'] = True
r['username'] = request.session.get('arara_username', 0);
else:
sess = ""
r['logged_in'] = False
r['username'] = ""
request.session['django_language']="en"
return sess, r
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:__init__.py
示例13: send_password_recovery_email
def send_password_recovery_email(request):
sess, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
if r['logged_in'] == True:
raise InvalidOperation("Already logged in!")
if request.method == 'POST':
username = request.POST.get('username_field', '')
email = request.POST.get('email_field', '')
error_msg = ''
if not username:
error_msg = 'Username field is empty.'
if not email:
error_msg = 'Email field is empty.'
if error_msg:
return HttpResponse('<script>alert("%s"); history.back(); </script>' % error_msg)
try:
server.member_manager.send_password_recovery_email(username, email)
resp = "We sent e-mail to your e-mail address. Please check your inbox."
except InvalidOperation, e:
resp = e.why
return HttpResponse('<script>alert("%s"); history.back(); </script>' % resp)
开发者ID:hodduc,项目名称:arara,代码行数:25,代码来源:views.py
示例14: update
def update(request):
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
blacklist = server.blacklist_manager.get_blacklist(sess)
bl_submit_chooser = request.POST['bl_submit_chooser']
if bl_submit_chooser == "update":
for b in blacklist:
article_bl_key = 'blacklist_article_%s' % b.blacklisted_user_username
if article_bl_key in request.POST:
b.block_article = True
else:
b.block_article = False
message_bl_key = 'blacklist_message_%s' % b.blacklisted_user_username
if message_bl_key in request.POST:
b.block_message = True
else:
b.block_message = False
server.blacklist_manager.modify_blacklist(sess, BlacklistRequest(
blacklisted_user_username = b.blacklisted_user_username,
block_article = b.block_article,
block_message = b.block_message))
if bl_submit_chooser == "delete":
for b in blacklist:
delete_user = request.POST.get('bl_%s_delete' % b.blacklisted_user_username, "")
if delete_user != "":
server.blacklist_manager.delete_blacklist(sess, delete_user)
return HttpResponseRedirect("/blacklist/")
开发者ID:hodduc,项目名称:arara,代码行数:29,代码来源:views.py
示例15: delete
def delete(request):
if request.method == 'POST':
username = request.POST['username']
server = warara_middleware.get_server()
sess, r = warara.check_logged_in(request)
server.blacklist_manager.delete_blacklist(sess, username)
return HttpResponseRedirect("/blacklist/")
开发者ID:hodduc,项目名称:arara,代码行数:7,代码来源:views.py
示例16: do_get_board_alias
def do_get_board_alias(value):
"Get board name and board alias"
server = warara_middleware.get_server()
board_alias = cache.get('board_alias.' + value)
if not board_alias:
board_alias = server.board_manager.get_board(value).board_alias
cache.set('board_alias.' + value, board_alias, CACHETIME_BOARD_ALIAS)
return board_alias
开发者ID:hodduc,项目名称:arara,代码行数:8,代码来源:arara_tags.py
示例17: do_get_board_description
def do_get_board_description(value, arg):
"Get board name and board description"
server = warara_middleware.get_server()
board_description = cache.get('board_description.' + value)
if not board_description:
board_description = server.board_manager.get_board(value).board_description
cache.set('board_description.' + value, board_description, CACHETIME_BOARD_DESCRIPTION)
return board_description
开发者ID:hodduc,项目名称:arara,代码行数:8,代码来源:arara_tags.py
示例18: count_new_message
def count_new_message(request):
server = warara_middleware.get_server()
sess, _ = warara.check_logged_in(request)
try:
result = server.messaging_manager.get_unread_message_count(sess)
return HttpResponse(str(result))
except:
return HttpResponse("0")
开发者ID:hodduc,项目名称:arara,代码行数:8,代码来源:views.py
示例19: account
def account(request):
session_key, r = warara.check_logged_in(request)
server = warara_middleware.get_server()
account = server.member_manager.get_info(session_key)
account.last_logout_time = timestamp2datetime(account.last_logout_time)
account.logged_in = True
rendered = render_to_string('account/myaccount_frame.html', account.__dict__)
return HttpResponse(rendered)
开发者ID:hodduc,项目名称:arara,代码行数:9,代码来源:views.py
示例20: file_download
def file_download(request, board_name, article_root_id, article_id, file_id):
server = warara_middleware.get_server()
file = {}
file= server.file_manager.download_file(int(article_id), int(file_id))
file_ob = open("%s/%s/%s" % (FILE_DIR, file.file_path, file.saved_filename))
response = HttpResponse(file_ob, mimetype="application/x-forcedownload")
response['Content-Disposition'] = "attachment; filename=" + unicode(file.real_filename).encode('cp949', 'replace')
return response
开发者ID:hodduc,项目名称:arara,代码行数:9,代码来源:views.py
注:本文中的warara.warara_middleware.get_server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论