src/p4l/management/commands/import_record.py
changeset 119 ece69ca3ac24
parent 114 93b45b4f423c
child 126 a345f1a67bf1
equal deleted inserted replaced
118:d33a072d974b 119:ece69ca3ac24
   124         self.batch_size = options.get('batch_size', 50)
   124         self.batch_size = options.get('batch_size', 50)
   125         self.preserve = options.get("preserve", False)
   125         self.preserve = options.get("preserve", False)
   126         self.index = options.get("index", False)
   126         self.index = options.get("index", False)
   127         
   127         
   128         if not self.index:
   128         if not self.index:
   129             old_haystack_signal_processor = getattr(settings, "HAYSTACK_SIGNAL_PROCESSOR", None)
   129             old_realtime_indexing = getattr(settings, "REALTIME_INDEXING", None)
   130             #this is not recommended by the django manual, but in case of management command it seems to work
   130             #this is not recommended by the django manual, but in case of management command it seems to work
   131             if old_haystack_signal_processor:
   131             settings.REALTIME_INDEXING = False 
   132                 settings.HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.BaseSignalProcessor' 
       
   133         
   132         
   134         transaction.enter_transaction_management()
   133         transaction.enter_transaction_management()
   135         transaction.managed(True)
   134         transaction.managed(True)
   136 
   135 
   137         for records_url in args:
   136         for records_url in args:
   141             if errors:
   140             if errors:
   142                 print("%d error(s) when processing %s, check your log file." % (len(errors), records_url))
   141                 print("%d error(s) when processing %s, check your log file." % (len(errors), records_url))
   143 
   142 
   144         transaction.leave_transaction_management()
   143         transaction.leave_transaction_management()
   145         
   144         
   146         if not self.index and old_haystack_signal_processor:
   145         if not self.index and old_realtime_indexing:
   147             settings.HAYSTACK_SIGNAL_PROCESSOR = old_haystack_signal_processor
   146             settings.REALTIME_INDEXING = old_realtime_indexing
   148 
   147