[Pypi-checkins] r903 - in trunk/pypi: . templates

martin.von.loewis python-checkins at python.org
Wed Apr 6 20:34:51 CEST 2011


Author: martin.von.loewis
Date: Wed Apr  6 20:34:51 2011
New Revision: 903

Removed:
   trunk/pypi/templates/comment.pt
Modified:
   trunk/pypi/admin.py
   trunk/pypi/rpc.py
   trunk/pypi/store.py
   trunk/pypi/templates/display.pt
   trunk/pypi/templates/pkg_edit.pt
   trunk/pypi/webui.py
Log:
Remove rating feature.


Modified: trunk/pypi/admin.py
==============================================================================
--- trunk/pypi/admin.py	(original)
+++ trunk/pypi/admin.py	Wed Apr  6 20:34:51 2011
@@ -97,15 +97,6 @@
            print "Deleting", path
            shutil.rmtree(path)
 
-def send_comments(store):
-    '''Send out comments to package owners. Normally, this will
-    be done automatically, but the very first comments had not been sent.'''
-    import webui
-    c = store.get_cursor()
-    c.execute("select name, version, user_name, message from ratings where message!=''")
-    for package, version, author, comment in c.fetchall():
-        webui.comment_email(store, package, version, author, comment)
-
 def merge_user(store, old, new):
     c = store.get_cursor()
     if not store.get_user(old):

Modified: trunk/pypi/rpc.py
==============================================================================
--- trunk/pypi/rpc.py	(original)
+++ trunk/pypi/rpc.py	Wed Apr  6 20:34:51 2011
@@ -24,7 +24,6 @@
         self.register_function(updated_releases)
         self.register_function(changelog)
         self.register_function(post_cheesecake_for_release)
-        self.register_function(ratings)
         self.register_introspection_functions()
         self.register_multicall_functions()
 
@@ -120,16 +119,4 @@
     store.save_cheesecake_score(name, version, score_data)
     store.commit()
 
-def ratings(store, name, version, since):
-    ratings, comments = store.all_ratings(name, version, since)
-    for i, r in enumerate(ratings):
-        r = list(r)
-        r[3] = int(time.mktime(r[3].timetuple()))
-        ratings[i] = tuple(r)
-    for i, c in enumerate(comments):
-        c = list(c)
-        c[5] = int(time.mktime(c[5].timetuple()))
-        comments[i] = c
-    return ratings, comments
-
 handle_request = RequestHandler()

Modified: trunk/pypi/store.py
==============================================================================
--- trunk/pypi/store.py	(original)
+++ trunk/pypi/store.py	Wed Apr  6 20:34:51 2011
@@ -788,17 +788,6 @@
             project_urls.append(project[0].split(','))
         return project_urls
 
-    def get_package_comments(self, name):
-        cursor = self.get_cursor()
-        safe_execute(cursor, 'select comments from packages where name=%s',
-                     [name])
-        return cursor.fetchall()[0][0]
-
-    def set_package_comments(self, name, value):
-        cursor = self.get_cursor()
-        safe_execute(cursor, 'update packages set comments=%s where name=%s',
-                     [value, name])
-
     def get_unique(self, iterable):
         ''' Iterate over list of (name,version,date,summary) tuples
             and return list of unique (taking name and version into
@@ -1082,168 +1071,6 @@
                                               self.username,
                                               self.userip))
 
-    def add_rating(self, name, version, rating, message):
-        '''Add a user rating of a release; message is optional'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''insert into ratings (name, version, user_name, date, rating)
-                     values(%s, %s, %s, current_timestamp, %s)''', (name, version, self.username, rating))
-        if message:
-            safe_execute(cursor, '''insert into comments(rating, user_name, date, message, in_reply_to)
-                                    values(%s, %%s, current_timestamp, %%s, NULL)'''
-                         % self.last_id('ratings'),
-                         (self.username, message))
-            safe_execute(cursor, '''insert into comments_journal(name, version, id, submitted_by, date, action)
-                                    values(%%s, %%s, %s, %%s, current_timestamp, %%s)'''
-                         % self.last_id('comments'),
-                         (name, version, self.username, 'add_rating %r' % message))
-
-    def copy_rating(self, name, fromversion, toversion):
-        '''Copy a user-s rating of package name from one version to another;
-        return the comment if any'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''insert into ratings(name,version,user_name,date,rating)
-                     select name,%s,user_name,current_timestamp,rating from ratings
-                     where name=%s and version=%s and user_name=%s''',
-                     (toversion, name, fromversion, self.username))
-        # only copy comment, not follow-ups
-        safe_execute(cursor, 'select c.id from comments c, ratings r where c.rating=r.id and r.name=%s and r.version=%s', (name, fromversion))
-        cid = cursor.fetchone()
-        if cid:
-            cid = cid[0]
-            safe_execute(cursor, '''insert into comments(rating, user_name, date, message, in_reply_to)
-                     select %s, user_name, date, message, in_reply_to
-                     from comments where id=%%s''' % self.last_id('ratings'), (cid,))
-            safe_execute(cursor, '''insert into comments_journal(name, version, id, submitted_by, date, action)
-                     values(%%s, %%s, %s, %%s, current_timestamp, %%s)''' % self.last_id('comments'),
-                     (name, toversion, self.username, 'copied %s' % cid))
-
-            safe_execute(cursor, '''select message from comments
-                     where id=%s''', (cid,))
-            return cursor.fetchone()[0]
-        return None
-
-    def remove_rating(self, name, version):
-        '''Remove a rating for the current user'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, """insert into comments_journal(name, version, id, submitted_by, date, action)
-        select %s, %s, id, %s, current_timestamp, 'deleted' from ratings where user_name=%s and name=%s and version=%s""",
-                     (name, version, self.username, self.username, name, version))
-        safe_execute(cursor, "delete from ratings where user_name=%s and name=%s and version=%s",
-                     (self.username, name, version))
-
-    _Rating=FastResultRow('id! date! user rating!')
-    _Comment=FastResultRow('id! rating! user date! message in_reply_to!')
-    def get_ratings(self, name, version):
-        '''Return ratings,messages for a release.'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''select id, date, user_name, rating from ratings
-                     where name=%s and version=%s order by date''', (name, version))
-        res = cursor.fetchall()
-        safe_execute(cursor, '''select c.id, c.rating, c.user_name, c.date, c.message, c.in_reply_to from
-                     ratings r, comments c where r.name=%s and r.version=%s and r.id=c.rating order by c.date''', (name, version))
-        res2 = cursor.fetchall()
-        return Result(None, res, self._Rating), Result(None, res2, self._Comment)
-
-    def get_comment(self, id):
-        '''Return a single comment.'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''select id, rating, user_name, date, message, in_reply_to from
-                     comments where id=%s''', (id,))
-        res = cursor.fetchall()
-        if res:
-            return self._Comment(None, res[0])
-        else:
-            return None
-
-    def add_comment(self, msg, comment):
-        "Add a comment as a reply to msg. Return name and version"
-        cursor = self.get_cursor()
-        safe_execute(cursor, "select c.rating, r.name, r.version from comments c, ratings r where c.id=%s and c.rating=r.id", (msg,))
-        rating, name, version = cursor.fetchone()
-        safe_execute(cursor, '''insert into comments(rating, user_name, date, message, in_reply_to)
-                     values(%s,%s,current_timestamp,%s,%s)''', (rating, self.username, comment, msg))
-        safe_execute(cursor, '''insert into comments_journal(name, version, id, submitted_by, date, action)
-                     values(%%s, %%s, %s, %%s, current_timestamp, %%s)''' % self.last_id('comments'),
-                     (name, version, self.username, 'add %s %r' % (msg, comment)))
-        return name, version
-
-    def remove_comment(self, msg):
-        "Delete a comment and all its follow-ups."
-        cursor = self.get_cursor()
-        safe_execute(cursor, "select r.name, r.version from ratings r, comments c where c.id=%s and r.id=c.rating", (msg,))
-        name, version = cursor.fetchone()
-        safe_execute(cursor, "delete from comments where id=%s", (msg,))
-        safe_execute(cursor, '''insert into comments_journal(name, version, id, submitted_by, date, action)
-                     values(%s, %s, %s, %s, current_timestamp, 'delete')''', (name, version, msg, self.username))
-
-    def has_package_comments(self, name):
-        "Return true if the package has any comments"
-        cursor = self.get_cursor()
-        safe_execute(cursor, """select r.name,count(*) from ratings r,comments c
-                     where r.id=c.rating and r.name=%s group by(r.name)""", (name,))
-        return len(cursor.fetchall()) > 0
-
-    def get_package_commenters(self, name):
-        "Return the email addresses of all commenters on a package."
-        cursor = self.get_cursor()
-        safe_execute(cursor, """select distinct(email) from ratings r,comments c,users u
-                     where r.id=c.rating and r.name=%s and c.user_name=u.name""", (name,))
-        return [r[0] for r in cursor.fetchall()]
-
-    _AllRatings=FastResultRow('name version user_name date! rating! message')
-    def all_ratings(self, name, version, date):
-        '''Return all ratings since UTC timestamp. name and version may be None.'''
-        cursor = self.get_cursor()
-        date = time.strftime('%Y-%m-%d %H:%M:%S +0000', time.gmtime(date))
-        if name:
-            if version:
-                safe_execute(cursor, '''select name, version, user_name, date, rating
-                from ratings where name=%s and version=%s and date > %s''', (name, version, date))
-                ratings = cursor.fetchall()
-                safe_execute(cursor, '''select c.id, c.in_reply_to, r.name, r.version,
-                c.user_name, c.date, c.message
-                from ratings r, comments c where
-                r.name=%s and r.version=%s and r.id=c.rating and c.date > %s''',
-                             (name, version, date))
-                comments = cursor.fetchall()
-            else:
-                safe_execute(cursor, '''select name, version, user_name, date, rating
-                from ratings where name=%s and date > %s''', (name,date))
-                ratings = cursor.fetchall()
-                safe_execute(cursor, '''select c.id, c.in_reply_to, r.name, r.version,
-                c.user_name, c.date, c.message
-                from ratings r, comments c where
-                r.name=%s and r.id=c.rating and c.date > %s''',
-                             (name, date))
-                comments = cursor.fetchall()
-        else:
-                safe_execute(cursor, '''select name, version, user_name, date, rating
-                from ratings where date > %s''', (date,))
-                ratings = cursor.fetchall()
-                safe_execute(cursor, '''select c.id, c.in_reply_to, r.name, r.version,
-                c.user_name, c.date, c.message
-                from ratings r, comments c where
-                r.id=c.rating and c.date > %s''', (date,))
-                comments = cursor.fetchall()
-        return ratings, comments
-
-    def has_rating(self, name, version):
-        '''Check whether user has rated this release'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''select count(*) from ratings
-                     where user_name=%s and name=%s and version=%s''', (self.username, name, version))
-        return cursor.fetchall()[0][0]
-
-    def latest_rating(self, name):
-        '''Return the user-s latest rating on any release, or None.'''
-        cursor = self.get_cursor()
-        safe_execute(cursor, '''select version from ratings
-                     where user_name=%s and name=%s order by date desc limit 1''', (self.username, name))
-        res = cursor.fetchone()
-        if res:
-            res = res[0]
-        return res
-
     def save_cheesecake_score(self, name, version, score_data):
         '''Save Cheesecake score for a release.
         '''

Deleted: /trunk/pypi/templates/comment.pt
==============================================================================
--- /trunk/pypi/templates/comment.pt	Wed Apr  6 20:34:51 2011
+++ (empty file)
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="standard_template/macros/page">
-
-<metal:fill fill-slot="head">
- <style type="text/css">
-  table.form th {white-space: pre;}
- </style>
-</metal:fill>
-
-<metal:fill fill-slot="body">
-<p>The comment from <span tal:replace="data/comment/user"/> said <cite tal:content="data/comment/message"/></p>
-<p>Your reply:
-<form tal:attributes="action app/url_path" method="POST">
-   <input type="hidden" name=":action" value="addcomment"/>
-   <input type="hidden" name="msg" tal:attributes="value data/comment/id"/>
-   <textarea name="comment" rows="5" cols="40" wrap="soft"> </textarea>
-   <br/>
-   <input type="submit"/>
-</form>
-</p>
-<p><em>Note:</em>If <span tal:replace="data/comment/user"/> deletes the original message, your response to it will also get deleted.</p>
-</metal:fill>
-</html>

Modified: trunk/pypi/templates/display.pt
==============================================================================
--- trunk/pypi/templates/display.pt	(original)
+++ trunk/pypi/templates/display.pt	Wed Apr  6 20:34:51 2011
@@ -244,72 +244,7 @@
 
 </ul>
 
-<div tal:condition="python:app.loggedin and not (app.store.has_role('Maintainer', data['name']) or app.store.has_role('Owner', data['name']))">
-  <div tal:condition="data/has_rated">
-    <form tal:attributes="action string:${app/url_path}/${data/name}/${data/version}" method="POST">
-      <input type="hidden" name=":action" value="rate"/>
-      <input type="hidden" name="name" tal:attributes="value data/name"/>
-      <input type="hidden" name="version" tal:attributes="value data/version"/>
-      <input type="submit" name="remove" value="Remove your rating" />
-    </form>
-  </div>
-  <div tal:condition="not:data/has_rated">
-    <form tal:attributes="action string:${app/url_path}/${data/name}/${data/version}" method="POST">
-      <input type="hidden" name=":action" value="rate"/>
-      <input type="hidden" name="name" tal:attributes="value data/name"/>
-      <input type="hidden" name="version" tal:attributes="value data/version"/>
-      <table>
-      <tr>
-      <td>Rate this release: 0</td>
-      <td><input type="radio" name="rating" value="0"/></td>
-      <td><input type="radio" name="rating" value="1"/></td>
-      <td><input type="radio" name="rating" value="2"/></td>
-      <td><input type="radio" name="rating" value="3"/></td>
-      <td><input type="radio" name="rating" value="4"/></td>
-      <td><input type="radio" name="rating" value="5"/></td>
-      <td>5 (best)</td>
-      </tr>
-      </table>
-      <table tal:condition="python:app.store.get_package_comments(data['name'])"><tr><td>Review: (<em>Please use the package's bug reporting channels <br/>(trackers, mailing lists) for bug reports and requests for help</em>)</td><td>
-         <!--XXX trick TAL into not minimizing tag-->
-         <textarea name="comment" rows="5" cols="40" wrap="soft"> </textarea>
-      </td></tr></table>
-      <input type="submit" name="rate" value="Rate"/>
-    </form>
-    <form tal:condition="data/latest_rating" tal:attributes="action string:${app/url_path}/${data/name}/${data/version}" method="POST">
-      <input type="hidden" name=":action" value="rate"/>
-      <input type="hidden" name="name" tal:attributes="value data/name"/>
-      <input type="hidden" name="version" tal:attributes="value data/version"/>
-      <input type="hidden" name="fromversion" tal:attributes="value data/latest_rating"/>
-      <input type="submit" name="copy" tal:attributes="value string:Copy your rating from release ${data/latest_rating}"/>
-    </form>
-  </div>
-</div>
-<div tal:condition="not:app/loggedin">
- <p><em>Log in to rate this package.</em></p>
-</div>
-
-<div tal:condition="data/nr_ratings">
-       Package rating (<span tal:replace="data/nr_ratings"/> vote<tal:block tal:condition="python:data['nr_ratings'] != 1">s</tal:block>): 
-       <span tal:replace="python:float(data['sum_ratings'])/data['nr_ratings']"/>
-
-  <ul>
-   <tal:block  tal:repeat="i python:range(6)">
-   <li tal:condition="python:data['tally_ratings'][i]">
-    <span tal:replace="i"/> point<tal:block tal:condition="python:i != 1">s</tal:block>:
-    <span tal:replace="python:data['tally_ratings'][i]"/> vote<tal:block tal:condition="python:data['tally_ratings'][i] != 1">s</tal:block>
-   </li>
-   </tal:block>
-  </ul>
-  <p>Ratings range from 0 to 5 (best).</p>
-</div>
-
-<div tal:condition="python:not app.store.get_package_comments(data['name'])">The package owner has disabled commenting on this package.</div>
-
-<div tal:condition="python:app.store.get_package_comments(data['name']) and data['comments']">
-<b>Package Comments:</b>
-<span tal:replace="structure data/comments"/>
-</div>
+<em>The rating feature has been removed. See <a href="http://mail.python.org/pipermail/catalog-sig/2011-April/thread.html">catalog-sig</a> for the discussion of this removal.</em>
 
 <table tal:condition="python:app.loggedin and (app.store.has_role('Admin') or
   app.store.has_role('Maintainer', data['name']) or app.store.has_role('Owner', data['name']))" class="history">

Modified: trunk/pypi/templates/pkg_edit.pt
==============================================================================
--- trunk/pypi/templates/pkg_edit.pt	(original)
+++ trunk/pypi/templates/pkg_edit.pt	Wed Apr  6 20:34:51 2011
@@ -83,12 +83,6 @@
   <input tal:condition="not:data/autohide" type="checkbox" name="autohide">Auto-hide old releases</input>
   <input type="submit" name="submit_autohide" value="Change" />
   <br/>
-  <input tal:condition="data/comments" type="checkbox" name="comments"
-         checked="checked">Allow comments on releases</input>
-  <input tal:condition="not:data/comments" type="checkbox" name="comments">Allow comments on releases</input>
-  <input type="submit" name="submit_comments" value="Change" />
-  <tal:block tal:condition="python:app.store.has_package_comments(data['name'])">
-  (commenters will be notified about this change)</tal:block>
 </form>
 
 <p>You can now host documentation at

Modified: trunk/pypi/webui.py
==============================================================================
--- trunk/pypi/webui.py	(original)
+++ trunk/pypi/webui.py	Wed Apr  6 20:34:51 2011
@@ -115,32 +115,6 @@
 <a href="%(url_path)s?:action=forgotten_password_form">reset for you</a>.</p>
 ''' + _prov
 
-comment_message = '''Subject: New comment on %(package)s
-From: PyPI operators <%(admin)s>
-To: %(email)s
-Reply-To: %(replyto)s
-
-[REPLIES TO THIS MESSAGE WILL NOT GO TO THE COMMENTER]
-%(author)s has made the following comment on your package:
-
-%(comment)s
-
-You can read all comments on %(url)s.
-'''
-
-rating_message = '''Subject: New rating on %(package)s
-From: PyPI operators <%(admin)s>
-To: %(email)s
-Reply-To: %(replyto)s
-
-[REPLIES TO THIS MESSAGE WILL NOT GO TO THE COMMENTER]
-%(author)s has rated your package as %(rating)s/5.  Comment (optional):
-
-%(comment)s
-
-You can read all comments on %(url)s.
-'''
-
 chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
 
 class Provider:
@@ -169,31 +143,6 @@
 else:
     PyPiPageTemplate = _PyPiPageTemplate
 
-def comment_email(store, package, version, author, comment, rating, add_recipients):
-    emails = set()
-    recipients = [r['user_name'] for r in store.get_package_roles(package)] + add_recipients
-    for r in recipients:
-        email = store.get_user(r)['email']
-        if email:
-            emails.add(email)
-    info = {
-        'package': package,
-        'admin': store.config.adminemail,
-        'replyto': store.config.replyto,
-        'author': author,
-        'email': ','.join(emails),
-        'comment': comment,
-        'url': '%s/%s/%s' % (store.config.url, package, version),
-        'rating': rating,
-        }
-    smtp = smtplib.SMTP(store.config.mailhost)
-    if rating is None:
-        message = comment_message % info
-    else:
-        message = rating_message % info
-    smtp.sendmail(store.config.adminemail, list(emails), message)
-
-
 class FileUpload:
     pass
 
@@ -571,8 +520,7 @@
         display register_form user_form forgotten_password_form user
         password_reset role role_form list_classifiers login logout files
         file_upload show_md5 doc_upload claim openid openid_return dropid
-        rate comment addcomment delcomment clear_auth addkey delkey lasthour
-        json gae_file about'''.split():
+        clear_auth addkey delkey lasthour json gae_file about'''.split():
             getattr(self, action)()
         else:
             #raise NotFound, 'Unknown action %s' % action
@@ -1328,20 +1276,6 @@
         latest_version_url = '%s/%s/%s' % (self.config.url, name,
                                            latest_version)
 
-        # Compute rating data
-        has_rated = self.loggedin and self.store.has_rating(name, version)
-        latest_rating = self.loggedin and self.store.latest_rating(name)
-        ratings, comments = self.store.get_ratings(name, version)
-        total = 0.0
-        hcomments = [] # as a hierarchy
-        parent_comments = {}
-        tally = [0]*6
-        rating_by_id = {}
-        for r in ratings:
-            rating_by_id[r['id']] = r
-            total += r['rating']
-            tally[r['rating']] += 1
-
         # New metadata
         requires_dist = self.store.get_package_requires_dist(name, version)
         provides_dist = self.store.get_package_provides_dist(name, version)
@@ -1349,51 +1283,6 @@
         project_url = self.store.get_package_project_url(name, version)
         requires_external = self.store.get_package_requires_external(name, version)
 
-        for c in comments:
-            add = c, []
-            parent_comments[c['id']] = add[1]
-            if c['in_reply_to']:
-                parent_comments[c['in_reply_to']].append(add)
-            else:
-                hcomments.append(add)
-
-        def render_comments(comments, toplevel):
-            if not comments:
-                return []
-            result = ["<ul>\n"]
-            for c,children in comments:
-                message = cgi.escape(c['message'])
-                message = '<br />'.join(message.split('\r\n'))
-                date = c['date'].strftime("%Y-%m-%d")
-                if not self.loggedin:
-                    reply = ''
-                elif self.username != c['user']:
-                    reply = " <a href='%s?:action=comment&msg=%d'>Reply</a>" % (self.url_path, c['id'])
-                elif toplevel:
-                    reply = ''
-                else:
-                    if children:
-                        msg = "Remove (including followups)"
-                    else:
-                        msg = "Remove"
-                    reply = " <a href='%s?:action=delcomment&msg=%d&name=%s&version=%s'>%s</a>" % (self.url_path, c['id'], name, version, msg)
-                if toplevel:
-                    rating = rating_by_id[c['rating']]['rating']
-                    if rating == 1:
-                        rating = ', 1 point'
-                    else:
-                        rating = ', %s points' % rating
-                else:
-                    rating = ''
-                result.append("<li class=\"comment\"><b>%s</b> (%s%s):<br/>%s %s" %
-                              (c['user'], date, rating, message, reply))
-                if children:
-                    result.extend(render_comments(children, False))
-                result.append("</li>\n")
-            result.append("</ul>\n")
-            return result
-        comments = "".join(render_comments(hcomments, True))
-
         docs = ''
         for sub in [[], ['html']]:
             path = [self.config.database_docs_dir, name.encode('utf8')] + sub + ['index.html']
@@ -1410,14 +1299,8 @@
                             requires=values('requires'),
                             provides=values('provides'),
                             obsoletes=values('obsoletes'),
-                            has_rated=has_rated,
-                            latest_rating=latest_rating,
                             files=files,
                             docs=docs,
-                            sum_ratings=total,
-                            nr_ratings=len(ratings),
-                            tally_ratings=tally,
-                            comments=comments,
                             categories=categories,
                             is_py3k=is_py3k,
                             roles=roles,
@@ -1958,10 +1841,6 @@
             value = self.form.has_key('autohide')
             self.store.set_package_autohide(name, value)
 
-        if self.form.has_key('submit_comments'):
-            value = self.form.has_key('comments')
-            self.store.set_package_comments(name, value)
-
         # look up the current info about the releases
         releases = list(self.store.get_package_releases(name))
         reldict = {}
@@ -1989,104 +1868,8 @@
 
         self.write_template('pkg_edit.pt', releases=releases, name=name,
                             autohide=self.store.get_package_autohide(name),
-                            comments=self.store.get_package_comments(name),
             title="Package '%s' Editing"%name)
 
-    def rate(self):
-        '''Add or delete a rating.'''
-        if not self.loggedin:
-            raise Unauthorised, "You need to login to rate"
-
-        name = self.form.get('name', '')
-        version = self.form.get('version', '')
-
-        if self.store.has_role('Owner', name) or self.store.has_role('Maintainer', name):
-            raise Forbidden, "You cannot rate your own packages"
-
-        if not name or not version:
-            raise FormError, 'name and version required'
-
-        if self.form.has_key('remove'):
-            if not self.store.has_rating(name, version):
-                raise Forbidden, "You did not rate that release"
-            self.store.remove_rating(name, version)
-            return self.display()
-
-        if self.form.has_key('copy'):
-            if self.store.has_rating(name, version):
-                raise Forbidden, "You have already rated this release"
-            if not self.form.has_key('fromversion'):
-                raise FormError, "fromversion missing"
-            comment = self.store.copy_rating(name, self.form['fromversion'], version)
-            if comment:
-                comment_email(self.store, name, version, self.username, comment,
-                              None, [])
-            return self.display()
-        if self.form.has_key('rate'):
-            if self.store.has_rating(name, version):
-                raise Forbidden, "You have already rated this release"
-            if not self.form.has_key('rating'):
-                raise FormError, "rating not provided"
-            message = self.form.get('comment', '').strip()
-            if message and not self.store.get_package_comments(name):
-                raise FormError, "package does not allow comments"
-            rating = self.form['rating']
-            self.store.add_rating(name, version, rating, message)
-            comment_email(self.store, name, version, self.username, message,
-                          rating, [])
-            return self.display()
-
-        raise FormError, "Bad button"
-
-    def comment(self):
-        'Ask for a follow-up comment'
-        if not self.form.has_key('msg'):
-            raise FormError
-        comment = self.store.get_comment(self.form['msg'])
-        self.write_template('comment.pt', title='Reply to comment',
-                            comment=comment)
-
-    def addcomment(self):
-        'Post a follow-up comment'
-        if not self.authenticated:
-            raise Unauthorised, "You need to be identified to post a comment"
-        if not self.form.has_key('msg') or not self.form.has_key('comment'):
-            raise FormError
-        msg = self.form['msg']
-        comment = self.form['comment']
-        orig = self.store.get_comment(msg)
-        if not orig:
-            raise FormError, "Invalid message"
-        if orig['user'] == self.username:
-            raise FormError, "You cannot respond to your own comments"
-        comment = comment.strip()
-        if not comment:
-            raise FormError, "You must fill in a comment"
-
-        name, version = self.store.add_comment(msg, comment)
-        comment_email(self.store, name, version, self.username, comment,
-                      None, [orig['user']])
-
-        return self.display(name=name, version=version)
-
-
-    def delcomment(self):
-        if not self.authenticated:
-            raise Unauthorised, \
-                "You must be identified to delete a comment"
-
-        if not self.form.has_key('msg'):
-            raise FormError
-
-        msg = self.form['msg']
-        comment = self.store.get_comment(msg)
-        if not comment:
-            raise FormError, "Invalid comment ID"
-        if comment['user'] != self.username or not comment['in_reply_to']:
-            raise FormError, "You cannot delete this comment" + comment['user']
-        self.store.remove_comment(comment['id'])
-        return self.display()
-
     def remove_pkg(self):
         ''' Remove a release or a whole package from the db.
 


More information about the Pypi-checkins mailing list