Skip to content

Commit fe48bdb

Browse files
author
Richard Jones
committed
mailgw was assuming certain properties existed on the issues being created.
1 parent f220a75 commit fe48bdb

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

roundup/hyperdb.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: hyperdb.py,v 1.10 2001-07-30 02:38:31 richard Exp $
1+
# $iD: HYperdb.py,v 1.10 2001/07/30 02:38:31 richard Exp $
22

33
# standard python modules
44
import cPickle, re, string
@@ -119,7 +119,12 @@ def create(self, **propvalues):
119119
else:
120120
raise ValueError, 'node with key "%s" exists'%value
121121

122-
prop = self.properties[key]
122+
# try to handle this property
123+
try:
124+
prop = self.properties[key]
125+
except KeyError:
126+
raise KeyError, '"%s" has no property "%s"'%(self.classname,
127+
key)
123128

124129
if prop.isLinkType:
125130
if type(value) != type(''):
@@ -793,6 +798,9 @@ def Choice(name, *options):
793798

794799
#
795800
# $Log: not supported by cvs2svn $
801+
# Revision 1.10 2001/07/30 02:38:31 richard
802+
# get() now has a default arg - for migration only.
803+
#
796804
# Revision 1.9 2001/07/29 09:28:23 richard
797805
# Fixed sorting by clicking on column headings.
798806
#

roundup/mailgw.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class node. Any parts of other types are each stored in separate files
5555
an exception, the original message is bounced back to the sender with the
5656
explanatory message given in the exception.
5757
58-
$Id: mailgw.py,v 1.5 2001-07-29 07:01:39 richard Exp $
58+
$Id: mailgw.py,v 1.6 2001-08-01 04:24:21 richard Exp $
5959
'''
6060

6161

@@ -258,36 +258,37 @@ def handle_message(self, message):
258258
# handle the files
259259
files = []
260260
for (name, type, data) in attachments:
261-
files.append(self.db.file.create(type=type, name=name, content=data))
261+
files.append(self.db.file.create(type=type, name=name,
262+
content=data))
262263

263264
# now handle the db stuff
264265
if nodeid:
265-
# If an item designator (class name and id number) is found there, the
266-
# newly created "msg" node is added to the "messages" property for
267-
# that item, and any new "file" nodes are added to the "files"
266+
# If an item designator (class name and id number) is found there,
267+
# the newly created "msg" node is added to the "messages" property
268+
# for that item, and any new "file" nodes are added to the "files"
268269
# property for the item.
269-
message_id = self.db.msg.create(author=author, recipients=recipients,
270-
date=date.Date('.'), summary=summary, content=content,
271-
files=files)
270+
message_id = self.db.msg.create(author=author,
271+
recipients=recipients, date=date.Date('.'), summary=summary,
272+
content=content, files=files)
272273
messages = cl.get(nodeid, 'messages')
273274
messages.append(message_id)
274275
props['messages'] = messages
275-
apply(cl.set, (nodeid, ), props)
276+
cl.set(nodeid, **props)
276277
else:
277278
# If just an item class name is found there, we attempt to create a
278279
# new item of that class with its "messages" property initialized to
279280
# contain the new "msg" node and its "files" property initialized to
280281
# contain any new "file" nodes.
281-
message_id = self.db.msg.create(author=author, recipients=recipients,
282-
date=date.Date('.'), summary=summary, content=content,
283-
files=files)
284-
if not props.has_key('assignedto'):
282+
message_id = self.db.msg.create(author=author,
283+
recipients=recipients, date=date.Date('.'), summary=summary,
284+
content=content, files=files)
285+
# fill out the properties with defaults where required
286+
if properties.has_key('assignedto') and \
287+
not props.has_key('assignedto'):
285288
props['assignedto'] = '1' # "admin"
286-
if not props.has_key('priority'):
287-
props['priority'] = '1' # "bug-fatal"
288-
if not props.has_key('status'):
289+
if properties.has_key('status') and not props.has_key('status'):
289290
props['status'] = '1' # "unread"
290-
if not props.has_key('title'):
291+
if properties.has_key('title') and not props.has_key('title'):
291292
props['title'] = title
292293
props['messages'] = [message_id]
293294
props['nosy'] = recipients[:]
@@ -297,6 +298,9 @@ def handle_message(self, message):
297298

298299
#
299300
# $Log: not supported by cvs2svn $
301+
# Revision 1.5 2001/07/29 07:01:39 richard
302+
# Added vim command to all source so that we don't get no steenkin' tabs :)
303+
#
300304
# Revision 1.4 2001/07/28 06:43:02 richard
301305
# Multipart message class has the getPart method now. Added some tests for it.
302306
#

0 commit comments

Comments
 (0)