Changeset 12004 for main/waeup.ikoba/trunk/src/waeup
- Timestamp:
- 20 Nov 2014, 04:11:18 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
r11997 r12004 1 ## $Id : batching.py 11891 2014-10-28 20:02:45Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 355 355 raw_header = reader.next() 356 356 for num, field in enumerate(headerfields): 357 if field not in ['customer_id', 'reg_number', ' id', 'code', 'level'357 if field not in ['customer_id', 'reg_number', 'document_id', 'code', 'level' 358 358 ] and mode == 'remove': 359 359 continue … … 378 378 379 379 location_fields = [] 380 additional_fields = [' id']380 additional_fields = ['document_id'] 381 381 additional_headers = [] 382 382 383 383 def checkHeaders(self, headerfields, mode='ignore'): 384 384 super(CustomerDocumentProcessor, self).checkHeaders(headerfields) 385 if mode in ('update', 'remove') and not ' id' in headerfields:386 raise FatalCSVError( 387 "Need id for import in update and remove modes!")385 if mode in ('update', 'remove') and not 'document_id' in headerfields: 386 raise FatalCSVError( 387 "Need document_id for import in update and remove modes!") 388 388 return True 389 389 … … 398 398 if documents is None: 399 399 return None 400 id = row.get('id', None)401 if id is None:402 return None 403 entry = documents.get( id)400 document_id = row.get('document_id', None) 401 if document_id is None: 402 return None 403 entry = documents.get(document_id) 404 404 return entry 405 405 … … 417 417 def addEntry(self, obj, row, site): 418 418 parent = self.getParent(row, site) 419 id = row['id'].strip('#')420 parent[ id] = obj419 document_id = row['document_id'].strip('#') 420 parent[document_id] = obj 421 421 return 422 422 … … 427 427 customer = self._getCustomer(row, site) 428 428 customer.__parent__.logger.info('%s - Document removed: %s' 429 % (customer.customer_id, document. id))430 del parent[document. id]429 % (customer.customer_id, document.document_id)) 430 del parent[document.document_id] 431 431 return 432 432 … … 437 437 CustomerDocumentProcessor, self).checkConversion(row, mode=mode) 438 438 439 # We have to check id.440 id = row.get('id', None)441 if not id:439 # We have to check document_id. 440 document_id = row.get('document_id', None) 441 if not document_id: 442 442 timestamp = ("%d" % int(time()*10000))[1:] 443 id = "d%s" % timestamp444 conv_dict[' id'] =id443 document_id = "d%s" % timestamp 444 conv_dict['document_id'] = document_id 445 445 return errs, inv_errs, conv_dict 446 if not id.startswith('d') or len(id) != 14:447 errs.append((' id','invalid format'))446 if not document_id.startswith('d') or len(document_id) != 14: 447 errs.append(('document_id','invalid format')) 448 448 return errs, inv_errs, conv_dict -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/sample_document_data.csv
r11995 r12004 1 id,reg_number,title1 document_id,reg_number,title 2 2 d1266236341953,1,My first doc 3 3 d1266236341954,2,My second doc -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
r11997 r12004 1 1 # -*- coding: utf-8 -*- 2 ## $Id : test_batching.py 11756 2014-07-09 12:46:08Z henrik$2 ## $Id$ 3 3 ## 4 4 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 259 259 self.customer = self.app['customers'][customer.customer_id] 260 260 document = createObject(u'waeup.CustomerDocument') 261 document. id = 'd120'262 self.customer['documents'][document. id] = document261 document.document_id = 'd120' 262 self.customer['documents'][document.document_id] = document 263 263 264 264 # Import customers with subobjects … … 282 282 def test_getEntry(self): 283 283 assert self.processor.getEntry( 284 dict(customer_id='ID_NONE', id='nonsense'), self.app) is None285 assert self.processor.getEntry( 286 dict(customer_id=self.customer.customer_id, id='d120'),284 dict(customer_id='ID_NONE', document_id='nonsense'), self.app) is None 285 assert self.processor.getEntry( 286 dict(customer_id=self.customer.customer_id, document_id='d120'), 287 287 self.app) is self.customer['documents']['d120'] 288 288 289 289 def test_delEntry(self): 290 290 assert self.processor.getEntry( 291 dict(customer_id=self.customer.customer_id, id='d120'),291 dict(customer_id=self.customer.customer_id, document_id='d120'), 292 292 self.app) is self.customer['documents']['d120'] 293 293 self.assertEqual(len(self.customer['documents'].keys()),1) 294 294 self.processor.delEntry( 295 dict(customer_id=self.customer.customer_id, id='d120'),295 dict(customer_id=self.customer.customer_id, document_id='d120'), 296 296 self.app) 297 297 assert self.processor.getEntry( 298 dict(customer_id=self.customer.customer_id, id='d120'),298 dict(customer_id=self.customer.customer_id, document_id='d120'), 299 299 self.app) is None 300 300 self.assertEqual(len(self.customer['documents'].keys()),0) … … 303 303 self.assertEqual(len(self.customer['documents'].keys()),1) 304 304 document1 = createObject(u'waeup.CustomerDocument') 305 document1. id = 'p234'305 document1.document_id = 'p234' 306 306 self.processor.addEntry( 307 document1, dict(customer_id=self.customer.customer_id, id='p234'),307 document1, dict(customer_id=self.customer.customer_id, document_id='p234'), 308 308 self.app) 309 309 self.assertEqual(len(self.customer['documents'].keys()),2) 310 self.assertEqual(self.customer['documents']['p234']. id, 'p234')310 self.assertEqual(self.customer['documents']['p234'].document_id, 'p234') 311 311 document2 = createObject(u'waeup.CustomerDocument') 312 document1. id = 'nonsense'312 document1.document_id = 'nonsense' 313 313 314 314 def test_checkConversion(self): 315 315 errs, inv_errs, conv_dict = self.processor.checkConversion( 316 dict( id='d1266236341955'))316 dict(document_id='d1266236341955')) 317 317 self.assertEqual(len(errs),0) 318 318 errs, inv_errs, conv_dict = self.processor.checkConversion( 319 dict( id='nonsense'))319 dict(document_id='nonsense')) 320 320 self.assertEqual(len(errs),1) 321 321 timestamp = ("%d" % int(time()*10000))[1:] 322 id = "d%s" % timestamp323 errs, inv_errs, conv_dict = self.processor.checkConversion( 324 dict( id=id))322 document_id = "d%s" % timestamp 323 errs, inv_errs, conv_dict = self.processor.checkConversion( 324 dict(document_id=document_id)) 325 325 self.assertEqual(len(errs),0) 326 326 … … 330 330 self.assertEqual(num_warns,0) 331 331 document = self.processor.getEntry(dict(reg_number='1', 332 id='d1266236341953'), self.app)332 document_id='d1266236341953'), self.app) 333 333 self.assertEqual( 334 334 self.app['customers']['X666666']['documents']['d1266236341953'], 335 335 document) 336 self.assertEqual(document. id, 'd1266236341953')336 self.assertEqual(document.document_id, 'd1266236341953') 337 337 document = self.processor.getEntry(dict(reg_number='3', 338 id='d1266236341955'), self.app)338 document_id='d1266236341955'), self.app) 339 339 shutil.rmtree(os.path.dirname(fin_file)) 340 340 logcontent = open(self.logfile).read() … … 343 343 'INFO - system - CustomerDocument Processor - ' 344 344 'sample_document_data - X666666 - updated: ' 345 ' id=d1266236341953, title=My first doc'345 'document_id=d1266236341953, title=My first doc' 346 346 in logcontent) 347 347 … … 355 355 num, num_warns, fin_file, fail_file = self.processor.doImport( 356 356 self.csv_file, DOCUMENT_HEADER_FIELDS,'update') 357 self.assertEqual(num_warns,1) # There is one record without id357 self.assertEqual(num_warns,1) # There is one record without document_id 358 358 shutil.rmtree(os.path.dirname(fin_file)) 359 359 … … 367 367 num, num_warns, fin_file, fail_file = self.processor.doImport( 368 368 self.csv_file, DOCUMENT_HEADER_FIELDS,'remove') 369 self.assertEqual(num_warns,1) # There is one record without id369 self.assertEqual(num_warns,1) # There is one record without document_id 370 370 shutil.rmtree(os.path.dirname(fin_file)) 371 371 logcontent = open(self.logfile).read() -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_document.py
r11997 r12004 1 ## $Id : tests.py 9469 2012-10-30 17:49:17Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 57 57 container = CustomerDocumentsContainer() 58 58 document = createObject(u'waeup.CustomerDocument') 59 document.id = 'my_document'59 id = document.document_id 60 60 container.addDocument(document) 61 self.assertEqual(container[ 'my_document'], document)61 self.assertEqual(container[id], document) 62 62 self.assertRaises(TypeError, container.addDocument, object()) 63 63 return -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/catalog.py
r11997 r12004 1 ## $Id : catalog.py 8700 2012-06-12 21:01:17Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann … … 29 29 grok.context(IDocument) 30 30 31 id = grok.index.Field(attribute='id')31 document_id = grok.index.Field(attribute='document_id') -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/container.py
r11997 r12004 1 ## $Id : container.py 7811 2012-03-08 19:00:51Z uli$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 38 38 raise TypeError( 39 39 'DocumentsContainers contain only IDocument instances') 40 self[document. id] = document40 self[document.document_id] = document 41 41 return 42 42 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py
r11997 r12004 1 ## $Id : document.py 10842 2013-12-11 13:21:37Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 54 54 super(Document, self).__init__() 55 55 timestamp = ("%d" % int(time()*10000))[1:] 56 self. id = "d%s" % timestamp56 self.document_id = "d%s" % timestamp 57 57 return 58 58 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py
r11997 r12004 1 ## $Id : interfaces.py 11450 2014-02-27 06:25:18Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 39 39 40 40 """ 41 id = Attribute('Document Identifier')41 document_id = Attribute('Document Identifier') 42 42 history = Attribute('Object history, a list of messages') 43 43 -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests.py
r11997 r12004 1 ## $Id : tests.py 9469 2012-10-30 17:49:17Z henrik$1 ## $Id$ 2 2 ## 3 3 ## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann … … 57 57 container = DocumentsContainer() 58 58 document = createObject(u'waeup.Document') 59 id = document.id59 document_id = document.document_id 60 60 container.addDocument(document) 61 self.assertEqual(container[ id], document)61 self.assertEqual(container[document_id], document) 62 62 self.assertRaises(TypeError, container.addDocument, object()) 63 63 return
Note: See TracChangeset for help on using the changeset viewer.