Index: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	(revision 203)
+++ trunk/ChangeLog	(revision 204)
@@ -22,4 +22,23 @@
 	  closes request #55
 
+	  email2trac.conf use same format as trac.ini, eg email2trac.conf:
+	  [project]
+	  default_component : test
+
+	  the ticket_prefix can be overriden by the commandline option:
+	   * -t,--ticket_prefix <value>
+
+	  The feature can be used to have different settings for different 
+	  email aliases
+
+	  Requested by: greg dot deakyne at etapestry dot com
+	  Implemented by: Bas van der Vlies
+
+
+	* Fixed a bug in ticket_update. It failed when project did not have 
+	  ticket component field,  closes bug #62
+	  Reported by: gernot dot hillier add siemens dot com
+	  Fixed by: Bas van der Vlies
+	  
 	* run_email2trac.c:
 	   - can no longer segfault after a failed malloc.
Index: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	(revision 203)
+++ trunk/debian/changelog	(revision 204)
@@ -1,2 +1,8 @@
+email2trac (0.20-1) stable; urgency=low
+
+  * New version, see Changelog
+
+ -- root <root@rc.sara.nl>  Tue, 27 May 2008 23:12:54 +0200
+
 email2trac (0.13.0-1) stable; urgency=low
 
Index: trunk/email2trac.py.in
===================================================================
--- trunk/email2trac.py.in	(revision 203)
+++ trunk/email2trac.py.in	(revision 204)
@@ -107,7 +107,4 @@
 trac_default_version = '0.10'
 m = None 
-DRY_RUN = False
-
-
 
 # A UTC class needed for trac version 0.11, added by
@@ -133,5 +130,5 @@
 	comment = '> '
     
-	def __init__(self, env, parameters, version):
+	def __init__(self, env, parameters, version, dry_run):
 		self.env = env
 
@@ -147,4 +144,6 @@
 
 		self.VERSION = version
+		self.DRY_RUN = dry_run
+
 		self.get_config = self.env.config.get
 
@@ -260,13 +259,13 @@
 				print 'This message is a SPAM. Automatic ticket insertion refused (SPAM level > %d' % self.SPAM_LEVEL
 
-			return True	
+			return 'drop'	
 
 		elif spam:
 
-			return 'Spam'
-
-		else:
-
-			return self.get_config('ticket', 'default_component') 
+			return 'Spam'	
+
+		else:
+
+			return False
 
 
@@ -530,5 +529,5 @@
 					print  'ticket_field\t %s = %s' %(field,  ticket[field])
 					
-	def ticket_update(self, m):
+	def ticket_update(self, m, spam):
 		"""
 		If the current email is a reply to an existing ticket, this function
@@ -536,5 +535,4 @@
 		creating a new one.
 		"""
-		global DRY_RUN
 
 		if not m['Subject']:
@@ -609,5 +607,5 @@
 			str = self.attachments(m, tkt)
 
-		if self.notification:
+		if self.notification and not spam:
 			self.notify(tkt, False, when)
 
@@ -654,5 +652,5 @@
 
 
-	def new_ticket(self, msg):
+	def new_ticket(self, msg, spam):
 		"""
 		Create a new ticket
@@ -673,5 +671,8 @@
 		# Old style setting for component, will be removed
 		#
-		if settings.has_key('component'):
+		if spam:
+			tkt['component'] = 'Spam'
+
+		elif settings.has_key('component'):
 			tkt['component'] = settings['component']
 
@@ -700,5 +701,5 @@
 		when = datetime.now(utc)
 
-		if DRY_RUN:
+		if self.DRY_RUN:
 			ticket_id = 'DRY_RUN'
 		else:
@@ -725,5 +726,5 @@
 
 		if changed:
-			if DRY_RUN:
+			if self.DRY_RUN:
 				print 'DRY_RUN: tkt.save_changes(self.author, comment)'
 			else:
@@ -732,8 +733,9 @@
 
 		if self.notification:
-			if DRY_RUN:
+			if self.DRY_RUN:
 				print 'DRY_RUN: self.notify(tkt, True)'
 			else:
-				self.notify(tkt, True)
+				if not spam:
+					self.notify(tkt, True)
 				#self.notify(tkt, False)
 
@@ -757,9 +759,14 @@
  			return False
 
-	    # If component is true then we drop the message drop message
-		#
-		if self.spam(m) == True:
+		# If drop the message
+		#
+		if self.spam(m) == 'drop':
 			return False
 
+		elif self.spam(m) == 'spam':
+			spam_msg = True
+
+		else:
+			spam_msg = False
 
 		if self.get_config('notification', 'smtp_enabled') in ['true']:
@@ -771,8 +778,8 @@
 		#
 		if self.TICKET_UPDATE > 0:
-			if self.ticket_update(m):
+			if self.ticket_update(m, spam_msg):
 				return True
 
-		self.new_ticket(m)
+		self.new_ticket(m, spam_msg)
 
 	def strip_signature(self, text):
@@ -905,7 +912,4 @@
 		A wrapper for the TRAC notify function. So we can use templates
 		"""
-		if tkt['component'] == 'Spam':
-			return	
-
 		try:
 			# create false {abs_}href properties, to trick Notify()
@@ -1097,12 +1101,12 @@
 	# Default config file
 	#
-	global DRY_RUN
-
 	configfile = '@email2trac_conf@'
 	project = ''
 	component = ''
 	ticket_prefix = 'default'
+	dry_run = None
 
 	ENABLE_SYSLOG = 0
+
 
 	SHORT_OPT = 'chf:np:t:'
@@ -1126,5 +1130,5 @@
 			configfile = value
 		elif opt in ['-n', '--dry-run']:
-			DRY_RUN = True
+			dry_run = True
 		elif opt in ['-p', '--project']:
 			project_name = value
@@ -1195,5 +1199,5 @@
 
 		env = Environment(settings['project'], create=0)
-		tktparser = TicketEmailParser(env, settings, float(version))
+		tktparser = TicketEmailParser(env, settings, float(version), dry_run)
 		tktparser.parse(sys.stdin)
 
