## ## batching.py ## Login : ## Started on Fri Jul 23 15:42:46 2010 Uli Fouquet ## $Id$ ## ## Copyright (C) 2010 Uli Fouquet & Henrik Bettermann ## 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.applicants.interfaces import IApplicantsContainer class ApplicantsContainerImporter(BatchProcessor): """An importer for applicants containers. """ grok.implements(IBatchProcessor) grok.provides(IBatchProcessor) grok.context(Interface) util_name = 'applicants container importer' grok.name(util_name) name = u'Applicants Container Importer' mode = u'create' iface = IApplicantsContainer location_fields = ['code',] factory_name = 'waeup.ApplicantsContainer' def parentsExist(self, row, site): return 'applicants' in site.keys() def entryExists(self, row, site): return row['code'] in site['applicants'].keys() def getParent(self, row, site): return site['applicants'] def getEntry(self, row, site): if not self.entryExists(row, site): return None parent = self.getParent(row, site) return parent.get(row['code']) def addEntry(self, obj, row, site): parent = self.getParent(row, site) parent[row['code']] = obj return def delEntry(self, row, site): parent = self.getParent(row, site) del parent[row['code']] return