source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/jambtables/batching.py @ 11031

Last change on this file since 11031 was 5321, checked in by uli, 14 years ago

Enable batches for application data.

File size: 2.2 KB
Line 
1##
2## batching.py
3## Login : <uli@pu.smp.net>
4## Started on  Fri Jul 23 15:42:46 2010 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2010 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22"""Batch processing for applicants.
23"""
24import grok
25from zope.interface import Interface
26from waeup.sirp.interfaces import IBatchProcessor
27from waeup.sirp.utils.batching import BatchProcessor
28from waeup.sirp.jambtables.interfaces import IApplicantPDEImportData
29
30class ApplicantImporter(BatchProcessor):
31    """An importer for applicants.
32    """
33    grok.provides(IBatchProcessor)
34    grok.context(Interface)
35    util_name = 'applcation importer'
36    grok.name(util_name)
37
38    name = u'Application Importer'
39    iface = IApplicantPDEImportData
40
41    location_fields = ['reg_no',]
42    factory_name = 'waeup.Applicant'
43
44    def parentsExist(self, row, site):
45        return 'applications' in site.keys()
46
47    def entryExists(self, row, site):
48        return row['reg_no'] in site['applications'].keys()
49
50    def getParent(self, row, site):
51        return site['applications']
52
53    def getEntry(self, row, site):
54        if not self.entryExists(row, site):
55            return None
56        parent = self.getParent(row, site)
57        return parent.get(row['reg_no'])
58
59    def addEntry(self, obj, row, site):
60        parent = self.getParent(row, site)
61        reg_no = row['reg_no']
62        parent[reg_no] = obj
63        return
64
65    def delEntry(self, row, site):
66        parent = self.getParent(row, site)
67        del parent[row['reg_no']]
68        return
Note: See TracBrowser for help on using the repository browser.