Ignore:
Timestamp:
3 Jun 2012, 13:57:01 (12 years ago)
Author:
uli
Message:

Reduce number of site lookups during imports.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/batching.py

    r8615 r8617  
    304304        cert = conv_dict.get('course1', None)
    305305        if cert is not None and (mode in ('create', 'update')):
    306             # course1 application category must match container's.  We
    307             # could move that check into addApplicant, as it is
    308             # expensive.
    309             #
    310             # XXX: getSite() should be avoided here.
    311             parent = self.getParent(row, grok.getSite())
     306            # course1 application category must match container's.
     307            parent = self.getParent(row, self.site)
    312308            if cert.application_category != parent.application_category:
    313309                errs.append(('course1', 'wrong application category'))
     
    336332            return 'Applicant is blocked.'
    337333        return None
     334
     335    def doImport(self, *args, **kw):
     336        # XXX: Not thread-safe.  Parallel applicant imports into
     337        # different sites could mean a mess.  Luckily this is not a
     338        # typical use-case. On the other hand it spares thousands of
     339        # site lookups during large imports.
     340        # XXX: Maybe this should go into Importer base.
     341        self.site = grok.getSite() # needed by checkConversion()
     342        return super(ApplicantProcessor, self).doImport(*args, **kw)
Note: See TracChangeset for help on using the changeset viewer.