def process(request): print 'Processing transactions ...' LOG = Datalog('process.log') docs = Pangadokument.objects.all().order_by('import_aeg') for doc in docs: LOG.info('Pangadokument: '+doc.failinimi) rows = Pangakirje.objects.all().filter(allikas=doc, arvestatud='N').order_by('kuupaev', 'reatyyp', 'arhiveerimistunnus') for row in rows: LOG.info('Rida: '+row.selgitus) rules = Tehingutyyp.objects.all() created = 0 for rule in rules: if row.reatyyp == rule.reatyyp and row.tunnus == rule.tunnus and re.search(rule.triger, row.selgitus) and row.arvestatud != 'J': LOG.info('Triger: '+ rule.triger ) items = Kontokasutus.objects.all().filter(tehingutyyp=rule).order_by('on_deebet') deals = Deals(LOG) created = deals.create(row, items, rule) if created == 0: LOG.warning(' > Kandeid ei tehtud') context = {'LOG': LOG.log} LOG.end() result = render_to_response('showlog.html', context, context_instance=RequestContext(request)) return result