Changeset 8334 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 3 May 2012, 20:43:02 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py
r8331 r8334 204 204 parent = self.getParent(row, site) 205 205 parent.addApplicant(obj) 206 # We have to log this if state is provided. If not, 207 # logging is done by the event handler handle_applicant_added 208 if row.has_key('state'): 209 parent.__parent__.logger.info( 210 '%s - Application initialized' % obj.applicant_id) 206 #parent.__parent__.logger.info( 207 # 'Applicant imported: %s' % obj.applicant_id) 211 208 history = IObjectHistory(obj) 212 history.addMessage(_('Application initialized'))209 history.addMessage(_('Application record imported')) 213 210 return 214 211 … … 218 215 parent = applicant.__parent__ 219 216 del parent[applicant.application_number] 217 #parent.__parent__.logger.info( 218 # 'Applicant removed: %s' % applicant.applicant_id) 220 219 pass 221 220 … … 224 223 """ 225 224 items_changed = '' 226 227 225 # Remove application_number from row if empty 228 226 if row.has_key('application_number') and row['application_number'] in ( … … 235 233 obj.applicant_id = u'%s_%s' % ( 236 234 row['container_code'], row['application_number']) 235 items_changed += ('%s=%s, ' % ('applicant_id', obj.applicant_id)) 237 236 row.pop('application_number') 238 237 239 238 # Update password 240 passwd = row.get('password', IGNORE_MARKER) 241 if passwd not in ('', IGNORE_MARKER): 242 IUserAccount(obj).setPassword(passwd) 239 if row.has_key('password'): 240 passwd = row.get('password', IGNORE_MARKER) 241 if passwd not in ('', IGNORE_MARKER): 242 IUserAccount(obj).setPassword(passwd) 243 items_changed += ('%s=%s, ' % ('password', passwd)) 243 244 row.pop('password') 244 245 245 246 # Update registration state 246 state = row.get('state', IGNORE_MARKER) 247 if state not in (IGNORE_MARKER, ''): 248 value = row['state'] 249 IWorkflowState(obj).setState(value) 250 msg = _("State '${a}' set", mapping = {'a':value}) 251 history = IObjectHistory(obj) 252 history.addMessage(msg) 247 if row.has_key('state'): 248 state = row.get('state', IGNORE_MARKER) 249 if state not in (IGNORE_MARKER, ''): 250 IWorkflowState(obj).setState(state) 251 msg = _("State '${a}' set", mapping = {'a':state}) 252 history = IObjectHistory(obj) 253 history.addMessage(msg) 254 items_changed += ('%s=%s, ' % ('state', state)) 253 255 row.pop('state') 254 256 255 257 # apply other values... 256 items_changed = super(ApplicantProcessor, self).updateEntry(258 items_changed += super(ApplicantProcessor, self).updateEntry( 257 259 obj, row, site) 258 260 259 261 # Log actions... 260 262 parent = self.getParent(row, site) 261 if hasattr(obj,'application_number'):263 if self.getLocator(row) == 'container_code': 262 264 # Update mode: the applicant exists and we can get the applicant_id 263 265 parent.__parent__.logger.info( 264 '%s - Application record updated: %s' 265 % (obj.applicant_id, items_changed)) 266 'Applicant imported: %s' % items_changed) 266 267 else: 267 268 # Create mode: the applicant does not yet exist 268 parent.logger.info('Application record imported: %s' % items_changed) 269 parent.__parent__.logger.info( 270 'Applicant updated: %s' % items_changed) 269 271 return items_changed 270 272 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py
r8332 r8334 245 245 open(self.csv_file_update2, 'wb').write(APPLICANT_SAMPLE_DATA_UPDATE2) 246 246 247 self.logfile = os.path.join( 248 self.app['datacenter'].storage, 'logs', 'applicants.log') 249 247 250 def test_interface(self): 248 251 # Make sure we fulfill the interface contracts. … … 289 292 assert applicant.__implemented__.__name__ == ( 290 293 'waeup.kofa.applicants.applicant.Applicant') 294 logcontent = open(self.logfile).read() 295 # Logging message from updateEntry, 296 # create applicant with given application_number 297 self.assertTrue( 298 'Applicant imported: applicant_id=dp2011_1234, password=mypwd1, ' 299 'reg_number=1001, firstname=Aaren, middlename=Peter, lastname=Pieri, ' 300 'sex=m, course1=CERT1, date_of_birth=1990-01-02, email=xx@yy.zz' in 301 logcontent) 302 # create applicant with random application_number which is 303 # not shown in the log file 304 self.assertTrue( 305 'Applicant imported: reg_number=1003, firstname=Aaren, ' 306 'middlename=Alfons, lastname=Berson, sex=m, course1=CERT1, ' 307 'date_of_birth=1990-01-04, email=xx@yy.zz' in 308 logcontent) 291 309 shutil.rmtree(os.path.dirname(fin_file)) 292 310 … … 327 345 self.assertTrue(IUserAccount(container['1234']).checkPassword('mypwd1')) 328 346 # password of Finau is still unset 329 self.assertEqual(IUserAccount(container['2345']).password, '')347 self.assertEqual(IUserAccount(container['2345']).password,None) 330 348 # reg_number of Finau has changed 331 349 self.assertEqual(container['2345'].reg_number, '6666') 350 logcontent = open(self.logfile).read() 351 352 # Logging message from updateEntry, 353 # reg_number is locator 354 self.assertTrue( 355 'Applicant updated: reg_number=1001, firstname=Aaren' in 356 logcontent) 357 # applicant_id is locator 358 self.assertTrue( 359 'Applicant updated: state=admitted, reg_number=6666, ' 360 'firstname=Alfons, applicant_id=dp2011_2345' in 361 logcontent) 362 332 363 shutil.rmtree(os.path.dirname(fin_file)) 333 364 … … 350 381 self.csv_file_update, APPLICANT_HEADER_FIELDS_UPDATE, 'remove') 351 382 self.assertEqual(num_warns,0) 352 shutil.rmtree(os.path.dirname(fin_file)) 383 logcontent = open(self.logfile).read() 384 385 # Logging message from handle_applicant_transition_event 386 self.assertTrue( 387 'dp2011_1234 - Applicant record removed' in 388 logcontent) 389 390 shutil.rmtree(os.path.dirname(fin_file)) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/workflow.py
r8312 r8334 170 170 history.addMessage(msg) 171 171 # In some tests we don't have a an applicants root or a user 172 try: 173 applicants_root = grok.getSite()['applicants'] 174 applicants_root.logger.info('%s - %s' % (obj.applicant_id,msg)) 175 except (TypeError, AttributeError): 176 pass 172 if event.transition.transition_id != 'init': 173 try: 174 applicants_root = grok.getSite()['applicants'] 175 applicants_root.logger.info('%s - %s' % (obj.applicant_id,msg)) 176 except (TypeError, AttributeError): 177 pass 177 178 return -
main/waeup.kofa/trunk/src/waeup/kofa/utils/converters.py
r8217 r8334 302 302 obj = context 303 303 if isinstance(context, basestring): 304 # If we log initialization transitions this 305 # will create another (misleading) log entry 304 306 obj = createObject(context) 305 307
Note: See TracChangeset for help on using the changeset viewer.