## ## batching.py ## Login : ## Started on Fri Jul 23 15:42:46 2010 Uli Fouquet ## $Id$ ## ## Copyright (C) 2010 Uli Fouquet ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """Batch processing for applicants. """ import grok from zope.interface import Interface from waeup.sirp.interfaces import IBatchProcessor from waeup.sirp.utils.batching import BatchProcessor from waeup.sirp.jambtables.interfaces import IApplicantPDEImportData class ApplicantImporter(BatchProcessor): """An importer for applicants. """ grok.provides(IBatchProcessor) grok.context(Interface) util_name = 'applcation importer' grok.name(util_name) name = u'Application Importer' iface = IApplicantPDEImportData location_fields = ['reg_no',] factory_name = 'waeup.Applicant' def parentsExist(self, row, site): return 'applications' in site.keys() def entryExists(self, row, site): return row['reg_no'] in site['applications'].keys() def getParent(self, row, site): return site['applications'] def getEntry(self, row, site): if not self.entryExists(row, site): return None parent = self.getParent(row, site) return parent.get(row['reg_no']) def addEntry(self, obj, row, site): parent = self.getParent(row, site) reg_no = row['reg_no'] parent[reg_no] = obj return def delEntry(self, row, site): parent = self.getParent(row, site) del parent[row['reg_no']] return