Code

Pagination of index pages.
[roundup.git] / roundup / cgi_client.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: cgi_client.py,v 1.133 2002-07-08 15:32:05 gmcm Exp $
20 __doc__ = """
21 WWW request handler (also used in the stand-alone server).
22 """
24 import os, cgi, StringIO, urlparse, re, traceback, mimetypes, urllib
25 import binascii, Cookie, time, random
27 import roundupdb, htmltemplate, date, hyperdb, password
28 from roundup.i18n import _
29 from roundup.indexer import Indexer
31 class Unauthorised(ValueError):
32     pass
34 class NotFound(ValueError):
35     pass
37 class Client:
38     '''
39     A note about login
40     ------------------
42     If the user has no login cookie, then they are anonymous. There
43     are two levels of anonymous use. If there is no 'anonymous' user, there
44     is no login at all and the database is opened in read-only mode. If the
45     'anonymous' user exists, the user is logged in using that user (though
46     there is no cookie). This allows them to modify the database, and all
47     modifications are attributed to the 'anonymous' user.
48     '''
50     def __init__(self, instance, request, env, form=None):
51         hyperdb.traceMark()
52         self.instance = instance
53         self.request = request
54         self.env = env
55         self.path = env['PATH_INFO']
56         self.split_path = self.path.split('/')
57         self.instance_path_name = env['INSTANCE_NAME']
58         url = self.env['SCRIPT_NAME'] + '/'
59         machine = self.env['SERVER_NAME']
60         port = self.env['SERVER_PORT']
61         if port != '80': machine = machine + ':' + port
62         self.base = urlparse.urlunparse(('http', env['HTTP_HOST'], url,
63             None, None, None))
65         if form is None:
66             self.form = cgi.FieldStorage(environ=env)
67         else:
68             self.form = form
69         self.headers_done = 0
70         try:
71             self.debug = int(env.get("ROUNDUP_DEBUG", 0))
72         except ValueError:
73             # someone gave us a non-int debug level, turn it off
74             self.debug = 0
76         # used for searching the indexes
77         self.indexer = Indexer('%s/db'%instance.INSTANCE_HOME)
80     def getuid(self):
81         try:
82             return self.db.user.lookup(self.user)
83         except KeyError:
84             if self.user is None:
85                 # user is not logged in and username 'anonymous' doesn't
86                 # exist in the database
87                 err = _('anonymous users have read-only access only')
88             else:
89                 err = _("sanity check: unknown user name `%s'")%self.user
90             raise Unauthorised, errmsg
92     def header(self, headers=None):
93         '''Put up the appropriate header.
94         '''
95         if headers is None:
96             headers = {'Content-Type':'text/html'}
97         if not headers.has_key('Content-Type'):
98             headers['Content-Type'] = 'text/html'
99         self.request.send_response(200)
100         for entry in headers.items():
101             self.request.send_header(*entry)
102         self.request.end_headers()
103         self.headers_done = 1
104         if self.debug:
105             self.headers_sent = headers
107     global_javascript = '''
108 <script language="javascript">
109 submitted = false;
110 function submit_once() {
111     if (submitted) {
112         alert("Your request is being processed.\\nPlease be patient.");
113         return 0;
114     }
115     submitted = true;
116     return 1;
119 function help_window(helpurl, width, height) {
120     HelpWin = window.open('%(base)s%(instance_path_name)s/' + helpurl, 'HelpWindow', 'scrollbars=yes,resizable=yes,toolbar=no,height='+height+',width='+width);
123 </script>
124 '''
125     def make_index_link(self, name):
126         '''Turn a configuration entry into a hyperlink...
127         '''
128         # get the link label and spec
129         spec = getattr(self.instance, name+'_INDEX')
131         d = {}
132         d[':sort'] = ','.join(map(urllib.quote, spec['SORT']))
133         d[':group'] = ','.join(map(urllib.quote, spec['GROUP']))
134         d[':filter'] = ','.join(map(urllib.quote, spec['FILTER']))
135         d[':columns'] = ','.join(map(urllib.quote, spec['COLUMNS']))
136         d[':pagesize'] = spec.get('PAGESIZE','50')
138         # snarf the filterspec
139         filterspec = spec['FILTERSPEC'].copy()
141         # now format the filterspec
142         for k, l in filterspec.items():
143             # fix up the CURRENT USER if needed (handle None too since that's
144             # the old flag value)
145             if l in (None, 'CURRENT USER'):
146                 if not self.user:
147                     continue
148                 l = [self.db.user.lookup(self.user)]
150             # add
151             d[urllib.quote(k)] = ','.join(map(urllib.quote, l))
153         # finally, format the URL
154         return '<a href="%s?%s">%s</a>'%(spec['CLASS'],
155             '&'.join([k+'='+v for k,v in d.items()]), spec['LABEL'])
158     def pagehead(self, title, message=None):
159         '''Display the page heading, with information about the tracker and
160             links to more information
161         '''
163         # include any important message
164         if message is not None:
165             message = _('<div class="system-msg">%(message)s</div>')%locals()
166         else:
167             message = ''
169         # style sheet (CSS)
170         style = open(os.path.join(self.instance.TEMPLATES, 'style.css')).read()
172         # figure who the user is
173         user_name = self.user or ''
174         if user_name not in ('', 'anonymous'):
175             userid = self.db.user.lookup(self.user)
176         else:
177             userid = None
179         # figure all the header links
180         if hasattr(self.instance, 'HEADER_INDEX_LINKS'):
181             links = []
182             for name in self.instance.HEADER_INDEX_LINKS:
183                 spec = getattr(self.instance, name + '_INDEX')
184                 # skip if we need to fill in the logged-in user id there's
185                 # no user logged in
186                 if (spec['FILTERSPEC'].has_key('assignedto') and
187                         spec['FILTERSPEC']['assignedto'] in ('CURRENT USER',
188                         None) and userid is None):
189                     continue
190                 links.append(self.make_index_link(name))
191         else:
192             # no config spec - hard-code
193             links = [
194                 _('All <a href="issue?status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>'),
195                 _('Unassigned <a href="issue?assignedto=-1&status=-1,unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=-activity&:filter=status,assignedto&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>')
196             ]
198         # if they're logged in, include links to their information, and the
199         # ability to add an issue
200         if user_name not in ('', 'anonymous'):
201             user_info = _('''
202 <a href="user%(userid)s">My Details</a> | <a href="logout">Logout</a>
203 ''')%locals()
205             # figure the "add class" links
206             if hasattr(self.instance, 'HEADER_ADD_LINKS'):
207                 classes = self.instance.HEADER_ADD_LINKS
208             else:
209                 classes = ['issue']
210             l = []
211             for class_name in classes:
212                 cap_class = class_name.capitalize()
213                 links.append(_('Add <a href="new%(class_name)s">'
214                     '%(cap_class)s</a>')%locals())
216             # if there's no config header link spec, force a user link here
217             if not hasattr(self.instance, 'HEADER_INDEX_LINKS'):
218                 links.append(_('<a href="issue?assignedto=%(userid)s&status=-1,unread,chatting,open,pending&:filter=status,resolution,assignedto&:sort=-activity&:columns=id,activity,status,resolution,title,creator&:group=type&show_customization=1">My Issues</a>')%locals())
219         else:
220             user_info = _('<a href="login">Login</a>')
221             add_links = ''
223         # if the user is admin, include admin links
224         admin_links = ''
225         if user_name == 'admin':
226             links.append(_('<a href="list_classes">Class List</a>'))
227             links.append(_('<a href="user">User List</a>'))
228             links.append(_('<a href="newuser">Add User</a>'))
230         # add the search links
231         if hasattr(self.instance, 'HEADER_SEARCH_LINKS'):
232             classes = self.instance.HEADER_SEARCH_LINKS
233         else:
234             classes = ['issue']
235         l = []
236         for class_name in classes:
237             cap_class = class_name.capitalize()
238             links.append(_('Search <a href="search%(class_name)s">'
239                 '%(cap_class)s</a>')%locals())
241         # now we have all the links, join 'em
242         links = '\n | '.join(links)
244         # include the javascript bit
245         global_javascript = self.global_javascript%self.__dict__
247         # finally, format the header
248         self.write(_('''<html><head>
249 <title>%(title)s</title>
250 <style type="text/css">%(style)s</style>
251 </head>
252 %(global_javascript)s
253 <body bgcolor=#ffffff>
254 %(message)s
255 <table width=100%% border=0 cellspacing=0 cellpadding=2>
256 <tr class="location-bar"><td><big><strong>%(title)s</strong></big></td>
257 <td align=right valign=bottom>%(user_name)s</td></tr>
258 <tr class="location-bar">
259 <td align=left>%(links)s</td>
260 <td align=right>%(user_info)s</td>
261 </table><br>
262 ''')%locals())
264     def pagefoot(self):
265         if self.debug:
266             self.write(_('<hr><small><dl><dt><b>Path</b></dt>'))
267             self.write('<dd>%s</dd>'%(', '.join(map(repr, self.split_path))))
268             keys = self.form.keys()
269             keys.sort()
270             if keys:
271                 self.write(_('<dt><b>Form entries</b></dt>'))
272                 for k in self.form.keys():
273                     v = self.form.getvalue(k, "<empty>")
274                     if type(v) is type([]):
275                         # Multiple username fields specified
276                         v = "|".join(v)
277                     self.write('<dd><em>%s</em>=%s</dd>'%(k, cgi.escape(v)))
278             keys = self.headers_sent.keys()
279             keys.sort()
280             self.write(_('<dt><b>Sent these HTTP headers</b></dt>'))
281             for k in keys:
282                 v = self.headers_sent[k]
283                 self.write('<dd><em>%s</em>=%s</dd>'%(k, cgi.escape(v)))
284             keys = self.env.keys()
285             keys.sort()
286             self.write(_('<dt><b>CGI environment</b></dt>'))
287             for k in keys:
288                 v = self.env[k]
289                 self.write('<dd><em>%s</em>=%s</dd>'%(k, cgi.escape(v)))
290             self.write('</dl></small>')
291         self.write('</body></html>')
293     def write(self, content):
294         if not self.headers_done:
295             self.header()
296         self.request.wfile.write(content)
298     def index_arg(self, arg):
299         ''' handle the args to index - they might be a list from the form
300             (ie. submitted from a form) or they might be a command-separated
301             single string (ie. manually constructed GET args)
302         '''
303         if self.form.has_key(arg):
304             arg =  self.form[arg]
305             if type(arg) == type([]):
306                 return [arg.value for arg in arg]
307             return arg.value.split(',')
308         return []
310     def index_sort(self):
311         # first try query string
312         x = self.index_arg(':sort')
313         if x:
314             return x
315         # nope - get the specs out of the form
316         specs = []
317         for colnm in self.db.getclass(self.classname).getprops().keys():
318             desc = ''
319             try:
320                 spec = self.form[':%s_ss' % colnm]
321             except KeyError:
322                 continue
323             spec = spec.value
324             if spec:
325                 if spec[-1] == '-':
326                     desc='-'
327                     spec = spec[0]
328                 specs.append((int(spec), colnm, desc))
329         specs.sort()
330         x = []
331         for _, colnm, desc in specs:
332             x.append('%s%s' % (desc, colnm))
333         return x
334     
335     def index_filterspec(self, filter):
336         ''' pull the index filter spec from the form
338         Links and multilinks want to be lists - the rest are straight
339         strings.
340         '''
341         filterspec = {}
342         props = self.db.classes[self.classname].getprops()
343         for colnm in filter:
344             widget = ':%s_fs' % colnm
345             try:
346                 val = self.form[widget]
347             except KeyError:
348                 try:
349                     val = self.form[colnm]
350                 except KeyError:
351                     # they checked the filter box but didn't enter a value
352                     continue
353             propdescr = props.get(colnm, None)
354             if propdescr is None:
355                 print "huh? %r is in filter & form, but not in Class!" % colnm
356                 raise "butthead programmer"
357             if (isinstance(propdescr, hyperdb.Link) or
358                 isinstance(propdescr, hyperdb.Multilink)):
359                 if type(val) == type([]):
360                     val = [arg.value for arg in val]
361                 else:
362                     val = val.value.split(',')
363                 l = filterspec.get(colnm, [])
364                 l = l + val
365                 filterspec[colnm] = l
366             else:
367                 filterspec[colnm] = val.value
368             
369         return filterspec
370     
371     def customization_widget(self):
372         ''' The customization widget is visible by default. The widget
373             visibility is remembered by show_customization.  Visibility
374             is not toggled if the action value is "Redisplay"
375         '''
376         if not self.form.has_key('show_customization'):
377             visible = 1
378         else:
379             visible = int(self.form['show_customization'].value)
380             if self.form.has_key('action'):
381                 if self.form['action'].value != 'Redisplay':
382                     visible = self.form['action'].value == '+'
383             
384         return visible
386     # TODO: make this go away some day...
387     default_index_sort = ['-activity']
388     default_index_group = ['priority']
389     default_index_filter = ['status']
390     default_index_columns = ['id','activity','title','status','assignedto']
391     default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
392     default_pagesize = '50'
394     def _get_customisation_info(self):
395         # see if the web has supplied us with any customisation info
396         defaults = 1
397         for key in ':sort', ':group', ':filter', ':columns', ':pagesize':
398             if self.form.has_key(key):
399                 defaults = 0
400                 break
401         if defaults:
402             # try the instance config first
403             if hasattr(self.instance, 'DEFAULT_INDEX'):
404                 d = self.instance.DEFAULT_INDEX
405                 self.classname = d['CLASS']
406                 sort = d['SORT']
407                 group = d['GROUP']
408                 filter = d['FILTER']
409                 columns = d['COLUMNS']
410                 filterspec = d['FILTERSPEC']
411                 pagesize = d.get('PAGESIZE', '50')
413             else:
414                 # nope - fall back on the old way of doing it
415                 self.classname = 'issue'
416                 sort = self.default_index_sort
417                 group = self.default_index_group
418                 filter = self.default_index_filter
419                 columns = self.default_index_columns
420                 filterspec = self.default_index_filterspec
421                 pagesize = self.default_pagesize
422         else:
423             # make list() extract the info from the CGI environ
424             self.classname = 'issue'
425             sort = group = filter = columns = filterspec = pagesize = None
426         return columns, filter, group, sort, filterspec, pagesize
428     def index(self):
429         ''' put up an index - no class specified
430         '''
431         columns, filter, group, sort, filterspec, pagesize = \
432             self._get_customisation_info()
433         return self.list(columns=columns, filter=filter, group=group,
434             sort=sort, filterspec=filterspec, pagesize=pagesize)
436     def searchnode(self):
437         columns, filter, group, sort, filterspec, pagesize = \
438             self._get_customisation_info()
439 ##        show_nodes = 1
440 ##        if len(self.form.keys()) == 0:
441 ##            # get the default search filters from instance_config
442 ##            if hasattr(self.instance, 'SEARCH_FILTERS'):
443 ##                for f in self.instance.SEARCH_FILTERS:
444 ##                    spec = getattr(self.instance, f)
445 ##                    if spec['CLASS'] == self.classname:
446 ##                        filter = spec['FILTER']
447 ##                
448 ##            show_nodes = 0
449 ##            show_customization = 1
450 ##        return self.list(columns=columns, filter=filter, group=group,
451 ##            sort=sort, filterspec=filterspec,
452 ##            show_customization=show_customization, show_nodes=show_nodes,
453 ##            pagesize=pagesize)
454         cn = self.classname
455         self.pagehead(_('%(instancename)s: Index of %(classname)s')%{
456             'classname': cn, 'instancename': self.instance.INSTANCE_NAME})
457         index = htmltemplate.IndexTemplate(self, self.instance.TEMPLATES, cn)
458         self.write('<form onSubmit="return submit_once()" action="%s">\n'%self.classname)
459         all_columns = self.db.getclass(cn).getprops().keys()
460         all_columns.sort()
461         index.filter_section('', filter, columns, group, all_columns, sort,
462                              filterspec, pagesize, 0)
463         self.pagefoot()
464         index.db = index.cl = index.properties = None
465         index.clear()
467     # XXX deviates from spec - loses the '+' (that's a reserved character
468     # in URLS
469     def list(self, sort=None, group=None, filter=None, columns=None,
470             filterspec=None, show_customization=None, show_nodes=1, pagesize=None):
471         ''' call the template index with the args
473             :sort    - sort by prop name, optionally preceeded with '-'
474                      to give descending or nothing for ascending sorting.
475             :group   - group by prop name, optionally preceeded with '-' or
476                      to sort in descending or nothing for ascending order.
477             :filter  - selects which props should be displayed in the filter
478                      section. Default is all.
479             :columns - selects the columns that should be displayed.
480                      Default is all.
482         '''
483         cn = self.classname
484         cl = self.db.classes[cn]
485         self.pagehead(_('%(instancename)s: Index of %(classname)s')%{
486             'classname': cn, 'instancename': self.instance.INSTANCE_NAME})
487         if sort is None: sort = self.index_sort()
488         if group is None: group = self.index_arg(':group')
489         if filter is None: filter = self.index_arg(':filter')
490         if columns is None: columns = self.index_arg(':columns')
491         if filterspec is None: filterspec = self.index_filterspec(filter)
492         if show_customization is None:
493             show_customization = self.customization_widget()
494         if self.form.has_key('search_text'):
495             search_text = self.form['search_text'].value
496         else:
497             search_text = ''
498         if pagesize is None:
499             if self.form.has_key(':pagesize'):
500                 pagesize = self.form[':pagesize'].value
501             else:
502                 pagesize = '50'
503         pagesize = int(pagesize)
504         if self.form.has_key(':startwith'):
505             startwith = int(self.form[':startwith'].value)
506         else:
507             startwith = 0
509         index = htmltemplate.IndexTemplate(self, self.instance.TEMPLATES, cn)
510         try:
511             index.render(filterspec, search_text, filter, columns, sort, 
512                 group, show_customization=show_customization, 
513                 show_nodes=show_nodes, pagesize=pagesize, startwith=startwith)
514         except htmltemplate.MissingTemplateError:
515             self.basicClassEditPage()
516         self.pagefoot()
518     def basicClassEditPage(self):
519         '''Display a basic edit page that allows simple editing of the
520            nodes of the current class
521         '''
522         if self.user != 'admin':
523             raise Unauthorised
524         w = self.write
525         cn = self.classname
526         cl = self.db.classes[cn]
527         idlessprops = cl.getprops(protected=0).keys()
528         props = ['id'] + idlessprops
531         # get the CSV module
532         try:
533             import csv
534         except ImportError:
535             w(_('Sorry, you need the csv module to use this function.<br>\n'
536                 'Get it from: <a href="http://www.object-craft.com.au/projects/csv/">http://www.object-craft.com.au/projects/csv/'))
537             return
539         # do the edit
540         if self.form.has_key('rows'):
541             rows = self.form['rows'].value.splitlines()
542             p = csv.parser()
543             found = {}
544             line = 0
545             for row in rows:
546                 line += 1
547                 values = p.parse(row)
548                 # not a complete row, keep going
549                 if not values: continue
551                 # extract the nodeid
552                 nodeid, values = values[0], values[1:]
553                 found[nodeid] = 1
555                 # confirm correct weight
556                 if len(idlessprops) != len(values):
557                     w(_('Not enough values on line %(line)s'%{'line':line}))
558                     return
560                 # extract the new values
561                 d = {}
562                 for name, value in zip(idlessprops, values):
563                     d[name] = value.strip()
565                 # perform the edit
566                 if cl.hasnode(nodeid):
567                     # edit existing
568                     cl.set(nodeid, **d)
569                 else:
570                     # new node
571                     found[cl.create(**d)] = 1
573             # retire the removed entries
574             for nodeid in cl.list():
575                 if not found.has_key(nodeid):
576                     cl.retire(nodeid)
578         w(_('''<p class="form-help">You may edit the contents of the
579         "%(classname)s" class using this form. The lines are full-featured
580         Comma-Separated-Value lines, so you may include commas and even
581         newlines by enclosing the values in double-quotes ("). Double
582         quotes themselves must be quoted by doubling ("").</p>
583         <p class="form-help">Remove entries by deleting their line. Add
584         new entries by appending
585         them to the table - put an X in the id column.</p>''')%{'classname':cn})
587         l = []
588         for name in props:
589             l.append(name)
590         w('<tt>')
591         w(', '.join(l) + '\n')
592         w('</tt>')
594         w('<form onSubmit="return submit_once()" method="POST">')
595         w('<textarea name="rows" cols=80 rows=15>')
596         p = csv.parser()
597         for nodeid in cl.list():
598             l = []
599             for name in props:
600                 l.append(cgi.escape(str(cl.get(nodeid, name))))
601             w(p.join(l) + '\n')
603         w(_('</textarea><br><input type="submit" value="Save Changes"></form>'))
605     def classhelp(self):
606         '''Display a table of class info
607         '''
608         w = self.write
609         cn = self.form['classname'].value
610         cl = self.db.classes[cn]
611         props = self.form['properties'].value.split(',')
612         if cl.labelprop(1) in props:
613             sort = [cl.labelprop(1)]
614         else:
615             sort = props[0]
617         w('<table border=1 cellspacing=0 cellpaddin=2>')
618         w('<tr>')
619         for name in props:
620             w('<th align=left>%s</th>'%name)
621         w('</tr>')
622         for nodeid in cl.filter(None, {}, sort, []): #cl.list():
623             w('<tr>')
624             for name in props:
625                 value = cgi.escape(str(cl.get(nodeid, name)))
626                 w('<td align="left" valign="top">%s</td>'%value)
627             w('</tr>')
628         w('</table>')
630     def shownode(self, message=None, num_re=re.compile('^\d+$')):
631         ''' display an item
632         '''
633         cn = self.classname
634         cl = self.db.classes[cn]
635         if self.form.has_key(':multilink'):
636             link = self.form[':multilink'].value
637             designator, linkprop = link.split(':')
638             xtra = ' for <a href="%s">%s</a>' % (designator, designator)
639         else:
640             xtra = ''
642         # possibly perform an edit
643         keys = self.form.keys()
644         # don't try to set properties if the user has just logged in
645         if keys and not self.form.has_key('__login_name'):
646             try:
647                 props = parsePropsFromForm(self.db, cl, self.form, self.nodeid)
648                 # make changes to the node
649                 self._changenode(props)
650                 # handle linked nodes 
651                 self._post_editnode(self.nodeid)
652                 # and some nice feedback for the user
653                 if props:
654                     message = _('%(changes)s edited ok')%{'changes':
655                         ', '.join(props.keys())}
656                 elif self.form.has_key('__note') and self.form['__note'].value:
657                     message = _('note added')
658                 elif (self.form.has_key('__file') and
659                         self.form['__file'].filename):
660                     message = _('file added')
661                 else:
662                     message = _('nothing changed')
663             except:
664                 self.db.rollback()
665                 s = StringIO.StringIO()
666                 traceback.print_exc(None, s)
667                 message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
669         # now the display
670         id = self.nodeid
671         if cl.getkey():
672             id = cl.get(id, cl.getkey())
673         self.pagehead('%s: %s %s'%(self.classname.capitalize(), id, xtra), message)
675         nodeid = self.nodeid
677         # use the template to display the item
678         item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES,
679             self.classname)
680         item.render(nodeid)
682         self.pagefoot()
683     showissue = shownode
684     showmsg = shownode
685     searchissue = searchnode
687     def _changenode(self, props):
688         ''' change the node based on the contents of the form
689         '''
690         cl = self.db.classes[self.classname]
692         # create the message
693         message, files = self._handle_message()
694         if message:
695             props['messages'] = cl.get(self.nodeid, 'messages') + [message]
696         if files:
697             props['files'] = cl.get(self.nodeid, 'files') + files
699         # make the changes
700         cl.set(self.nodeid, **props)
702     def _createnode(self):
703         ''' create a node based on the contents of the form
704         '''
705         cl = self.db.classes[self.classname]
706         props = parsePropsFromForm(self.db, cl, self.form)
708         # check for messages and files
709         message, files = self._handle_message()
710         if message:
711             props['messages'] = [message]
712         if files:
713             props['files'] = files
714         # create the node and return it's id
715         return cl.create(**props)
717     def _handle_message(self):
718         ''' generate an edit message
719         '''
720         # handle file attachments 
721         files = []
722         if self.form.has_key('__file'):
723             file = self.form['__file']
724             if file.filename:
725                 filename = file.filename.split('\\')[-1]
726                 mime_type = mimetypes.guess_type(filename)[0]
727                 if not mime_type:
728                     mime_type = "application/octet-stream"
729                 # create the new file entry
730                 files.append(self.db.file.create(type=mime_type,
731                     name=filename, content=file.file.read()))
733         # we don't want to do a message if none of the following is true...
734         cn = self.classname
735         cl = self.db.classes[self.classname]
736         props = cl.getprops()
737         note = None
738         # in a nutshell, don't do anything if there's no note or there's no
739         # NOSY
740         if self.form.has_key('__note'):
741             note = self.form['__note'].value.strip()
742         if not note:
743             return None, files
744         if not props.has_key('messages'):
745             return None, files
746         if not isinstance(props['messages'], hyperdb.Multilink):
747             return None, files
748         if not props['messages'].classname == 'msg':
749             return None, files
750         if not (self.form.has_key('nosy') or note):
751             return None, files
753         # handle the note
754         if '\n' in note:
755             summary = re.split(r'\n\r?', note)[0]
756         else:
757             summary = note
758         m = ['%s\n'%note]
760         # handle the messageid
761         # TODO: handle inreplyto
762         messageid = "<%s.%s.%s@%s>"%(time.time(), random.random(),
763             self.classname, self.instance.MAIL_DOMAIN)
765         # now create the message, attaching the files
766         content = '\n'.join(m)
767         message_id = self.db.msg.create(author=self.getuid(),
768             recipients=[], date=date.Date('.'), summary=summary,
769             content=content, files=files, messageid=messageid)
771         # update the messages property
772         return message_id, files
774     def _post_editnode(self, nid):
775         '''Do the linking part of the node creation.
777            If a form element has :link or :multilink appended to it, its
778            value specifies a node designator and the property on that node
779            to add _this_ node to as a link or multilink.
781            This is typically used on, eg. the file upload page to indicated
782            which issue to link the file to.
784            TODO: I suspect that this and newfile will go away now that
785            there's the ability to upload a file using the issue __file form
786            element!
787         '''
788         cn = self.classname
789         cl = self.db.classes[cn]
790         # link if necessary
791         keys = self.form.keys()
792         for key in keys:
793             if key == ':multilink':
794                 value = self.form[key].value
795                 if type(value) != type([]): value = [value]
796                 for value in value:
797                     designator, property = value.split(':')
798                     link, nodeid = roundupdb.splitDesignator(designator)
799                     link = self.db.classes[link]
800                     # take a dupe of the list so we're not changing the cache
801                     value = link.get(nodeid, property)[:]
802                     value.append(nid)
803                     link.set(nodeid, **{property: value})
804             elif key == ':link':
805                 value = self.form[key].value
806                 if type(value) != type([]): value = [value]
807                 for value in value:
808                     designator, property = value.split(':')
809                     link, nodeid = roundupdb.splitDesignator(designator)
810                     link = self.db.classes[link]
811                     link.set(nodeid, **{property: nid})
813     def newnode(self, message=None):
814         ''' Add a new node to the database.
815         
816         The form works in two modes: blank form and submission (that is,
817         the submission goes to the same URL). **Eventually this means that
818         the form will have previously entered information in it if
819         submission fails.
821         The new node will be created with the properties specified in the
822         form submission. For multilinks, multiple form entries are handled,
823         as are prop=value,value,value. You can't mix them though.
825         If the new node is to be referenced from somewhere else immediately
826         (ie. the new node is a file that is to be attached to a support
827         issue) then supply one of these arguments in addition to the usual
828         form entries:
829             :link=designator:property
830             :multilink=designator:property
831         ... which means that once the new node is created, the "property"
832         on the node given by "designator" should now reference the new
833         node's id. The node id will be appended to the multilink.
834         '''
835         cn = self.classname
836         cl = self.db.classes[cn]
837         if self.form.has_key(':multilink'):
838             link = self.form[':multilink'].value
839             designator, linkprop = link.split(':')
840             xtra = ' for <a href="%s">%s</a>' % (designator, designator)
841         else:
842             xtra = ''
844         # possibly perform a create
845         keys = self.form.keys()
846         if [i for i in keys if i[0] != ':']:
847             props = {}
848             try:
849                 nid = self._createnode()
850                 # handle linked nodes 
851                 self._post_editnode(nid)
852                 # and some nice feedback for the user
853                 message = _('%(classname)s created ok')%{'classname': cn}
855                 # render the newly created issue
856                 self.db.commit()
857                 self.nodeid = nid
858                 self.pagehead('%s: %s'%(self.classname.capitalize(), nid),
859                     message)
860                 item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES, 
861                     self.classname)
862                 item.render(nid)
863                 self.pagefoot()
864                 return
865             except:
866                 self.db.rollback()
867                 s = StringIO.StringIO()
868                 traceback.print_exc(None, s)
869                 message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
870         self.pagehead(_('New %(classname)s %(xtra)s')%{
871                 'classname': self.classname.capitalize(),
872                 'xtra': xtra }, message)
874         # call the template
875         newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
876             self.classname)
877         newitem.render(self.form)
879         self.pagefoot()
880     newissue = newnode
882     def newuser(self, message=None):
883         ''' Add a new user to the database.
885             Don't do any of the message or file handling, just create the node.
886         '''
887         cn = self.classname
888         cl = self.db.classes[cn]
890         # possibly perform a create
891         keys = self.form.keys()
892         if [i for i in keys if i[0] != ':']:
893             try:
894                 props = parsePropsFromForm(self.db, cl, self.form)
895                 nid = cl.create(**props)
896                 # handle linked nodes 
897                 self._post_editnode(nid)
898                 # and some nice feedback for the user
899                 message = _('%(classname)s created ok')%{'classname': cn}
900             except:
901                 self.db.rollback()
902                 s = StringIO.StringIO()
903                 traceback.print_exc(None, s)
904                 message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
905         self.pagehead(_('New %(classname)s')%{'classname':
906              self.classname.capitalize()}, message)
908         # call the template
909         newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
910             self.classname)
911         newitem.render(self.form)
913         self.pagefoot()
915     def newfile(self, message=None):
916         ''' Add a new file to the database.
917         
918         This form works very much the same way as newnode - it just has a
919         file upload.
920         '''
921         cn = self.classname
922         cl = self.db.classes[cn]
923         props = parsePropsFromForm(self.db, cl, self.form)
924         if self.form.has_key(':multilink'):
925             link = self.form[':multilink'].value
926             designator, linkprop = link.split(':')
927             xtra = ' for <a href="%s">%s</a>' % (designator, designator)
928         else:
929             xtra = ''
931         # possibly perform a create
932         keys = self.form.keys()
933         if [i for i in keys if i[0] != ':']:
934             try:
935                 file = self.form['content']
936                 mime_type = mimetypes.guess_type(file.filename)[0]
937                 if not mime_type:
938                     mime_type = "application/octet-stream"
939                 # save the file
940                 props['type'] = mime_type
941                 props['name'] = file.filename
942                 props['content'] = file.file.read()
943                 nid = cl.create(**props)
944                 # handle linked nodes
945                 self._post_editnode(nid)
946                 # and some nice feedback for the user
947                 message = _('%(classname)s created ok')%{'classname': cn}
948             except:
949                 self.db.rollback()
950                 s = StringIO.StringIO()
951                 traceback.print_exc(None, s)
952                 message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
954         self.pagehead(_('New %(classname)s %(xtra)s')%{
955                 'classname': self.classname.capitalize(),
956                 'xtra': xtra }, message)
957         newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
958             self.classname)
959         newitem.render(self.form)
960         self.pagefoot()
962     def showuser(self, message=None, num_re=re.compile('^\d+$')):
963         '''Display a user page for editing. Make sure the user is allowed
964             to edit this node, and also check for password changes.
965         '''
966         if self.user == 'anonymous':
967             raise Unauthorised
969         user = self.db.user
971         # get the username of the node being edited
972         node_user = user.get(self.nodeid, 'username')
974         if self.user not in ('admin', node_user):
975             raise Unauthorised
977         #
978         # perform any editing
979         #
980         keys = self.form.keys()
981         if keys:
982             try:
983                 props = parsePropsFromForm(self.db, user, self.form,
984                     self.nodeid)
985                 set_cookie = 0
986                 if props.has_key('password'):
987                     password = self.form['password'].value.strip()
988                     if not password:
989                         # no password was supplied - don't change it
990                         del props['password']
991                     elif self.nodeid == self.getuid():
992                         # this is the logged-in user's password
993                         set_cookie = password
994                 user.set(self.nodeid, **props)
995                 # and some feedback for the user
996                 message = _('%(changes)s edited ok')%{'changes':
997                     ', '.join(props.keys())}
998             except:
999                 self.db.rollback()
1000                 s = StringIO.StringIO()
1001                 traceback.print_exc(None, s)
1002                 message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
1003         else:
1004             set_cookie = 0
1006         # fix the cookie if the password has changed
1007         if set_cookie:
1008             self.set_cookie(self.user, set_cookie)
1010         #
1011         # now the display
1012         #
1013         self.pagehead(_('User: %(user)s')%{'user': node_user}, message)
1015         # use the template to display the item
1016         item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES, 'user')
1017         item.render(self.nodeid)
1018         self.pagefoot()
1020     def showfile(self):
1021         ''' display a file
1022         '''
1023         nodeid = self.nodeid
1024         cl = self.db.classes[self.classname]
1025         mime_type = cl.get(nodeid, 'type')
1026         if mime_type == 'message/rfc822':
1027             mime_type = 'text/plain'
1028         self.header(headers={'Content-Type': mime_type})
1029         self.write(cl.get(nodeid, 'content'))
1031     def classes(self, message=None):
1032         ''' display a list of all the classes in the database
1033         '''
1034         if self.user == 'admin':
1035             self.pagehead(_('Table of classes'), message)
1036             classnames = self.db.classes.keys()
1037             classnames.sort()
1038             self.write('<table border=0 cellspacing=0 cellpadding=2>\n')
1039             for cn in classnames:
1040                 cl = self.db.getclass(cn)
1041                 self.write('<tr class="list-header"><th colspan=2 align=left>'
1042                     '<a href="%s">%s</a></th></tr>'%(cn, cn.capitalize()))
1043                 for key, value in cl.properties.items():
1044                     if value is None: value = ''
1045                     else: value = str(value)
1046                     self.write('<tr><th align=left>%s</th><td>%s</td></tr>'%(
1047                         key, cgi.escape(value)))
1048             self.write('</table>')
1049             self.pagefoot()
1050         else:
1051             raise Unauthorised
1053     def login(self, message=None, newuser_form=None, action='index'):
1054         '''Display a login page.
1055         '''
1056         self.pagehead(_('Login to roundup'), message)
1057         self.write(_('''
1058 <table>
1059 <tr><td colspan=2 class="strong-header">Existing User Login</td></tr>
1060 <form onSubmit="return submit_once()" action="login_action" method=POST>
1061 <input type="hidden" name="__destination_url" value="%(action)s">
1062 <tr><td align=right>Login name: </td>
1063     <td><input name="__login_name"></td></tr>
1064 <tr><td align=right>Password: </td>
1065     <td><input type="password" name="__login_password"></td></tr>
1066 <tr><td></td>
1067     <td><input type="submit" value="Log In"></td></tr>
1068 </form>
1069 ''')%locals())
1070         if self.user is None and self.instance.ANONYMOUS_REGISTER == 'deny':
1071             self.write('</table>')
1072             self.pagefoot()
1073             return
1074         values = {'realname': '', 'organisation': '', 'address': '',
1075             'phone': '', 'username': '', 'password': '', 'confirm': '',
1076             'action': action, 'alternate_addresses': ''}
1077         if newuser_form is not None:
1078             for key in newuser_form.keys():
1079                 values[key] = newuser_form[key].value
1080         self.write(_('''
1081 <p>
1082 <tr><td colspan=2 class="strong-header">New User Registration</td></tr>
1083 <tr><td colspan=2><em>marked items</em> are optional...</td></tr>
1084 <form onSubmit="return submit_once()" action="newuser_action" method=POST>
1085 <input type="hidden" name="__destination_url" value="%(action)s">
1086 <tr><td align=right><em>Name: </em></td>
1087     <td><input name="realname" value="%(realname)s" size=40></td></tr>
1088 <tr><td align=right><em>Organisation: </em></td>
1089     <td><input name="organisation" value="%(organisation)s" size=40></td></tr>
1090 <tr><td align=right>E-Mail Address: </td>
1091     <td><input name="address" value="%(address)s" size=40></td></tr>
1092 <tr><td align=right><em>Alternate E-mail Addresses: </em></td>
1093     <td><textarea name="alternate_addresses" rows=5 cols=40>%(alternate_addresses)s</textarea></td></tr>
1094 <tr><td align=right><em>Phone: </em></td>
1095     <td><input name="phone" value="%(phone)s"></td></tr>
1096 <tr><td align=right>Preferred Login name: </td>
1097     <td><input name="username" value="%(username)s"></td></tr>
1098 <tr><td align=right>Password: </td>
1099     <td><input type="password" name="password" value="%(password)s"></td></tr>
1100 <tr><td align=right>Password Again: </td>
1101     <td><input type="password" name="confirm" value="%(confirm)s"></td></tr>
1102 <tr><td></td>
1103     <td><input type="submit" value="Register"></td></tr>
1104 </form>
1105 </table>
1106 ''')%values)
1107         self.pagefoot()
1109     def login_action(self, message=None):
1110         '''Attempt to log a user in and set the cookie
1112         returns 0 if a page is generated as a result of this call, and
1113         1 if not (ie. the login is successful
1114         '''
1115         if not self.form.has_key('__login_name'):
1116             self.login(message=_('Username required'))
1117             return 0
1118         self.user = self.form['__login_name'].value
1119         if self.form.has_key('__login_password'):
1120             password = self.form['__login_password'].value
1121         else:
1122             password = ''
1123         # make sure the user exists
1124         try:
1125             uid = self.db.user.lookup(self.user)
1126         except KeyError:
1127             name = self.user
1128             self.make_user_anonymous()
1129             action = self.form['__destination_url'].value
1130             self.login(message=_('No such user "%(name)s"')%locals(),
1131                 action=action)
1132             return 0
1134         # and that the password is correct
1135         pw = self.db.user.get(uid, 'password')
1136         if password != pw:
1137             self.make_user_anonymous()
1138             action = self.form['__destination_url'].value
1139             self.login(message=_('Incorrect password'), action=action)
1140             return 0
1142         self.set_cookie(self.user, password)
1143         return 1
1145     def newuser_action(self, message=None):
1146         '''Attempt to create a new user based on the contents of the form
1147         and then set the cookie.
1149         return 1 on successful login
1150         '''
1151         # re-open the database as "admin"
1152         self.db = self.instance.open('admin')
1154         # TODO: pre-check the required fields and username key property
1155         cl = self.db.user
1156         try:
1157             props = parsePropsFromForm(self.db, cl, self.form)
1158             uid = cl.create(**props)
1159         except ValueError, message:
1160             action = self.form['__destination_url'].value
1161             self.login(message, action=action)
1162             return 0
1163         self.user = cl.get(uid, 'username')
1164         password = cl.get(uid, 'password')
1165         self.set_cookie(self.user, self.form['password'].value)
1166         return 1
1168     def set_cookie(self, user, password):
1169         # construct the cookie
1170         user = binascii.b2a_base64('%s:%s'%(user, password)).strip()
1171         if user[-1] == '=':
1172           if user[-2] == '=':
1173             user = user[:-2]
1174           else:
1175             user = user[:-1]
1176         expire = Cookie._getdate(86400*365)
1177         path = '/'.join((self.env['SCRIPT_NAME'], self.env['INSTANCE_NAME']))
1178         self.header({'Set-Cookie': 'roundup_user=%s; expires=%s; Path=%s;' % (
1179             user, expire, path)})
1181     def make_user_anonymous(self):
1182         # make us anonymous if we can
1183         try:
1184             self.db.user.lookup('anonymous')
1185             self.user = 'anonymous'
1186         except KeyError:
1187             self.user = None
1189     def logout(self, message=None):
1190         self.make_user_anonymous()
1191         # construct the logout cookie
1192         now = Cookie._getdate()
1193         path = '/'.join((self.env['SCRIPT_NAME'], self.env['INSTANCE_NAME']))
1194         self.header({'Set-Cookie':
1195             'roundup_user=deleted; Max-Age=0; expires=%s; Path=%s;'%(now,
1196             path)})
1197         self.login()
1199     def main(self):
1200         '''Wrap the database accesses so we can close the database cleanly
1201         '''
1202         # determine the uid to use
1203         self.db = self.instance.open('admin')
1204         cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', ''))
1205         user = 'anonymous'
1206         if (cookie.has_key('roundup_user') and
1207                 cookie['roundup_user'].value != 'deleted'):
1208             cookie = cookie['roundup_user'].value
1209             if len(cookie)%4:
1210               cookie = cookie + '='*(4-len(cookie)%4)
1211             try:
1212                 user, password = binascii.a2b_base64(cookie).split(':')
1213             except (TypeError, binascii.Error, binascii.Incomplete):
1214                 # damaged cookie!
1215                 user, password = 'anonymous', ''
1217             # make sure the user exists
1218             try:
1219                 uid = self.db.user.lookup(user)
1220                 # now validate the password
1221                 if password != self.db.user.get(uid, 'password'):
1222                     user = 'anonymous'
1223             except KeyError:
1224                 user = 'anonymous'
1226         # make sure the anonymous user is valid if we're using it
1227         if user == 'anonymous':
1228             self.make_user_anonymous()
1229         else:
1230             self.user = user
1232         # re-open the database for real, using the user
1233         self.db = self.instance.open(self.user)
1235         # now figure which function to call
1236         path = self.split_path
1238         # default action to index if the path has no information in it
1239         if not path or path[0] in ('', 'index'):
1240             action = 'index'
1241         else:
1242             action = path[0]
1244         # Everthing ignores path[1:]
1245         #  - The file download link generator actually relies on this - it
1246         #    appends the name of the file to the URL so the download file name
1247         #    is correct, but doesn't actually use it.
1249         # everyone is allowed to try to log in
1250         if action == 'login_action':
1251             # try to login
1252             if not self.login_action():
1253                 return
1254             # figure the resulting page
1255             action = self.form['__destination_url'].value
1256             if not action:
1257                 action = 'index'
1258             self.do_action(action)
1259             return
1261         # allow anonymous people to register
1262         if action == 'newuser_action':
1263             # if we don't have a login and anonymous people aren't allowed to
1264             # register, then spit up the login form
1265             if self.instance.ANONYMOUS_REGISTER == 'deny' and self.user is None:
1266                 if action == 'login':
1267                     self.login()         # go to the index after login
1268                 else:
1269                     self.login(action=action)
1270                 return
1271             # try to add the user
1272             if not self.newuser_action():
1273                 return
1274             # figure the resulting page
1275             action = self.form['__destination_url'].value
1276             if not action:
1277                 action = 'index'
1279         # no login or registration, make sure totally anonymous access is OK
1280         elif self.instance.ANONYMOUS_ACCESS == 'deny' and self.user is None:
1281             if action == 'login':
1282                 self.login()             # go to the index after login
1283             else:
1284                 self.login(action=action)
1285             return
1287         # just a regular action
1288         self.do_action(action)
1290         # commit all changes to the database
1291         self.db.commit()
1293     def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
1294             nre=re.compile(r'new(\w+)'), sre=re.compile(r'search(\w+)')):
1295         '''Figure the user's action and do it.
1296         '''
1297         # here be the "normal" functionality
1298         if action == 'index':
1299             self.index()
1300             return
1301         if action == 'list_classes':
1302             self.classes()
1303             return
1304         if action == 'classhelp':
1305             self.classhelp()
1306             return
1307         if action == 'login':
1308             self.login()
1309             return
1310         if action == 'logout':
1311             self.logout()
1312             return
1314         # see if we're to display an existing node
1315         m = dre.match(action)
1316         if m:
1317             self.classname = m.group(1)
1318             self.nodeid = m.group(2)
1319             try:
1320                 cl = self.db.classes[self.classname]
1321             except KeyError:
1322                 raise NotFound, self.classname
1323             try:
1324                 cl.get(self.nodeid, 'id')
1325             except IndexError:
1326                 raise NotFound, self.nodeid
1327             try:
1328                 func = getattr(self, 'show%s'%self.classname)
1329             except AttributeError:
1330                 raise NotFound, 'show%s'%self.classname
1331             func()
1332             return
1334         # see if we're to put up the new node page
1335         m = nre.match(action)
1336         if m:
1337             self.classname = m.group(1)
1338             try:
1339                 func = getattr(self, 'new%s'%self.classname)
1340             except AttributeError:
1341                 raise NotFound, 'new%s'%self.classname
1342             func()
1343             return
1345         # see if we're to put up the new node page
1346         m = sre.match(action)
1347         if m:
1348             self.classname = m.group(1)
1349             try:
1350                 func = getattr(self, 'search%s'%self.classname)
1351             except AttributeError:
1352                 raise NotFound
1353             func()
1354             return
1356         # otherwise, display the named class
1357         self.classname = action
1358         try:
1359             self.db.getclass(self.classname)
1360         except KeyError:
1361             raise NotFound, self.classname
1362         self.list()
1365 class ExtendedClient(Client): 
1366     '''Includes pages and page heading information that relate to the
1367        extended schema.
1368     ''' 
1369     showsupport = Client.shownode
1370     showtimelog = Client.shownode
1371     newsupport = Client.newnode
1372     newtimelog = Client.newnode
1373     searchsupport = Client.searchnode
1375     default_index_sort = ['-activity']
1376     default_index_group = ['priority']
1377     default_index_filter = ['status']
1378     default_index_columns = ['activity','status','title','assignedto']
1379     default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
1380     default_pagesize = '50'
1382 def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
1383     '''Pull properties for the given class out of the form.
1384     '''
1385     props = {}
1386     keys = form.keys()
1387     for key in keys:
1388         if not cl.properties.has_key(key):
1389             continue
1390         proptype = cl.properties[key]
1391         if isinstance(proptype, hyperdb.String):
1392             value = form[key].value.strip()
1393         elif isinstance(proptype, hyperdb.Password):
1394             value = password.Password(form[key].value.strip())
1395         elif isinstance(proptype, hyperdb.Date):
1396             value = form[key].value.strip()
1397             if value:
1398                 value = date.Date(form[key].value.strip())
1399             else:
1400                 value = None
1401         elif isinstance(proptype, hyperdb.Interval):
1402             value = form[key].value.strip()
1403             if value:
1404                 value = date.Interval(form[key].value.strip())
1405             else:
1406                 value = None
1407         elif isinstance(proptype, hyperdb.Link):
1408             value = form[key].value.strip()
1409             # see if it's the "no selection" choice
1410             if value == '-1':
1411                 # don't set this property
1412                 continue
1413             else:
1414                 # handle key values
1415                 link = cl.properties[key].classname
1416                 if not num_re.match(value):
1417                     try:
1418                         value = db.classes[link].lookup(value)
1419                     except KeyError:
1420                         raise ValueError, _('property "%(propname)s": '
1421                             '%(value)s not a %(classname)s')%{'propname':key, 
1422                             'value': value, 'classname': link}
1423         elif isinstance(proptype, hyperdb.Multilink):
1424             value = form[key]
1425             if type(value) != type([]):
1426                 value = [i.strip() for i in value.value.split(',')]
1427             else:
1428                 value = [i.value.strip() for i in value]
1429             link = cl.properties[key].classname
1430             l = []
1431             for entry in map(str, value):
1432                 if entry == '': continue
1433                 if not num_re.match(entry):
1434                     try:
1435                         entry = db.classes[link].lookup(entry)
1436                     except KeyError:
1437                         raise ValueError, _('property "%(propname)s": '
1438                             '"%(value)s" not an entry of %(classname)s')%{
1439                             'propname':key, 'value': entry, 'classname': link}
1440                 l.append(entry)
1441             l.sort()
1442             value = l
1444         # get the old value
1445         if nodeid:
1446             try:
1447                 existing = cl.get(nodeid, key)
1448             except KeyError:
1449                 # this might be a new property for which there is no existing
1450                 # value
1451                 if not cl.properties.has_key(key): raise
1453             # if changed, set it
1454             if value != existing:
1455                 props[key] = value
1456         else:
1457             props[key] = value
1458     return props
1461 # $Log: not supported by cvs2svn $
1462 # Revision 1.132  2002/07/08 07:26:14  richard
1463 # ehem
1465 # Revision 1.131  2002/07/08 06:53:57  richard
1466 # Not sure why the cgi_client had an indexer argument.
1468 # Revision 1.130  2002/06/27 12:01:53  gmcm
1469 # If the form has a :multilink, put a back href in the pageheader (back to the linked-to node).
1470 # Some minor optimizations (only compile regexes once).
1472 # Revision 1.129  2002/06/20 23:52:11  richard
1473 # Better handling of unauth attempt to edit stuff
1475 # Revision 1.128  2002/06/12 21:28:25  gmcm
1476 # Allow form to set user-properties on a Fileclass.
1477 # Don't assume that a Fileclass is named "files".
1479 # Revision 1.127  2002/06/11 06:38:24  richard
1480 #  . #565996 ] The "Attach a File to this Issue" fails
1482 # Revision 1.126  2002/05/29 01:16:17  richard
1483 # Sorry about this huge checkin! It's fixing a lot of related stuff in one go
1484 # though.
1486 # . #541941 ] changing multilink properties by mail
1487 # . #526730 ] search for messages capability
1488 # . #505180 ] split MailGW.handle_Message
1489 #   - also changed cgi client since it was duplicating the functionality
1490 # . build htmlbase if tests are run using CVS checkout (removed note from
1491 #   installation.txt)
1492 # . don't create an empty message on email issue creation if the email is empty
1494 # Revision 1.125  2002/05/25 07:16:24  rochecompaan
1495 # Merged search_indexing-branch with HEAD
1497 # Revision 1.124  2002/05/24 02:09:24  richard
1498 # Nothing like a live demo to show up the bugs ;)
1500 # Revision 1.123  2002/05/22 05:04:13  richard
1501 # Oops
1503 # Revision 1.122  2002/05/22 04:12:05  richard
1504 #  . applied patch #558876 ] cgi client customization
1505 #    ... with significant additions and modifications ;)
1506 #    - extended handling of ML assignedto to all places it's handled
1507 #    - added more NotFound info
1509 # Revision 1.121  2002/05/21 06:08:10  richard
1510 # Handle migration
1512 # Revision 1.120  2002/05/21 06:05:53  richard
1513 #  . #551483 ] assignedto in Client.make_index_link
1515 # Revision 1.119  2002/05/15 06:21:21  richard
1516 #  . node caching now works, and gives a small boost in performance
1518 # As a part of this, I cleaned up the DEBUG output and implemented TRACE
1519 # output (HYPERDBTRACE='file to trace to') with checkpoints at the start of
1520 # CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff
1521 # (using if __debug__ which is compiled out with -O)
1523 # Revision 1.118  2002/05/12 23:46:33  richard
1524 # ehem, part 2
1526 # Revision 1.117  2002/05/12 23:42:29  richard
1527 # ehem
1529 # Revision 1.116  2002/05/02 08:07:49  richard
1530 # Added the ADD_AUTHOR_TO_NOSY handling to the CGI interface.
1532 # Revision 1.115  2002/04/02 01:56:10  richard
1533 #  . stop sending blank (whitespace-only) notes
1535 # Revision 1.114.2.4  2002/05/02 11:49:18  rochecompaan
1536 # Allow customization of the search filters that should be displayed
1537 # on the search page.
1539 # Revision 1.114.2.3  2002/04/20 13:23:31  rochecompaan
1540 # We now have a separate search page for nodes.  Search links for
1541 # different classes can be customized in instance_config similar to
1542 # index links.
1544 # Revision 1.114.2.2  2002/04/19 19:54:42  rochecompaan
1545 # cgi_client.py
1546 #     removed search link for the time being
1547 #     moved rendering of matches to htmltemplate
1548 # hyperdb.py
1549 #     filtering of nodes on full text search incorporated in filter method
1550 # roundupdb.py
1551 #     added paramater to call of filter method
1552 # roundup_indexer.py
1553 #     added search method to RoundupIndexer class
1555 # Revision 1.114.2.1  2002/04/03 11:55:57  rochecompaan
1556 #  . Added feature #526730 - search for messages capability
1558 # Revision 1.114  2002/03/17 23:06:05  richard
1559 # oops
1561 # Revision 1.113  2002/03/14 23:59:24  richard
1562 #  . #517734 ] web header customisation is obscure
1564 # Revision 1.112  2002/03/12 22:52:26  richard
1565 # more pychecker warnings removed
1567 # Revision 1.111  2002/02/25 04:32:21  richard
1568 # ahem
1570 # Revision 1.110  2002/02/21 07:19:08  richard
1571 # ... and label, width and height control for extra flavour!
1573 # Revision 1.109  2002/02/21 07:08:19  richard
1574 # oops
1576 # Revision 1.108  2002/02/21 07:02:54  richard
1577 # The correct var is "HTTP_HOST"
1579 # Revision 1.107  2002/02/21 06:57:38  richard
1580 #  . Added popup help for classes using the classhelp html template function.
1581 #    - add <display call="classhelp('priority', 'id,name,description')">
1582 #      to an item page, and it generates a link to a popup window which displays
1583 #      the id, name and description for the priority class. The description
1584 #      field won't exist in most installations, but it will be added to the
1585 #      default templates.
1587 # Revision 1.106  2002/02/21 06:23:00  richard
1588 # *** empty log message ***
1590 # Revision 1.105  2002/02/20 05:52:10  richard
1591 # better error handling
1593 # Revision 1.104  2002/02/20 05:45:17  richard
1594 # Use the csv module for generating the form entry so it's correct.
1595 # [also noted the sf.net feature request id in the change log]
1597 # Revision 1.103  2002/02/20 05:05:28  richard
1598 #  . Added simple editing for classes that don't define a templated interface.
1599 #    - access using the admin "class list" interface
1600 #    - limited to admin-only
1601 #    - requires the csv module from object-craft (url given if it's missing)
1603 # Revision 1.102  2002/02/15 07:08:44  richard
1604 #  . Alternate email addresses are now available for users. See the MIGRATION
1605 #    file for info on how to activate the feature.
1607 # Revision 1.101  2002/02/14 23:39:18  richard
1608 # . All forms now have "double-submit" protection when Javascript is enabled
1609 #   on the client-side.
1611 # Revision 1.100  2002/01/16 07:02:57  richard
1612 #  . lots of date/interval related changes:
1613 #    - more relaxed date format for input
1615 # Revision 1.99  2002/01/16 03:02:42  richard
1616 # #503793 ] changing assignedto resets nosy list
1618 # Revision 1.98  2002/01/14 02:20:14  richard
1619 #  . changed all config accesses so they access either the instance or the
1620 #    config attriubute on the db. This means that all config is obtained from
1621 #    instance_config instead of the mish-mash of classes. This will make
1622 #    switching to a ConfigParser setup easier too, I hope.
1624 # At a minimum, this makes migration a _little_ easier (a lot easier in the
1625 # 0.5.0 switch, I hope!)
1627 # Revision 1.97  2002/01/11 23:22:29  richard
1628 #  . #502437 ] rogue reactor and unittest
1629 #    in short, the nosy reactor was modifying the nosy list. That code had
1630 #    been there for a long time, and I suspsect it was there because we
1631 #    weren't generating the nosy list correctly in other places of the code.
1632 #    We're now doing that, so the nosy-modifying code can go away from the
1633 #    nosy reactor.
1635 # Revision 1.96  2002/01/10 05:26:10  richard
1636 # missed a parsePropsFromForm in last update
1638 # Revision 1.95  2002/01/10 03:39:45  richard
1639 #  . fixed some problems with web editing and change detection
1641 # Revision 1.94  2002/01/09 13:54:21  grubert
1642 # _add_assignedto_to_nosy did set nosy to assignedto only, no adding.
1644 # Revision 1.93  2002/01/08 11:57:12  richard
1645 # crying out for real configuration handling... :(
1647 # Revision 1.92  2002/01/08 04:12:05  richard
1648 # Changed message-id format to "<%s.%s.%s%s@%s>" so it complies with RFC822
1650 # Revision 1.91  2002/01/08 04:03:47  richard
1651 # I mucked the intent of the code up.
1653 # Revision 1.90  2002/01/08 03:56:55  richard
1654 # Oops, missed this before the beta:
1655 #  . #495392 ] empty nosy -patch
1657 # Revision 1.89  2002/01/07 20:24:45  richard
1658 # *mutter* stupid cutnpaste
1660 # Revision 1.88  2002/01/02 02:31:38  richard
1661 # Sorry for the huge checkin message - I was only intending to implement #496356
1662 # but I found a number of places where things had been broken by transactions:
1663 #  . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
1664 #    for _all_ roundup-generated smtp messages to be sent to.
1665 #  . the transaction cache had broken the roundupdb.Class set() reactors
1666 #  . newly-created author users in the mailgw weren't being committed to the db
1668 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
1669 # on when I found that stuff :):
1670 #  . #496356 ] Use threading in messages
1671 #  . detectors were being registered multiple times
1672 #  . added tests for mailgw
1673 #  . much better attaching of erroneous messages in the mail gateway
1675 # Revision 1.87  2001/12/23 23:18:49  richard
1676 # We already had an admin-specific section of the web heading, no need to add
1677 # another one :)
1679 # Revision 1.86  2001/12/20 15:43:01  rochecompaan
1680 # Features added:
1681 #  .  Multilink properties are now displayed as comma separated values in
1682 #     a textbox
1683 #  .  The add user link is now only visible to the admin user
1684 #  .  Modified the mail gateway to reject submissions from unknown
1685 #     addresses if ANONYMOUS_ACCESS is denied
1687 # Revision 1.85  2001/12/20 06:13:24  rochecompaan
1688 # Bugs fixed:
1689 #   . Exception handling in hyperdb for strings-that-look-like numbers got
1690 #     lost somewhere
1691 #   . Internet Explorer submits full path for filename - we now strip away
1692 #     the path
1693 # Features added:
1694 #   . Link and multilink properties are now displayed sorted in the cgi
1695 #     interface
1697 # Revision 1.84  2001/12/18 15:30:30  rochecompaan
1698 # Fixed bugs:
1699 #  .  Fixed file creation and retrieval in same transaction in anydbm
1700 #     backend
1701 #  .  Cgi interface now renders new issue after issue creation
1702 #  .  Could not set issue status to resolved through cgi interface
1703 #  .  Mail gateway was changing status back to 'chatting' if status was
1704 #     omitted as an argument
1706 # Revision 1.83  2001/12/15 23:51:01  richard
1707 # Tested the changes and fixed a few problems:
1708 #  . files are now attached to the issue as well as the message
1709 #  . newuser is a real method now since we don't want to do the message/file
1710 #    stuff for it
1711 #  . added some documentation
1712 # The really big changes in the diff are a result of me moving some code
1713 # around to keep like methods together a bit better.
1715 # Revision 1.82  2001/12/15 19:24:39  rochecompaan
1716 #  . Modified cgi interface to change properties only once all changes are
1717 #    collected, files created and messages generated.
1718 #  . Moved generation of change note to nosyreactors.
1719 #  . We now check for changes to "assignedto" to ensure it's added to the
1720 #    nosy list.
1722 # Revision 1.81  2001/12/12 23:55:00  richard
1723 # Fixed some problems with user editing
1725 # Revision 1.80  2001/12/12 23:27:14  richard
1726 # Added a Zope frontend for roundup.
1728 # Revision 1.79  2001/12/10 22:20:01  richard
1729 # Enabled transaction support in the bsddb backend. It uses the anydbm code
1730 # where possible, only replacing methods where the db is opened (it uses the
1731 # btree opener specifically.)
1732 # Also cleaned up some change note generation.
1733 # Made the backends package work with pydoc too.
1735 # Revision 1.78  2001/12/07 05:59:27  rochecompaan
1736 # Fixed small bug that prevented adding issues through the web.
1738 # Revision 1.77  2001/12/06 22:48:29  richard
1739 # files multilink was being nuked in post_edit_node
1741 # Revision 1.76  2001/12/05 14:26:44  rochecompaan
1742 # Removed generation of change note from "sendmessage" in roundupdb.py.
1743 # The change note is now generated when the message is created.
1745 # Revision 1.75  2001/12/04 01:25:08  richard
1746 # Added some rollbacks where we were catching exceptions that would otherwise
1747 # have stopped committing.
1749 # Revision 1.74  2001/12/02 05:06:16  richard
1750 # . We now use weakrefs in the Classes to keep the database reference, so
1751 #   the close() method on the database is no longer needed.
1752 #   I bumped the minimum python requirement up to 2.1 accordingly.
1753 # . #487480 ] roundup-server
1754 # . #487476 ] INSTALL.txt
1756 # I also cleaned up the change message / post-edit stuff in the cgi client.
1757 # There's now a clearly marked "TODO: append the change note" where I believe
1758 # the change note should be added there. The "changes" list will obviously
1759 # have to be modified to be a dict of the changes, or somesuch.
1761 # More testing needed.
1763 # Revision 1.73  2001/12/01 07:17:50  richard
1764 # . We now have basic transaction support! Information is only written to
1765 #   the database when the commit() method is called. Only the anydbm
1766 #   backend is modified in this way - neither of the bsddb backends have been.
1767 #   The mail, admin and cgi interfaces all use commit (except the admin tool
1768 #   doesn't have a commit command, so interactive users can't commit...)
1769 # . Fixed login/registration forwarding the user to the right page (or not,
1770 #   on a failure)
1772 # Revision 1.72  2001/11/30 20:47:58  rochecompaan
1773 # Links in page header are now consistent with default sort order.
1775 # Fixed bugs:
1776 #     - When login failed the list of issues were still rendered.
1777 #     - User was redirected to index page and not to his destination url
1778 #       if his first login attempt failed.
1780 # Revision 1.71  2001/11/30 20:28:10  rochecompaan
1781 # Property changes are now completely traceable, whether changes are
1782 # made through the web or by email
1784 # Revision 1.70  2001/11/30 00:06:29  richard
1785 # Converted roundup/cgi_client.py to use _()
1786 # Added the status file, I18N_PROGRESS.txt
1788 # Revision 1.69  2001/11/29 23:19:51  richard
1789 # Removed the "This issue has been edited through the web" when a valid
1790 # change note is supplied.
1792 # Revision 1.68  2001/11/29 04:57:23  richard
1793 # a little comment
1795 # Revision 1.67  2001/11/28 21:55:35  richard
1796 #  . login_action and newuser_action return values were being ignored
1797 #  . Woohoo! Found that bloody re-login bug that was killing the mail
1798 #    gateway.
1799 #  (also a minor cleanup in hyperdb)
1801 # Revision 1.66  2001/11/27 03:00:50  richard
1802 # couple of bugfixes from latest patch integration
1804 # Revision 1.65  2001/11/26 23:00:53  richard
1805 # This config stuff is getting to be a real mess...
1807 # Revision 1.64  2001/11/26 22:56:35  richard
1808 # typo
1810 # Revision 1.63  2001/11/26 22:55:56  richard
1811 # Feature:
1812 #  . Added INSTANCE_NAME to configuration - used in web and email to identify
1813 #    the instance.
1814 #  . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
1815 #    signature info in e-mails.
1816 #  . Some more flexibility in the mail gateway and more error handling.
1817 #  . Login now takes you to the page you back to the were denied access to.
1819 # Fixed:
1820 #  . Lots of bugs, thanks Roché and others on the devel mailing list!
1822 # Revision 1.62  2001/11/24 00:45:42  jhermann
1823 # typeof() instead of type(): avoid clash with database field(?) "type"
1825 # Fixes this traceback:
1827 # Traceback (most recent call last):
1828 #   File "roundup\cgi_client.py", line 535, in newnode
1829 #     self._post_editnode(nid)
1830 #   File "roundup\cgi_client.py", line 415, in _post_editnode
1831 #     if type(value) != type([]): value = [value]
1832 # UnboundLocalError: local variable 'type' referenced before assignment
1834 # Revision 1.61  2001/11/22 15:46:42  jhermann
1835 # Added module docstrings to all modules.
1837 # Revision 1.60  2001/11/21 22:57:28  jhermann
1838 # Added dummy hooks for I18N and some preliminary (test) markup of
1839 # translatable messages
1841 # Revision 1.59  2001/11/21 03:21:13  richard
1842 # oops
1844 # Revision 1.58  2001/11/21 03:11:28  richard
1845 # Better handling of new properties.
1847 # Revision 1.57  2001/11/15 10:24:27  richard
1848 # handle the case where there is no file attached
1850 # Revision 1.56  2001/11/14 21:35:21  richard
1851 #  . users may attach files to issues (and support in ext) through the web now
1853 # Revision 1.55  2001/11/07 02:34:06  jhermann
1854 # Handling of damaged login cookies
1856 # Revision 1.54  2001/11/07 01:16:12  richard
1857 # Remove the '=' padding from cookie value so quoting isn't an issue.
1859 # Revision 1.53  2001/11/06 23:22:05  jhermann
1860 # More IE fixes: it does not like quotes around cookie values; in the
1861 # hope this does not break anything for other browser; if it does, we
1862 # need to check HTTP_USER_AGENT
1864 # Revision 1.52  2001/11/06 23:11:22  jhermann
1865 # Fixed debug output in page footer; added expiry date to the login cookie
1866 # (expires 1 year in the future) to prevent probs with certain versions
1867 # of IE
1869 # Revision 1.51  2001/11/06 22:00:34  jhermann
1870 # Get debug level from ROUNDUP_DEBUG env var
1872 # Revision 1.50  2001/11/05 23:45:40  richard
1873 # Fixed newuser_action so it sets the cookie with the unencrypted password.
1874 # Also made it present nicer error messages (not tracebacks).
1876 # Revision 1.49  2001/11/04 03:07:12  richard
1877 # Fixed various cookie-related bugs:
1878 #  . bug #477685 ] base64.decodestring breaks
1879 #  . bug #477837 ] lynx does not like the cookie
1880 #  . bug #477892 ] Password edit doesn't fix login cookie
1881 # Also closed a security hole - a logged-in user could edit another user's
1882 # details.
1884 # Revision 1.48  2001/11/03 01:30:18  richard
1885 # Oops. uses pagefoot now.
1887 # Revision 1.47  2001/11/03 01:29:28  richard
1888 # Login page didn't have all close tags.
1890 # Revision 1.46  2001/11/03 01:26:55  richard
1891 # possibly fix truncated base64'ed user:pass
1893 # Revision 1.45  2001/11/01 22:04:37  richard
1894 # Started work on supporting a pop3-fetching server
1895 # Fixed bugs:
1896 #  . bug #477104 ] HTML tag error in roundup-server
1897 #  . bug #477107 ] HTTP header problem
1899 # Revision 1.44  2001/10/28 23:03:08  richard
1900 # Added more useful header to the classic schema.
1902 # Revision 1.43  2001/10/24 00:01:42  richard
1903 # More fixes to lockout logic.
1905 # Revision 1.42  2001/10/23 23:56:03  richard
1906 # HTML typo
1908 # Revision 1.41  2001/10/23 23:52:35  richard
1909 # Fixed lock-out logic, thanks Roch'e for pointing out the problems.
1911 # Revision 1.40  2001/10/23 23:06:39  richard
1912 # Some cleanup.
1914 # Revision 1.39  2001/10/23 01:00:18  richard
1915 # Re-enabled login and registration access after lopping them off via
1916 # disabling access for anonymous users.
1917 # Major re-org of the htmltemplate code, cleaning it up significantly. Fixed
1918 # a couple of bugs while I was there. Probably introduced a couple, but
1919 # things seem to work OK at the moment.
1921 # Revision 1.38  2001/10/22 03:25:01  richard
1922 # Added configuration for:
1923 #  . anonymous user access and registration (deny/allow)
1924 #  . filter "widget" location on index page (top, bottom, both)
1925 # Updated some documentation.
1927 # Revision 1.37  2001/10/21 07:26:35  richard
1928 # feature #473127: Filenames. I modified the file.index and htmltemplate
1929 #  source so that the filename is used in the link and the creation
1930 #  information is displayed.
1932 # Revision 1.36  2001/10/21 04:44:50  richard
1933 # bug #473124: UI inconsistency with Link fields.
1934 #    This also prompted me to fix a fairly long-standing usability issue -
1935 #    that of being able to turn off certain filters.
1937 # Revision 1.35  2001/10/21 00:17:54  richard
1938 # CGI interface view customisation section may now be hidden (patch from
1939 #  Roch'e Compaan.)
1941 # Revision 1.34  2001/10/20 11:58:48  richard
1942 # Catch errors in login - no username or password supplied.
1943 # Fixed editing of password (Password property type) thanks Roch'e Compaan.
1945 # Revision 1.33  2001/10/17 00:18:41  richard
1946 # Manually constructing cookie headers now.
1948 # Revision 1.32  2001/10/16 03:36:21  richard
1949 # CGI interface wasn't handling checkboxes at all.
1951 # Revision 1.31  2001/10/14 10:55:00  richard
1952 # Handle empty strings in HTML template Link function
1954 # Revision 1.30  2001/10/09 07:38:58  richard
1955 # Pushed the base code for the extended schema CGI interface back into the
1956 # code cgi_client module so that future updates will be less painful.
1957 # Also removed a debugging print statement from cgi_client.
1959 # Revision 1.29  2001/10/09 07:25:59  richard
1960 # Added the Password property type. See "pydoc roundup.password" for
1961 # implementation details. Have updated some of the documentation too.
1963 # Revision 1.28  2001/10/08 00:34:31  richard
1964 # Change message was stuffing up for multilinks with no key property.
1966 # Revision 1.27  2001/10/05 02:23:24  richard
1967 #  . roundup-admin create now prompts for property info if none is supplied
1968 #    on the command-line.
1969 #  . hyperdb Class getprops() method may now return only the mutable
1970 #    properties.
1971 #  . Login now uses cookies, which makes it a whole lot more flexible. We can
1972 #    now support anonymous user access (read-only, unless there's an
1973 #    "anonymous" user, in which case write access is permitted). Login
1974 #    handling has been moved into cgi_client.Client.main()
1975 #  . The "extended" schema is now the default in roundup init.
1976 #  . The schemas have had their page headings modified to cope with the new
1977 #    login handling. Existing installations should copy the interfaces.py
1978 #    file from the roundup lib directory to their instance home.
1979 #  . Incorrectly had a Bizar Software copyright on the cgitb.py module from
1980 #    Ping - has been removed.
1981 #  . Fixed a whole bunch of places in the CGI interface where we should have
1982 #    been returning Not Found instead of throwing an exception.
1983 #  . Fixed a deviation from the spec: trying to modify the 'id' property of
1984 #    an item now throws an exception.
1986 # Revision 1.26  2001/09/12 08:31:42  richard
1987 # handle cases where mime type is not guessable
1989 # Revision 1.25  2001/08/29 05:30:49  richard
1990 # change messages weren't being saved when there was no-one on the nosy list.
1992 # Revision 1.24  2001/08/29 04:49:39  richard
1993 # didn't clean up fully after debugging :(
1995 # Revision 1.23  2001/08/29 04:47:18  richard
1996 # Fixed CGI client change messages so they actually include the properties
1997 # changed (again).
1999 # Revision 1.22  2001/08/17 00:08:10  richard
2000 # reverted back to sending messages always regardless of who is doing the web
2001 # edit. change notes weren't being saved. bleah. hackish.
2003 # Revision 1.21  2001/08/15 23:43:18  richard
2004 # Fixed some isFooTypes that I missed.
2005 # Refactored some code in the CGI code.
2007 # Revision 1.20  2001/08/12 06:32:36  richard
2008 # using isinstance(blah, Foo) now instead of isFooType
2010 # Revision 1.19  2001/08/07 00:24:42  richard
2011 # stupid typo
2013 # Revision 1.18  2001/08/07 00:15:51  richard
2014 # Added the copyright/license notice to (nearly) all files at request of
2015 # Bizar Software.
2017 # Revision 1.17  2001/08/02 06:38:17  richard
2018 # Roundupdb now appends "mailing list" information to its messages which
2019 # include the e-mail address and web interface address. Templates may
2020 # override this in their db classes to include specific information (support
2021 # instructions, etc).
2023 # Revision 1.16  2001/08/02 05:55:25  richard
2024 # Web edit messages aren't sent to the person who did the edit any more. No
2025 # message is generated if they are the only person on the nosy list.
2027 # Revision 1.15  2001/08/02 00:34:10  richard
2028 # bleah syntax error
2030 # Revision 1.14  2001/08/02 00:26:16  richard
2031 # Changed the order of the information in the message generated by web edits.
2033 # Revision 1.13  2001/07/30 08:12:17  richard
2034 # Added time logging and file uploading to the templates.
2036 # Revision 1.12  2001/07/30 06:26:31  richard
2037 # Added some documentation on how the newblah works.
2039 # Revision 1.11  2001/07/30 06:17:45  richard
2040 # Features:
2041 #  . Added ability for cgi newblah forms to indicate that the new node
2042 #    should be linked somewhere.
2043 # Fixed:
2044 #  . Fixed the agument handling for the roundup-admin find command.
2045 #  . Fixed handling of summary when no note supplied for newblah. Again.
2046 #  . Fixed detection of no form in htmltemplate Field display.
2048 # Revision 1.10  2001/07/30 02:37:34  richard
2049 # Temporary measure until we have decent schema migration...
2051 # Revision 1.9  2001/07/30 01:25:07  richard
2052 # Default implementation is now "classic" rather than "extended" as one would
2053 # expect.
2055 # Revision 1.8  2001/07/29 08:27:40  richard
2056 # Fixed handling of passed-in values in form elements (ie. during a
2057 # drill-down)
2059 # Revision 1.7  2001/07/29 07:01:39  richard
2060 # Added vim command to all source so that we don't get no steenkin' tabs :)
2062 # Revision 1.6  2001/07/29 04:04:00  richard
2063 # Moved some code around allowing for subclassing to change behaviour.
2065 # Revision 1.5  2001/07/28 08:16:52  richard
2066 # New issue form handles lack of note better now.
2068 # Revision 1.4  2001/07/28 00:34:34  richard
2069 # Fixed some non-string node ids.
2071 # Revision 1.3  2001/07/23 03:56:30  richard
2072 # oops, missed a config removal
2074 # Revision 1.2  2001/07/22 12:09:32  richard
2075 # Final commit of Grande Splite
2077 # Revision 1.1  2001/07/22 11:58:35  richard
2078 # More Grande Splite
2081 # vim: set filetype=python ts=4 sw=4 et si