mlhamel  committed c216a67

fix an ungly thing

  • Participants
  • Parent commits e5470bb

Comments (0)

Files changed (1)

File webui/

 # system imports
 import sys, os, urllib, cStringIO, traceback, cgi, binascii, getopt, md5
-import time, random, smtplib, base64, sha, email, types, stat, urlparse
+import smtplib, time, random, base64, sha, email, types, stat, urlparse
 import re, zipfile, logging, pprint, sets, shutil, Cookie, subprocess
 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
 from distutils.util import rfc822_escape
 import MailingLogger, openid
 from mini_pkg_resources import safe_name
-esc = cgi.escape
-esq = lambda x: cgi.escape(x, True)
-def enumerate(sequence):
-    return [(i, sequence[i]) for i in range(len(sequence))]
+from messages import \
+    rego_message, password_change_message, password_message, unauth_message, \
+    comment_message, comment_email
+from utils.string import newline_to_br, path2str, str2path
 safe_filenames = re.compile(r'.+?\.(exe|tar\.gz|bz2|rpm|deb|zip|tgz|egg|dmg|msi)$', re.I)
 safe_username = re.compile(r'^[A-Za-z0-9._]+$')
 __version__ = '1.1'
-# email sent to user indicating how they should complete their registration
-rego_message = '''Subject: Complete your Cheese Shop registration
-From: %(admin)s
-To: %(email)s
-To complete your registration of the user "%(name)s" with the python module
-index, please visit the following URL:
-  %(url)s?:action=user&otk=%(otk)s
-# password change request email
-password_change_message = '''Subject: Cheese Shop password change request
-From: %(admin)s
-To: %(email)s
-Someone, perhaps you, has requested that the password be changed for your
-username, "%(name)s". If you wish to proceed with the change, please follow
-the link below:
-  %(url)s?:action=password_reset&email=%(email)s
-You should then receive another email with the new password.
-# password reset email - indicates what the password is now
-password_message = '''Subject: Cheese Shop password has been reset
-From: %(admin)s
-To: %(email)s
-Your login is: %(name)s
-Your password is now: %(password)s
-unauth_message = '''
-<p>If you are a new user, <a href="%(url_path)s?:action=register_form">please
-<p>If you have forgotten your password, you can have it
-<a href="%(url_path)s?:action=forgotten_password_form">reset for you</a>.</p>
-comment_message = '''Subject: New comment on %(package)s
-From: PyPI operators <%(admin)s>
-To: %(email)s
-Reply-To: %(replyto)s
-%(author)s has made the following comment on your package.
-You can read all comments on %(url)s.
 chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
     PyPiPageTemplate = _PyPiPageTemplate
-def comment_email(store, package, version, author, comment, 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),
-        }
-    smtp = smtplib.SMTP(store.config.mailhost)
-    smtp.sendmail(store.config.adminemail, list(emails), comment_message % info)
 class FileUpload:
-# poor man's markup heuristics so we don't have to use <PRE>,
-# for when rst didn't work on the text...
-br_patt = re.compile(" *\r?\n\r?(?= +)")
-p_patt = re.compile(" *\r?\n(\r?\n)+")
-def newline_to_br(text):
-    text = re.sub(br_patt, "<BR/>", text)
-    return re.sub(p_patt, "\n<P>\n", text)
-def path2str(path):
-    return " :: ".join(path)
-def str2path(s):
-    return [ node.strip() for node in s.split("::") ]
 def transmute(field):
     if hasattr(field, 'filename') and field.filename:
         v = FileUpload()
         # now the package info
         keys = info.keys()
-        keypref = 'name version author author_email maintainer maintainer_email home_page download_url summary license description keywords platform'.split()
+        keypref = ['name', 'version', 'author', 'author_email', 'maintainer', 
+                   'maintainer_email', 'home_page', 'download_url', 'summary', 
+                   'license', 'description', 'keywords', 'platform']
         for key in keypref:
             value = info[key]
             if not value: