Changeset 12004 for main


Ignore:
Timestamp:
20 Nov 2014, 04:11:18 (10 years ago)
Author:
Henrik Bettermann
Message:

Replace 'id' by 'document_id'.

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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    355355        raw_header = reader.next()
    356356        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'
    358358                             ] and mode == 'remove':
    359359                continue
     
    378378
    379379    location_fields = []
    380     additional_fields = ['id']
     380    additional_fields = ['document_id']
    381381    additional_headers = []
    382382
    383383    def checkHeaders(self, headerfields, mode='ignore'):
    384384        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!")
    388388        return True
    389389
     
    398398        if documents is None:
    399399            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)
    404404        return entry
    405405
     
    417417    def addEntry(self, obj, row, site):
    418418        parent = self.getParent(row, site)
    419         id = row['id'].strip('#')
    420         parent[id] = obj
     419        document_id = row['document_id'].strip('#')
     420        parent[document_id] = obj
    421421        return
    422422
     
    427427            customer = self._getCustomer(row, site)
    428428            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]
    431431        return
    432432
     
    437437            CustomerDocumentProcessor, self).checkConversion(row, mode=mode)
    438438
    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:
    442442            timestamp = ("%d" % int(time()*10000))[1:]
    443             id = "d%s" % timestamp
    444             conv_dict['id'] = id
     443            document_id = "d%s" % timestamp
     444            conv_dict['document_id'] = document_id
    445445            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'))
    448448        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,title
     1document_id,reg_number,title
    22d1266236341953,1,My first doc
    33d1266236341954,2,My second doc
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py

    r11997 r12004  
    11# -*- coding: utf-8 -*-
    2 ## $Id: test_batching.py 11756 2014-07-09 12:46:08Z henrik $
     2## $Id$
    33##
    44## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    259259        self.customer = self.app['customers'][customer.customer_id]
    260260        document = createObject(u'waeup.CustomerDocument')
    261         document.id = 'd120'
    262         self.customer['documents'][document.id] = document
     261        document.document_id = 'd120'
     262        self.customer['documents'][document.document_id] = document
    263263
    264264        # Import customers with subobjects
     
    282282    def test_getEntry(self):
    283283        assert self.processor.getEntry(
    284             dict(customer_id='ID_NONE', id='nonsense'), self.app) is None
    285         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'),
    287287            self.app) is self.customer['documents']['d120']
    288288
    289289    def test_delEntry(self):
    290290        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'),
    292292            self.app) is self.customer['documents']['d120']
    293293        self.assertEqual(len(self.customer['documents'].keys()),1)
    294294        self.processor.delEntry(
    295             dict(customer_id=self.customer.customer_id, id='d120'),
     295            dict(customer_id=self.customer.customer_id, document_id='d120'),
    296296            self.app)
    297297        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'),
    299299            self.app) is None
    300300        self.assertEqual(len(self.customer['documents'].keys()),0)
     
    303303        self.assertEqual(len(self.customer['documents'].keys()),1)
    304304        document1 = createObject(u'waeup.CustomerDocument')
    305         document1.id = 'p234'
     305        document1.document_id = 'p234'
    306306        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'),
    308308            self.app)
    309309        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')
    311311        document2 = createObject(u'waeup.CustomerDocument')
    312         document1.id = 'nonsense'
     312        document1.document_id = 'nonsense'
    313313
    314314    def test_checkConversion(self):
    315315        errs, inv_errs, conv_dict = self.processor.checkConversion(
    316             dict(id='d1266236341955'))
     316            dict(document_id='d1266236341955'))
    317317        self.assertEqual(len(errs),0)
    318318        errs, inv_errs, conv_dict = self.processor.checkConversion(
    319             dict(id='nonsense'))
     319            dict(document_id='nonsense'))
    320320        self.assertEqual(len(errs),1)
    321321        timestamp = ("%d" % int(time()*10000))[1:]
    322         id = "d%s" % timestamp
    323         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))
    325325        self.assertEqual(len(errs),0)
    326326
     
    330330        self.assertEqual(num_warns,0)
    331331        document = self.processor.getEntry(dict(reg_number='1',
    332             id='d1266236341953'), self.app)
     332            document_id='d1266236341953'), self.app)
    333333        self.assertEqual(
    334334            self.app['customers']['X666666']['documents']['d1266236341953'],
    335335            document)
    336         self.assertEqual(document.id, 'd1266236341953')
     336        self.assertEqual(document.document_id, 'd1266236341953')
    337337        document = self.processor.getEntry(dict(reg_number='3',
    338             id='d1266236341955'), self.app)
     338            document_id='d1266236341955'), self.app)
    339339        shutil.rmtree(os.path.dirname(fin_file))
    340340        logcontent = open(self.logfile).read()
     
    343343            'INFO - system - CustomerDocument Processor - '
    344344            'sample_document_data - X666666 - updated: '
    345             'id=d1266236341953, title=My first doc'
     345            'document_id=d1266236341953, title=My first doc'
    346346            in logcontent)
    347347
     
    355355        num, num_warns, fin_file, fail_file = self.processor.doImport(
    356356            self.csv_file, DOCUMENT_HEADER_FIELDS,'update')
    357         self.assertEqual(num_warns,1)  # There is one record without id
     357        self.assertEqual(num_warns,1)  # There is one record without document_id
    358358        shutil.rmtree(os.path.dirname(fin_file))
    359359
     
    367367        num, num_warns, fin_file, fail_file = self.processor.doImport(
    368368            self.csv_file, DOCUMENT_HEADER_FIELDS,'remove')
    369         self.assertEqual(num_warns,1)  # There is one record without id
     369        self.assertEqual(num_warns,1)  # There is one record without document_id
    370370        shutil.rmtree(os.path.dirname(fin_file))
    371371        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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    5757        container = CustomerDocumentsContainer()
    5858        document = createObject(u'waeup.CustomerDocument')
    59         document.id = 'my_document'
     59        id = document.document_id
    6060        container.addDocument(document)
    61         self.assertEqual(container['my_document'], document)
     61        self.assertEqual(container[id], document)
    6262        self.assertRaises(TypeError, container.addDocument, object())
    6363        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$
    22##
    33## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
     
    2929    grok.context(IDocument)
    3030
    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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    3838            raise TypeError(
    3939                'DocumentsContainers contain only IDocument instances')
    40         self[document.id] = document
     40        self[document.document_id] = document
    4141        return
    4242
  • 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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    5454        super(Document, self).__init__()
    5555        timestamp = ("%d" % int(time()*10000))[1:]
    56         self.id = "d%s" % timestamp
     56        self.document_id = "d%s" % timestamp
    5757        return
    5858
  • 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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    3939
    4040    """
    41     id = Attribute('Document Identifier')
     41    document_id = Attribute('Document Identifier')
    4242    history = Attribute('Object history, a list of messages')
    4343
  • 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$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    5757        container = DocumentsContainer()
    5858        document = createObject(u'waeup.Document')
    59         id = document.id
     59        document_id = document.document_id
    6060        container.addDocument(document)
    61         self.assertEqual(container[id], document)
     61        self.assertEqual(container[document_id], document)
    6262        self.assertRaises(TypeError, container.addDocument, object())
    6363        return
Note: See TracChangeset for help on using the changeset viewer.