add some debugging and safety measures
This commit is contained in:
parent
82568ec1b7
commit
c024b8b3a0
|
@ -3,6 +3,7 @@
|
|||
import cPickle
|
||||
import os
|
||||
import datetime
|
||||
import time
|
||||
import cStringIO
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
@ -522,6 +523,7 @@ class UpdateToBlobs(BrowserView):
|
|||
class SplitDocNumbers(BrowserView):
|
||||
def __call__(self):
|
||||
catalog = getToolByName(self.context, 'portal_catalog')
|
||||
fd = file('/tmp/archive-numeros.%d' % int(time.time()%10000000), 'w')
|
||||
for count, brain in enumerate(catalog.search({'portal_type': ['bqrD', 'biqD',
|
||||
'cr_seanceD', 'ProjetD', 'proposition_decret_reglementD',
|
||||
'proposition_resolution_modificationD', 'PropositionD',
|
||||
|
@ -541,6 +543,7 @@ class SplitDocNumbers(BrowserView):
|
|||
try:
|
||||
new_number = re.findall(r'(\d+) \(', attr_value)[0]
|
||||
except IndexError:
|
||||
print 'object:', object.id
|
||||
print 'failed to get doc number for', attr_value
|
||||
continue
|
||||
no_suite = None
|
||||
|
@ -548,8 +551,10 @@ class SplitDocNumbers(BrowserView):
|
|||
try:
|
||||
no_suite = re.findall(r'°\s*(\d+)', attr_value)[0]
|
||||
except IndexError:
|
||||
print 'object:', object.id
|
||||
print 'failed to get suite number for', attr_value
|
||||
continue
|
||||
print >> fd, object.id, attr_value
|
||||
setattr(object, attr, new_number)
|
||||
if no_suite:
|
||||
object.numero_suite = no_suite
|
||||
|
@ -557,3 +562,4 @@ class SplitDocNumbers(BrowserView):
|
|||
notify(ObjectModifiedEvent(object))
|
||||
if count%100 == 0:
|
||||
transaction.commit()
|
||||
fd.close()
|
||||
|
|
Reference in New Issue