[or-cvs] r21931: {weather} Small bugfixes, make a page look more nice (in weather/trunk: . lib/weather)

Christian Fromme kaner at strace.org
Fri Mar 12 19:22:56 UTC 2010


Author: kaner
Date: 2010-03-12 19:22:56 +0000 (Fri, 12 Mar 2010)
New Revision: 21931

Modified:
   weather/trunk/Weather.py
   weather/trunk/lib/weather/constants.py
   weather/trunk/lib/weather/utils.py
Log:
Small bugfixes, make a page look more nice


Modified: weather/trunk/Weather.py
===================================================================
--- weather/trunk/Weather.py	2010-03-12 18:39:42 UTC (rev 21930)
+++ weather/trunk/Weather.py	2010-03-12 19:22:56 UTC (rev 21931)
@@ -8,7 +8,7 @@
 from twisted.internet import reactor
 from twisted.internet.task import LoopingCall 
 
-from weather.constants import PAGE_TEMPLATE, PAGE_SIGNUP
+from weather.constants import PAGE_TEMPLATE, PAGE_SIGNUP, CONFIRMATION_MAIL, THANKS_OUT, PAGE_SUB_FIN
 from weather.queries import CHECK_SUBS_Q, INSERT_SUBS_Q, CHECK_SUBS_AUTH_Q, ACK_SUB_Q, UNSUBSCRIBE_Q
 from weather.poller import WeatherPoller
 from weather.config import pollPeriod, URLbase, mailFrom
@@ -68,6 +68,7 @@
         except Exception, e:
             self.error = "Unknown error while sending confirmation mail. " + \
                          "Please try again later."
+            print e
             #             "[Exception %s]" % sys.exc_info()[0]
             self._rollBack()
             return
@@ -83,7 +84,7 @@
         q.addCallback(self._errOut)
         q.addErrback(self._errback)
 
-    def _errOut(self, result):
+    def _errOut(self):
         self.request.setResponseCode(http.INTERNAL_SERVER_ERROR)
         self.request.write(utils.pageOut(self.error))
         self.request.finish()
@@ -126,10 +127,7 @@
     def _subDone(self, result, request):
         url = URLbase + "/unsubscribe?auth=" + self.unsubs_auth
         link = "<a href=\"" + url + "\">" + url + "</a>"
-        pageout = "<p>Subscription finished. Thank you very much."
-        pageout += "You can unsubscribe anytime with the following link: "
-        pageout += link
-        pageout += "</p>"
+        pageout = PAGE_SUB_FIN % link
         request.write(utils.pageOut(pageout))
         request.finish()
 

Modified: weather/trunk/lib/weather/constants.py
===================================================================
--- weather/trunk/lib/weather/constants.py	2010-03-12 18:39:42 UTC (rev 21930)
+++ weather/trunk/lib/weather/constants.py	2010-03-12 19:22:56 UTC (rev 21931)
@@ -104,3 +104,16 @@
 <p><i>Please note that while we won't ever intentionally publish them, the address/node pairs sent to this server are not protected against SMTP eavesdropping, hacking, or lawyers.</i>
 </form>
 """
+
+PAGE_SUB_FIN = """
+<p>
+Subscription finished.
+</p>
+<p>
+Thank you very much.
+</p>
+<p>
+You can unsubscribe anytime with the following link: <br/>
+%s
+</p>
+"""

Modified: weather/trunk/lib/weather/utils.py
===================================================================
--- weather/trunk/lib/weather/utils.py	2010-03-12 18:39:42 UTC (rev 21930)
+++ weather/trunk/lib/weather/utils.py	2010-03-12 19:22:56 UTC (rev 21931)
@@ -16,7 +16,7 @@
 from weather.queries import CREATE_TABLE_Q
 
 def setupDBConn(databaseName):
-    """Create database and table in case they don't exist yet"""
+    """Create database and table in case they don't exist yet, return pool"""
     db = sqlite3.connect(databaseName)
     db.execute(CREATE_TABLE_Q % "subscriptions")
     db.close()
@@ -54,7 +54,7 @@
     """Produce a random alphanumeric string for authentication"""
     r = base64.urlsafe_b64encode(os.urandom(18))[:-1]
     # some email clients don't like URLs ending in -
-    if r[-1] == "-":    
+    if r.endswith("-"):    
         r.replace("-", "x")
     return r
 



More information about the tor-commits mailing list