Ignore:
Timestamp:
20 Nov 2014, 05:40:52 (10 years ago)
Author:
Henrik Bettermann
Message:

Implement document_id generator. Ensure that document_ids remain unique during import.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/documents
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/container.py

    r12004 r12005  
    3030    grok.provides(IDocumentsContainer)
    3131
    32     def __init__(self):
    33         super(DocumentsContainer, self).__init__()
    34         return
    3532
    3633    def addDocument(self, document):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12004 r12005  
    3030from waeup.ikoba.interfaces import IIkobaUtils, IObjectHistory
    3131from waeup.ikoba.interfaces import MessageFactory as _
    32 from waeup.ikoba.documents.interfaces import IDocument, IDocument
    3332from waeup.ikoba.utils.helpers import attrs_to_fields, get_current_principal
    3433from waeup.ikoba.utils.logger import Logger
     34from waeup.ikoba.documents.interfaces import IDocument, IDocument
     35from waeup.ikoba.documents.utils import generate_document_id
    3536
    3637class Document(grok.Container, Logger):
     
    5152        return
    5253
     54    #def __init__(self):
     55    #    super(Document, self).__init__()
     56    #    timestamp = ("%d" % int(time()*10000))[1:]
     57    #    self.document_id = "d%s" % timestamp
     58     #   return
     59
    5360    def __init__(self):
    5461        super(Document, self).__init__()
    55         timestamp = ("%d" % int(time()*10000))[1:]
    56         self.document_id = "d%s" % timestamp
     62        # The site doesn't exist in unit tests
     63        try:
     64            self.document_id = generate_document_id()
     65        except AttributeError:
     66            self.document_id = u'd123'
    5767        return
    5868
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r12004 r12005  
    3535    """
    3636
     37    def addDocument(document):
     38        """Add a document.
     39        """
     40
    3741class IDocument(IIkobaObject):
    3842    """A base representation of documents.
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests.py

    r12004 r12005  
    6161        self.assertEqual(container[document_id], document)
    6262        self.assertRaises(TypeError, container.addDocument, object())
     63        self.assertEqual(document_id, 'd123')
    6364        return
    6465
Note: See TracChangeset for help on using the changeset viewer.