notebook worksheet rating info?

1 view
Skip to first unread message

Kevin Horton

unread,
Aug 6, 2009, 8:01:06 PM8/6/09
to sage-s...@googlegroups.com
What is supposed to happen if one click's on a rating_info link in a
list of notebook worksheets? I've tried with three different browsers
on two computers, on both sagenb.org and on my personal local server,
and I always end up at a blank page titled "Error | Sage Notebook".
--
Kevin Horton
Ottawa, Canada

William Stein

unread,
Aug 6, 2009, 8:23:23 PM8/6/09
to sage-support


2009/8/6 Kevin Horton <khor...@rogers.com>

Well that's definitely *not* what is supposed to happen.  Can you open a trac ticket for this (write to me if you need a trac account)?  Thanks!!

William

NoSyu

unread,
Aug 6, 2009, 8:42:12 PM8/6/09
to sage-support
Hello

I see this problem few weeks ago.

So maybe someone find it and make a ticket.

I can't find ticket, so I write problems and solution in this article.


Here is the original source Sage 4.1 server/notebook/twist.py line
1266~1299

class Worksheet_rating_info(WorksheetResource, resource.Resource):
def render(self, ctx):
s = self.worksheet.html_ratings_info()
return HTMLResponse(stream=message('''
<h2 align=center>Ratings for %s</h2>
<h3 align=center><a href='/home/%s'>Go to the worksheet.</a>
<br><br>
<table width=70%%align=center border=1 cellpadding=10
cellspacing=0>
<tr bgcolor="#7799bb"><td width=30em>User</td><td width=10em
align=center>Rating</td><td width=10em align=center
width=60em>Comment</td></tr>
%s
</table>
<br><br>
'''%(self.worksheet.name(), self.worksheet.filename(), s)))


class Worksheet_rate(WorksheetResource, resource.Resource):
def render(self, ctx):
ret = '/home/' + self.worksheet.filename()
#if self.worksheet.is_rater(self.username):
# return HTMLResponse(stream=message("You have already
rated the worksheet <i><b>%s</b></i>."%self.worksheet.name(), ret))
if user_type(self.username) == "guest":
return HTMLResponse(stream = message(
'You must <a href="/">login first</a> in order to rate
this worksheet.', ret))

rating = int(ctx.args['rating'][0])
if rating < 0 or rating >= 5:
return HTMLResponse(stream = message(
"Gees -- You can't fool the rating system that
easily!", ret))
comment = ctx.args['comment'][0]
self.worksheet.rate(rating, comment, self.username)
return HTMLResponse(stream=message("""
Thank you for rating the worksheet <b><i>%s</i></b>!
You can <a href="rating_info">see all ratings of this
worksheet.</a>
"""%self.worksheet.name(), '/pub/'))


and here is fixed soruce.

class Worksheet_rating_info(WorksheetResource, resource.Resource):
def render(self, ctx):
s = self.worksheet.html_ratings_info()
return HTMLResponse(stream='''
<h2 align=center>Ratings for %s</h2>
<h3 align=center><a href='/home/%s'>Go to the worksheet.</a>
<br><br>
<table width=70%%align=center border=1 cellpadding=10
cellspacing=0>
<tr bgcolor="#7799bb"><td width=30em>User</td><td width=10em
align=center>Rating</td><td width=10em align=center
width=60em>Comment</td></tr>
%s
</table>
<br><br>
'''%(self.worksheet.name(), self.worksheet.filename(), s))


class Worksheet_rate(WorksheetResource, resource.Resource):
def render(self, ctx):
ret = '/home/' + self.worksheet.filename()
#if self.worksheet.is_rater(self.username):
# return HTMLResponse(stream=message("You have already
rated the worksheet <i><b>%s</b></i>."%self.worksheet.name(), ret))
if user_type(self.username) == "guest":
return HTMLResponse(stream = message(
'You must <a href="/">login first</a> in order to rate
this worksheet.', ret))

rating = int(ctx.args['rating'][0])
if rating < 0 or rating >= 5:
return HTMLResponse(stream = message(
"Gees -- You can't fool the rating system that
easily!", ret))
comment = ctx.args['comment'][0]
self.worksheet.rate(rating, comment, self.username)
return HTMLResponse(stream="""
Thank you for rating the worksheet <b><i>%s</i></b>!
You can <a href="rating_info">see all ratings of this
worksheet.</a>
"""%self.worksheet.name())


The problem is that if the right result, it use message function.

message function is like this.

############################
# An error message
############################
def message(msg, cont=None):
template_dict = {'msg': msg, 'cont': cont}
return template('error_message.html', **template_dict)

It use for error page. But original source use it to show right result
such as rate and raing_info page.

Can I make a ticket for this?

누구나가 다, 자기 옆에서 눈물을 흘리며 신음하는 불행한 사람들에 비해 자기가 훨씬 더 불행하다고 생각하지요. 이게 바로 우리
가련한 인간들의 오만 중 하나입니다.

- 몬테크리스토 백작

it is the infirmity of our nature always to believe ourselves much
more unhappy than those who groan by our sides!

- The Count of Monte Cristo

c'est un des orgueils de notre pauvre humanité, que chaque homme se
croie plus malheureux qu'un autre malheureux qui pleure et qui gémit à
côté de lui

- Le Comte de Monte-Cristo



박진영 - Bak JinYeong

학부재학생 - Undergraduate

컴퓨터공학전공 - Department of Computer Engineering

정보통신공학부 - School of Information & Communication Engineering

성균관대학교 - SungKyunKwan University

블로그 - http://nosyu.pe.kr

이메일 - don...@skku.edu

Kevin Horton

unread,
Aug 7, 2009, 5:26:09 AM8/7/09
to sage-s...@googlegroups.com

I tried this proposed fix on sage-4.1, and it did not change the
result I get if clicking on the rating_info link for an unrated
worksheet.

Kevin Horton

unread,
Aug 7, 2009, 5:31:08 AM8/7/09
to sage-s...@googlegroups.com

This is now ticket 6683.

NoSyu

unread,
Aug 7, 2009, 8:33:45 AM8/7/09
to sage-support
I modify the only this from sage 4.1 source like this.

/server/notebook/twisted.py
I remove message function twice.

Here is my temporary sage server 4.1

http://nosyu.homeip.net:8000/pub/

It works fine when I click the unrated post and other things.

------------------------------------------------------------------------

누구나가 다, 자기 옆에서 눈물을 흘리며 신음하는 불행한 사람들에 비해 자기가 훨씬 더 불행하다고 생각하지요. 이게 바로 우리
가련한 인간들의 오만 중 하나입니다.

- 몬테크리스토 백작

it is the infirmity of our nature always to believe ourselves much
more unhappy than those who groan by our sides!

- The Count of Monte Cristo

c'est un des orgueils de notre pauvre humanité, que chaque homme se
croie plus malheureux qu'un autre malheureux qui pleure et qui gémit à
côté de lui

- Le Comte de Monte-Cristo



박진영 - Bak JinYeong

학부재학생 - Undergraduate

컴퓨터공학전공 - Department of Computer Engineering

정보통신공학부 - School of Information & Communication Engineering

성균관대학교 - SungKyunKwan University

블로그 - http://nosyu.pe.kr

이메일 - don...@skku.edu

Reply all
Reply to author
Forward
0 new messages