changeset 1103:db787cef1385

handled some XXXs
author Richard Jones <richard@users.sourceforge.net>
date Tue, 10 Sep 2002 12:44:42 +0000
parents d94bd5369456
children d759c3cb1f06
files roundup/admin.py roundup/backends/back_anydbm.py roundup/cgi/client.py roundup/cgi/templating.py roundup/date.py roundup/init.py roundup/mailgw.py roundup/roundupdb.py
diffstat 8 files changed, 97 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/admin.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/admin.py	Tue Sep 10 12:44:42 2002 +0000
@@ -16,7 +16,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: admin.py,v 1.27 2002-09-10 07:07:16 richard Exp $
+# $Id: admin.py,v 1.28 2002-09-10 12:44:42 richard Exp $
 
 import sys, os, getpass, getopt, re, UserDict, shlex, shutil
 try:
@@ -811,11 +811,11 @@
 
     def do_export(self, args):
         '''Usage: export [class[,class]] export_dir
-        Export the database to tab-separated-value files.
+        Export the database to colon-separated-value files.
 
         This action exports the current data from the database into
-        tab-separated-value files that are placed in the nominated destination
-        directory. The journals are not exported.
+        colon-separated-value files that are placed in the nominated
+        destination directory. The journals are not exported.
         '''
         # we need the CSV module
         if csv is None:
@@ -862,9 +862,9 @@
         The imported nodes will have the same nodeid as defined in the
         import file, thus replacing any existing content.
 
-        XXX The new nodes are added to the existing database - if you want to
-        XXX create a new database using the imported data, then create a new
-        XXX database (or, tediously, retire all the old data.)
+        The new nodes are added to the existing database - if you want to
+        create a new database using the imported data, then create a new
+        database (or, tediously, retire all the old data.)
         '''
         if len(args) < 1:
             raise UsageError, _('Not enough arguments supplied')
--- a/roundup/backends/back_anydbm.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/backends/back_anydbm.py	Tue Sep 10 12:44:42 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.74 2002-09-10 08:04:56 richard Exp $
+#$Id: back_anydbm.py,v 1.75 2002-09-10 12:44:42 richard Exp $
 '''
 This module defines a backend that saves the hyperdatabase in a database
 chosen by anydbm. It is guaranteed to always be available in python
@@ -1001,7 +1001,7 @@
 
         return d[propname]
 
-    # XXX not in spec
+    # not in spec
     def getnode(self, nodeid, cache=1):
         ''' Return a convenience wrapper for the node.
 
@@ -1368,7 +1368,7 @@
             cldb.close()
         raise KeyError, keyvalue
 
-    # XXX: change from spec - allows multiple props to match
+    # change from spec - allows multiple props to match
     def find(self, **propspec):
         '''Get the ids of nodes in this class which link to the given nodes.
 
@@ -1881,7 +1881,7 @@
         self.db.indexer.add_text((self.classname, nodeid, 'content'), content,
             mime_type)
 
-# XXX deviation from spec - was called ItemClass
+# deviation from spec - was called ItemClass
 class IssueClass(Class, roundupdb.IssueClass):
     # Overridden methods:
     def __init__(self, db, classname, **properties):
--- a/roundup/cgi/client.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/cgi/client.py	Tue Sep 10 12:44:42 2002 +0000
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.26 2002-09-10 03:01:18 richard Exp $
+# $Id: client.py,v 1.27 2002-09-10 12:44:42 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -317,7 +317,7 @@
         ''' Return a PageTemplate for the named page
         '''
         pt = getTemplate(self.instance.config.TEMPLATES, name, extension)
-        # XXX handle PT rendering errors here more nicely
+        # catch errors so we can handle PT rendering errors more nicely
         try:
             # let the template render figure stuff out
             return pt.render(self, None, None, **kwargs)
--- a/roundup/cgi/templating.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/cgi/templating.py	Tue Sep 10 12:44:42 2002 +0000
@@ -222,7 +222,7 @@
     def __getitem__(self, item):
         ''' return an HTMLProperty instance
         '''
-        #print 'getitem', (self, item)
+       #print 'HTMLClass.getitem', (self, item)
 
         # we don't exist
         if item == 'id':
@@ -378,7 +378,7 @@
     def __getitem__(self, item):
         ''' return an HTMLProperty instance
         '''
-        #print 'getitem', (self, item)
+       #print 'HTMLItem.getitem', (self, item)
         if item == 'id':
             return self._nodeid
 
@@ -411,7 +411,12 @@
         return '  <input type="hidden" name=":action" value="edit">\n'\
         '  <input type="submit" name="submit" value="%s">'%label
 
-    # XXX this probably should just return the history items, not the HTML
+    def journal(self, direction='descending'):
+        ''' Return a list of HTMLJournalEntry instances.
+        '''
+        # XXX do this
+        return []
+
     def history(self, direction='descending'):
         l = ['<table class="history">'
              '<tr><th colspan="4" class="header">',
@@ -753,13 +758,13 @@
     '''
     def __getattr__(self, attr):
         ''' return a new HTMLItem '''
-        #print 'getattr', (self, attr, self._value)
+       #print 'Link.getattr', (self, attr, self._value)
         if not self._value:
             raise AttributeError, "Can't access missing value"
         if self._prop.classname == 'user':
-            klass = HTMLItem
+            klass = HTMLUser
         else:
-            klass = HTMLUser
+            klass = HTMLItem
         i = klass(self._client, self._prop.classname, self._value)
         return getattr(i, attr)
 
@@ -865,7 +870,7 @@
     def __getitem__(self, num):
         ''' iterate and return a new HTMLItem
         '''
-        #print 'getitem', (self, num)
+       #print 'Multi.getitem', (self, num)
         value = self._value[num]
         if self._prop.classname == 'user':
             klass = HTMLUser
@@ -873,6 +878,11 @@
             klass = HTMLItem
         return klass(self._client, self._prop.classname, value)
 
+    def __contains__(self, value):
+        ''' Support the "in" operator
+        '''
+        return value in self._value
+
     def reverse(self):
         ''' return the list in reverse order
         '''
--- a/roundup/date.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/date.py	Tue Sep 10 12:44:42 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: date.py,v 1.27 2002-09-10 01:27:13 richard Exp $
+# $Id: date.py,v 1.28 2002-09-10 12:44:42 richard Exp $
 
 __doc__ = """
 Date, time and time interval handling.
@@ -153,7 +153,7 @@
         """
         return Date(self.addInterval(interval))
 
-    # XXX deviates from spec to allow subtraction of dates as well
+    # deviates from spec to allow subtraction of dates as well
     def __sub__(self, other):
         """ Subtract:
              1. an interval from this date to produce another date.
--- a/roundup/init.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/init.py	Tue Sep 10 12:44:42 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: init.py,v 1.23 2002-09-09 23:55:19 richard Exp $
+# $Id: init.py,v 1.24 2002-09-10 12:44:42 richard Exp $
 
 __doc__ = """
 Init (create) a roundup instance.
@@ -36,7 +36,7 @@
     it is false, the contents of the files pointed to by symbolic
     links are copied.
 
-    XXX copied from shutil.py in std lib
+    This was copied from shutil.py in std lib.
 
     """
     names = os.listdir(src)
--- a/roundup/mailgw.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/mailgw.py	Tue Sep 10 12:44:42 2002 +0000
@@ -73,7 +73,7 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception. 
 
-$Id: mailgw.py,v 1.85 2002-09-10 03:01:18 richard Exp $
+$Id: mailgw.py,v 1.86 2002-09-10 12:44:42 richard Exp $
 '''
 
 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -392,6 +392,63 @@
 '''%(nodeid, subject)
 
         #
+        # handle the users
+        #
+        # Don't create users if anonymous isn't allowed to register
+        create = 1
+        anonid = self.db.user.lookup('anonymous')
+        if not self.db.security.hasPermission('Email Registration', anonid):
+            create = 0
+
+        # ok, now figure out who the author is - create a new user if the
+        # "create" flag is true
+        author = uidFromAddress(self.db, message.getaddrlist('from')[0],
+            create=create)
+
+        # no author? means we're not author
+        if not author:
+            raise Unauthorized, '''
+You are not a registered user.
+
+Unknown address: %s
+'''%message.getaddrlist('from')[0][1]
+
+        # make sure the author has permission to use the email interface
+        if not self.db.security.hasPermission('Email Access', author):
+            raise Unauthorized, 'You are not permitted to access this tracker.'
+
+        # make sure they're allowed to edit this class of information
+        if not self.db.security.hasPermission('Edit', author, classname):
+            raise Unauthorized, 'You are not permitted to edit %s.'%classname
+
+        # the author may have been created - make sure the change is
+        # committed before we reopen the database
+        self.db.commit()
+
+        # reopen the database as the author
+        username = self.db.user.get(author, 'username')
+        self.db = self.instance.open(username)
+
+        # re-get the class with the new database connection
+        cl = self.db.getclass(classname)
+
+        # now update the recipients list
+        recipients = []
+        tracker_email = self.instance.config.TRACKER_EMAIL.lower()
+        for recipient in message.getaddrlist('to') + message.getaddrlist('cc'):
+            r = recipient[1].strip().lower()
+            if r == tracker_email or not r:
+                continue
+
+            # look up the recipient - create if necessary (and we're
+            # allowed to)
+            recipient = uidFromAddress(self.db, recipient, create)
+
+            # if all's well, add the recipient to the list
+            if recipient:
+                recipients.append(recipient)
+
+        #
         # extract the args
         #
         subject_args = m.group('args')
@@ -522,60 +579,6 @@
 '''%(errors, subject)
 
         #
-        # handle the users
-        #
-
-        # Don't create users if anonymous isn't allowed to register
-        create = 1
-        anonid = self.db.user.lookup('anonymous')
-        if not self.db.security.hasPermission('Email Registration', anonid):
-            create = 0
-
-        # ok, now figure out who the author is - create a new user if the
-        # "create" flag is true
-        author = uidFromAddress(self.db, message.getaddrlist('from')[0],
-            create=create)
-
-        # no author? means we're not author
-        if not author:
-            raise Unauthorized, '''
-You are not a registered user.
-
-Unknown address: %s
-'''%message.getaddrlist('from')[0][1]
-
-        # make sure the author has permission to use the email interface
-        if not self.db.security.hasPermission('Email Access', author):
-            raise Unauthorized, 'You are not permitted to access this tracker.'
-
-        # the author may have been created - make sure the change is
-        # committed before we reopen the database
-        self.db.commit()
-            
-        # reopen the database as the author
-        username = self.db.user.get(author, 'username')
-        self.db = self.instance.open(username)
-
-        # re-get the class with the new database connection
-        cl = self.db.getclass(classname)
-
-        # now update the recipients list
-        recipients = []
-        tracker_email = self.instance.config.TRACKER_EMAIL.lower()
-        for recipient in message.getaddrlist('to') + message.getaddrlist('cc'):
-            r = recipient[1].strip().lower()
-            if r == tracker_email or not r:
-                continue
-
-            # look up the recipient - create if necessary (and we're
-            # allowed to)
-            recipient = uidFromAddress(self.db, recipient, create)
-
-            # if all's well, add the recipient to the list
-            if recipient:
-                recipients.append(recipient)
-
-        #
         # handle message-id and in-reply-to
         #
         messageid = message.getheader('message-id')
--- a/roundup/roundupdb.py	Tue Sep 10 12:44:08 2002 +0000
+++ b/roundup/roundupdb.py	Tue Sep 10 12:44:42 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: roundupdb.py,v 1.66 2002-09-10 03:01:18 richard Exp $
+# $Id: roundupdb.py,v 1.67 2002-09-10 12:44:42 richard Exp $
 
 __doc__ = """
 Extending hyperdb with types specific to issue-tracking.
@@ -46,9 +46,11 @@
     pass
 
 class DetectorError(RuntimeError):
+    ''' Raised by detectors that want to indicate that something's amiss
+    '''
     pass
 
-# XXX deviation from spec - was called ItemClass
+# deviation from spec - was called IssueClass
 class IssueClass:
     """ This class is intended to be mixed-in with a hyperdb backend
         implementation. The backend should provide a mechanism that
@@ -134,7 +136,7 @@
             # send the message
             self.send_message(nodeid, msgid, note, sendto)
 
-    # XXX backwards compatibility - don't remove
+    # backwards compatibility - don't remove
     sendmessage = nosymessage
 
     def send_message(self, nodeid, msgid, note, sendto):

Roundup Issue Tracker: http://roundup-tracker.org/