Ignore:
Timestamp:
1 Oct 2012, 21:18:48 (12 years ago)
Author:
Henrik Bettermann
Message:

Add AccessCodeProcessor?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/accesscode.py

    r9263 r9265  
    8181    grok.implements(IAccessCode)
    8282
    83     def __init__(self, batch_serial, random_num):
     83    def __init__(self, batch_serial=None, random_num=None):
    8484        super(AccessCode, self).__init__()
    8585        self.batch_serial = batch_serial
     
    154154
    155155    def __init__(self, creation_date=None, creator=None, batch_prefix=None,
    156                  cost=None, entry_num=None, num=None):
     156                 cost=None, entry_num=0, num=None):
    157157        super(AccessCodeBatch, self).__init__()
    158158        self.creation_date = creation_date
     
    317317
    318318    def addBatchByImport(self, batch, batch_id):
    319         """Add an already created `batch` by import
    320         with defined id.
    321         """
     319        """Add an already created `batch` by import with defined id.
     320
     321        We want to create a batch without access codes. Since num_entry
     322        access codes are automatically added by handle_batch_added when
     323        the batch is added to the ZODB, we have to temporarily set entry_num
     324        to zero when adding the batch persistently.
     325        """
     326        orig_entry_num = batch.entry_num
     327        batch.entry_num = 0
    322328        self[batch_id] = batch
     329        self._p_changed = True
     330        batch.entry_num = orig_entry_num
    323331        return
    324332
     
    480488
    481489    def __call__(self, *args, **kw):
    482         return AccessCodeBatch(*args, **kw)
     490        return AccessCodeBatch()
    483491
    484492    def getInterfaces(self):
    485493        return implementedBy(AccessCodeBatch)
     494
     495class AccessCodeFactory(grok.GlobalUtility):
     496    """A factory for accesscodes.
     497
     498    We need this factory for the accesscodeprocessor.
     499    """
     500    grok.implements(IFactory)
     501    grok.name(u'waeup.AccessCode')
     502    title = u"Create a new accesscode.",
     503    description = u"This factory instantiates new accesscode instances."
     504
     505    def __call__(self, *args, **kw):
     506        return AccessCode(*args, **kw)
     507
     508    def getInterfaces(self):
     509        return implementedBy(AccessCode)
    486510
    487511def get_access_code(access_code):
Note: See TracChangeset for help on using the changeset viewer.