[Zope-CVS] CVS: Products/ZWiki - ZWikiPage.py:1.62

Ken Manheimer klm@zope.com
Thu, 13 Dec 2001 15:04:57 -0500


Update of /cvs-zopeorg/Products/ZWiki
In directory cvs.zope.org:/tmp/cvs-serv14948

Modified Files:
	ZWikiPage.py 
Log Message:
Polishing:

 - Do a better job getting the host name for the email subject line

 - Include a link to a search for all pages where you're subscribed.
   (The implementation of this may be more specific to zope.org than
   it needs to be.  Also, i didn't see an easy way to establish that
   there is a SiteIndex without provoking a dtml-if namespace bug i
   recently found, so i'm using heavy artillery - a try-except - for
   what should be a simple existence test.  Yuck.)

 - Some slight word crafting.


=== Products/ZWiki/ZWikiPage.py 1.61 => 1.62 ===
                 return "No update notice sent - no email addrs resolved"
             addrs = string.join(addrs_list, ', ')
-                
-            wiki_host = string.split(REQUEST.HTTP_HOST, ':')[0]
+
+            wiki_host = REQUEST.BASE0
+            if wiki_host[:7] == 'http://':
+                wiki_host = wiki_host[7:]
             sender_email = "webmaster@" + wiki_host
             userobj = getSecurityManager().getUser()
             userid = str(userobj)
@@ -1412,7 +1414,7 @@
 --
 %s
 --
-(To change your subscription, visit
+(To change your subscription, visit:
   %s/subscribeform )
 """ % (wiki_host,
        sender_email,
@@ -2986,9 +2988,9 @@
           username="REQUEST.AUTHENTICATED_USER.getUserName()"
           issuper="_.string.lower(username) in ['super', 'superuser']"
           isanon="_.string.lower(username) in ['anonymous', 'anonymous user']"
-          notallowed="issuper or isanon">
+          nonmember="issuper or isanon">
 
-<dtml-if notallowed>
+<dtml-if nonmember>
   <p>
     <font color="red">
       Note: superusers and anonymous users cannot subscribe. 
@@ -2997,13 +2999,13 @@
 </dtml-if>
 
 You are visiting as
-  <b> <dtml-var "REQUEST.AUTHENTICATED_USER.getUserName()"> </b>
+  <b> <dtml-var username> </b>
 <br>
 
 <FORM METHOD="POST" ACTION="&dtml-wiki_page_url;/subscribeform" ENCTYPE="multipart/form-data">
 
 Subscribers receive a copy of all edits via email.
-<dtml-if notallowed>
+<dtml-if nonmember>
   You have to login to
 <dtml-else>
   You can
@@ -3013,7 +3015,7 @@
 
 <br><br>
 
-<dtml-unless notallowed>
+<dtml-unless nonmember>
   <dtml-if email>
     Your email address:
   <dtml-else>
@@ -3030,7 +3032,7 @@
   <tr valign="top">
    <td valign="top">
 
-    <dtml-unless notallowed>
+    <dtml-unless nonmember>
       You are currently
       <b><dtml-unless isSubscriber>
       not
@@ -3061,8 +3063,8 @@
 
     <dtml-let n="subscriberCount()">
       There <dtml-if "n==1">is<dtml-else>are</dtml-if> &dtml-n; 
-      subscriber<dtml-unless "n==1">s</dtml-unless> to this page
-      <dtml-if n>:<br>
+      subscriber<dtml-unless "n==1">s</dtml-unless> of this 
+      page<dtml-if n>:<br>
       <dtml-in subscriberList>
       <dtml-var sequence-item><br>
       </dtml-in>
@@ -3073,7 +3075,7 @@
    </td>
    <td valign="top">
 
-    <dtml-unless notallowed>
+    <dtml-unless nonmember>
       You are currently
       <b><dtml-unless isWikiSubscriber>
       not
@@ -3089,14 +3091,12 @@
       <INPUT TYPE="submit" NAME="../wikiSubscribe:method"
              VALUE=" Subscribe to the whole wiki " style="font-weight:bold">
       </dtml-if>
-      <br>
-
-      <br>
+      <br> <br>
     </dtml-unless>
     <dtml-let n="wikiSubscriberCount()">
       There <dtml-if "n==1">is<dtml-else>are</dtml-if> &dtml-n; 
-      subscriber<dtml-unless "n==1">s</dtml-unless> to the whole wiki
-      <dtml-if n>:<br>
+      subscriber<dtml-unless "n==1">s</dtml-unless> of the whole 
+      wiki<dtml-if n>:<br>
       <dtml-in wikiSubscriberList>
       <dtml-var sequence-item><br>
       </dtml-in>
@@ -3105,6 +3105,22 @@
     </td>
     </tr>
 </table>
+
+<dtml-comment>
+  The following subscriptions search is probably specific to zope.org, and a
+  hack besides, sigh.  It depends on the SiteIndex having a 'subscribers'
+  index, and supporting a 'search?index=params' URL interface.
+</dtml-comment>
+<dtml-try>
+<dtml-if expr="(not nonmember)">
+  <dtml-let catalogurl="SiteIndex.absolute_url()">
+    Click <a href=
+     "&dtml-catalogurl;/search?subscribers=&dtml.url_quote-username;">here</a>
+    to search for all your page subscriptions.
+  </dtml-let>
+</dtml-if>
+<dtml-except NameError>
+</dtml-try>
 
 </FORM>
 </dtml-let>