Skip to content

Commit c729684

Browse files
author
Richard Jones
committed
web forms may now unset Link values (like assignedto)
1 parent 3b0973e commit c729684

File tree

8 files changed

+79
-22
lines changed

8 files changed

+79
-22
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ Fixed:
99
. #571170 ] gdbm deadlock
1010
. #576241 ] MultiLink problems in parsePropsFromForm
1111
. fixed the date module so that Date(". - 2d") works
12+
. web forms may now unset Link values (like assignedto)
1213

1314
Feature:
15+
TODO: roll stuff in from the TODO to here
1416
. added capability to save queries:
1517
- a query Class with name, klass (to search) and url (query string) properties
1618
- a Multilink to query on user called queries

doc/upgrading.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ reindexing
1919
TODO: dbinit now imports classes from selct_db
2020
TODO: select_db needs fixing to include Class, FileClass and IssueClass
2121
TODO: migration of security settings
22+
TODO: nosy reactor has been updated
2223

2324

2425
Migrating from 0.4.1 to 0.4.2

roundup/backends/back_anydbm.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.56 2002-07-31 22:04:33 richard Exp $
18+
#$Id: back_anydbm.py,v 1.57 2002-07-31 23:57:36 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -998,21 +998,23 @@ class or a KeyError is raised.
998998

999999
# do stuff based on the prop type
10001000
if isinstance(prop, Link):
1001-
link_class = self.properties[propname].classname
1001+
link_class = prop.classname
10021002
# if it isn't a number, it's a key
1003-
if type(value) != type(''):
1004-
raise ValueError, 'link value must be String'
1005-
if not num_re.match(value):
1003+
if value is not None and not isinstance(value, type('')):
1004+
raise ValueError, 'property "%s" link value be a string'%(
1005+
propname)
1006+
if isinstance(value, type('')) and not num_re.match(value):
10061007
try:
10071008
value = self.db.classes[link_class].lookup(value)
10081009
except (TypeError, KeyError):
10091010
raise IndexError, 'new property "%s": %s not a %s'%(
1010-
propname, value, self.properties[propname].classname)
1011+
propname, value, prop.classname)
10111012

1012-
if not self.db.getclass(link_class).hasnode(value):
1013+
if (value is not None and
1014+
not self.db.getclass(link_class).hasnode(value)):
10131015
raise IndexError, '%s has no node %s'%(link_class, value)
10141016

1015-
if self.do_journal and self.properties[propname].do_journal:
1017+
if self.do_journal and prop.do_journal:
10161018
# register the unlink with the old linked node
10171019
if node[propname] is not None:
10181020
self.db.addjournal(link_class, node[propname], 'unlink',
@@ -1791,6 +1793,9 @@ def __init__(self, db, classname, **properties):
17911793

17921794
#
17931795
#$Log: not supported by cvs2svn $
1796+
#Revision 1.56 2002/07/31 22:04:33 richard
1797+
#cleanup
1798+
#
17941799
#Revision 1.55 2002/07/30 08:22:38 richard
17951800
#Session storage in the hyperdb was horribly, horribly inefficient. We use
17961801
#a simple anydbm wrapper now - which could be overridden by the metakit

roundup/backends/back_metakit.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,11 @@ def set(self, nodeid, **propvalues):
324324
# do stuff based on the prop type
325325
if isinstance(prop, hyperdb.Link):
326326
link_class = prop.classname
327+
# must be a string or None
328+
if value is not None and not isinstance(value, type('')):
329+
raise ValueError, 'property "%s" link value be a string'%(
330+
propname)
327331
# if it isn't a number, it's a key
328-
if type(value) != _STRINGTYPE:
329-
raise ValueError, 'link value must be String'
330332
try:
331333
int(value)
332334
except ValueError:
@@ -336,7 +338,8 @@ def set(self, nodeid, **propvalues):
336338
raise IndexError, 'new property "%s": %s not a %s'%(
337339
key, value, prop.classname)
338340

339-
if not self.db.getclass(link_class).hasnode(value):
341+
if (value is not None and
342+
not self.db.getclass(link_class).hasnode(value)):
340343
raise IndexError, '%s has no node %s'%(link_class, value)
341344

342345
setattr(row, key, int(value))
@@ -345,11 +348,13 @@ def set(self, nodeid, **propvalues):
345348
if self.do_journal and prop.do_journal:
346349
# register the unlink with the old linked node
347350
if oldvalue:
348-
self.db.addjournal(link_class, value, _UNLINK, (self.classname, str(row.id), key))
351+
self.db.addjournal(link_class, value, _UNLINK,
352+
(self.classname, str(row.id), key))
349353

350354
# register the link with the newly linked node
351355
if value:
352-
self.db.addjournal(link_class, value, _LINK, (self.classname, str(row.id), key))
356+
self.db.addjournal(link_class, value, _LINK,
357+
(self.classname, str(row.id), key))
353358

354359
elif isinstance(prop, hyperdb.Multilink):
355360
if type(value) != _LISTTYPE:

roundup/cgi_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.153 2002-07-31 22:40:50 gmcm Exp $
18+
# $Id: cgi_client.py,v 1.154 2002-07-31 23:57:36 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -1631,8 +1631,7 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
16311631
value = form[key].value.strip()
16321632
# see if it's the "no selection" choice
16331633
if value == '-1':
1634-
# don't set this property
1635-
continue
1634+
value = None
16361635
else:
16371636
# handle key values
16381637
link = cl.properties[key].classname
@@ -1691,6 +1690,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
16911690

16921691
#
16931692
# $Log: not supported by cvs2svn $
1693+
# Revision 1.153 2002/07/31 22:40:50 gmcm
1694+
# Fixes to the search form and saving queries.
1695+
# Fixes to sorting in back_metakit.py.
1696+
#
16941697
# Revision 1.152 2002/07/31 22:04:14 richard
16951698
# cleanup
16961699
#

roundup/templates/classic/detectors/nosyreaction.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.12 2002-05-29 01:16:17 richard Exp $
18+
#$Id: nosyreaction.py,v 1.13 2002-07-31 23:57:36 richard Exp $
1919

2020
from roundup import roundupdb, hyperdb
2121

@@ -88,7 +88,7 @@ def updatenosy(db, cl, nodeid, newvalues):
8888
current[value] = 1
8989

9090
# add assignedto(s) to the nosy list
91-
if newvalues.has_key('assignedto'):
91+
if newvalues.has_key('assignedto') and newvalues['assignedto'] is not None:
9292
propdef = cl.getprops()
9393
if isinstance(propdef['assignedto'], hyperdb.Link):
9494
assignedto_ids = [newvalues['assignedto']]
@@ -141,6 +141,18 @@ def init(db):
141141

142142
#
143143
#$Log: not supported by cvs2svn $
144+
#Revision 1.12 2002/05/29 01:16:17 richard
145+
#Sorry about this huge checkin! It's fixing a lot of related stuff in one go
146+
#though.
147+
#
148+
#. #541941 ] changing multilink properties by mail
149+
#. #526730 ] search for messages capability
150+
#. #505180 ] split MailGW.handle_Message
151+
# - also changed cgi client since it was duplicating the functionality
152+
#. build htmlbase if tests are run using CVS checkout (removed note from
153+
# installation.txt)
154+
#. don't create an empty message on email issue creation if the email is empty
155+
#
144156
#Revision 1.11 2002/01/14 22:21:38 richard
145157
##503353 ] setting properties in initial email
146158
#

roundup/templates/extended/detectors/nosyreaction.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.12 2002-05-29 01:16:17 richard Exp $
18+
#$Id: nosyreaction.py,v 1.13 2002-07-31 23:57:37 richard Exp $
1919

2020
from roundup import roundupdb, hyperdb
2121

@@ -88,7 +88,7 @@ def updatenosy(db, cl, nodeid, newvalues):
8888
current[value] = 1
8989

9090
# add assignedto(s) to the nosy list
91-
if newvalues.has_key('assignedto'):
91+
if newvalues.has_key('assignedto') and newvalues['assignedto'] is not None:
9292
propdef = cl.getprops()
9393
if isinstance(propdef['assignedto'], hyperdb.Link):
9494
assignedto_ids = [newvalues['assignedto']]
@@ -141,6 +141,18 @@ def init(db):
141141

142142
#
143143
#$Log: not supported by cvs2svn $
144+
#Revision 1.12 2002/05/29 01:16:17 richard
145+
#Sorry about this huge checkin! It's fixing a lot of related stuff in one go
146+
#though.
147+
#
148+
#. #541941 ] changing multilink properties by mail
149+
#. #526730 ] search for messages capability
150+
#. #505180 ] split MailGW.handle_Message
151+
# - also changed cgi client since it was duplicating the functionality
152+
#. build htmlbase if tests are run using CVS checkout (removed note from
153+
# installation.txt)
154+
#. don't create an empty message on email issue creation if the email is empty
155+
#
144156
#Revision 1.11 2002/01/14 22:21:38 richard
145157
##503353 ] setting properties in initial email
146158
#

test/test_db.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: test_db.py,v 1.38 2002-07-26 08:27:00 richard Exp $
18+
# $Id: test_db.py,v 1.39 2002-07-31 23:57:37 richard Exp $
1919

2020
import unittest, os, shutil, time
2121

@@ -90,12 +90,16 @@ def testStringChange(self):
9090
self.assertEqual(self.db.issue.get('2', 'title'), 'ham')
9191
self.db.commit()
9292
self.assertEqual(self.db.issue.get('2', 'title'), 'ham')
93+
self.db.issue.set('1', title=None)
94+
self.assertEqual(self.db.issue.get('1', "title"), None)
9395

9496
def testLinkChange(self):
9597
self.db.issue.create(title="spam", status='1')
9698
self.assertEqual(self.db.issue.get('1', "status"), '1')
9799
self.db.issue.set('1', status='2')
98100
self.assertEqual(self.db.issue.get('1', "status"), '2')
101+
self.db.issue.set('1', status=None)
102+
self.assertEqual(self.db.issue.get('1', "status"), None)
99103

100104
def testDateChange(self):
101105
self.db.issue.create(title="spam", status='1')
@@ -106,12 +110,16 @@ def testDateChange(self):
106110
self.assertNotEqual(a, b)
107111
self.assertNotEqual(b, date.Date('1970-1-1 00:00:00'))
108112
self.db.issue.set('1', deadline=date.Date())
113+
self.db.issue.set('1', deadline=None)
114+
self.assertEqual(self.db.issue.get('1', "deadline"), None)
109115

110116
def testIntervalChange(self):
111117
self.db.issue.create(title="spam", status='1')
112118
a = self.db.issue.get('1', "foo")
113119
self.db.issue.set('1', foo=date.Interval('-1d'))
114120
self.assertNotEqual(self.db.issue.get('1', "foo"), a)
121+
self.db.issue.set('1', foo=None)
122+
self.assertEqual(self.db.issue.get('1', "foo"), None)
115123

116124
def testBooleanChange(self):
117125
userid = self.db.user.create(username='foo', assignable=1)
@@ -121,13 +129,17 @@ def testBooleanChange(self):
121129
self.assertNotEqual(self.db.user.get(userid, 'assignable'), a)
122130
self.db.user.set(userid, assignable=0)
123131
self.db.user.set(userid, assignable=1)
132+
self.db.user.set('1', assignable=None)
133+
self.assertEqual(self.db.user.get('1', "assignable"), None)
124134

125135
def testNumberChange(self):
126136
self.db.user.create(username='foo', age='1')
127137
a = self.db.user.get('1', 'age')
128138
self.db.user.set('1', age='3')
129139
self.assertNotEqual(self.db.user.get('1', 'age'), a)
130140
self.db.user.set('1', age='1.0')
141+
self.db.user.set('1', age=None)
142+
self.assertEqual(self.db.user.get('1', "age"), None)
131143

132144
def testNewProperty(self):
133145
self.db.issue.create(title="spam", status='1')
@@ -576,7 +588,7 @@ def suite():
576588
unittest.makeSuite(anydbmDBTestCase, 'test'),
577589
unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test')
578590
]
579-
# return unittest.TestSuite(l)
591+
#return unittest.TestSuite(l)
580592

581593
try:
582594
import bsddb
@@ -603,6 +615,11 @@ def suite():
603615

604616
#
605617
# $Log: not supported by cvs2svn $
618+
# Revision 1.38 2002/07/26 08:27:00 richard
619+
# Very close now. The cgi and mailgw now use the new security API. The two
620+
# templates have been migrated to that setup. Lots of unit tests. Still some
621+
# issue in the web form for editing Roles assigned to users.
622+
#
606623
# Revision 1.37 2002/07/25 07:14:06 richard
607624
# Bugger it. Here's the current shape of the new security implementation.
608625
# Still to do:

0 commit comments

Comments
 (0)