def handle_app_config(self, app_config, **options): m_name = options.get('model_name') if not m_name: self.stderr.write("Model name missing.") else: m = app_config.get_model(m_name) # TODO: Add check to see if current mapping differs from mapping on node. self.stderr.write(WRNING_MSG) a = raw_input() if a == 'y': self.stdout.write("Destroying '{}' index.".format( m.get_index_name())) try: delete_index(m.get_index_name()) self.stdout.write("Done.") self.stdout.write("Re-creating index.") create_index(app_config, m_name) self.stdout.write("Done.") self.stdout.write("Re-creating documents.") time.sleep(1) # To avoid overloading the node. for obj in m.objects.all(): err = create_document(obj) if not err: self.stdout.write(DOC_CREATED_MSG.format(obj.pk)) else: self.stderr.write(err) except IndexNotFound as e: self.stderr.write(e.__str__()) else: self.stdout.write("Operation cancelled.")
def handle_app_config(self, app_config, **options): m_name = options.get('model_name') if not m_name: self.stderr.write("Model name missing.") else: m = app_config.get_model(m_name) # TODO: Add check to see if current mapping differs from mapping on node. self.stderr.write(WRNING_MSG) a = raw_input() if a == 'y': self.stdout.write("Destroying '{}' index.".format(m.get_index_name())) try: delete_index(m.get_index_name()) self.stdout.write("Done.") self.stdout.write("Re-creating index.") create_index(app_config, m_name) self.stdout.write("Done.") self.stdout.write("Re-creating documents.") time.sleep(1) # To avoid overloading the node. for obj in m.objects.all(): err = create_document(obj) if not err: self.stdout.write(DOC_CREATED_MSG.format(obj.pk)) else: self.stderr.write(err) except IndexNotFound as e: self.stderr.write(e.__str__()) else: self.stdout.write("Operation cancelled.")
def handle_app_config(self, app_config, **options): n_index = options.get('new_index') c_docs = options.get('create_docs') m_name = options.get('model_name') if not m_name: self.stderr.write('No model name specified.') else: if n_index: self.stdout.write('Creating index.') create_index(app_config, m_name) self.stdout.write('Done.') if c_docs: model = app_config.get_model(m_name) for m in model.objects.all(): err = create_document(m) if not err: self.stdout.write('Success creating document {}.'.format( m.pk)) else: self.stderr.write(err)
def handle_app_config(self, app_config, **options): n_index = options.get('new_index') c_docs = options.get('create_docs') m_name = options.get('model_name') if not m_name: self.stderr.write('No model name specified.') else: if n_index: self.stdout.write('Creating index.') create_index(app_config, m_name) self.stdout.write('Done.') if c_docs: model = app_config.get_model(m_name) for m in model.objects.all(): err = create_document(m) if not err: self.stdout.write( 'Success creating document {}.'.format(m.pk)) else: self.stderr.write(err)
def document_handler(sender, **kwargs): if not kwargs.get('created'): update_document(kwargs.get('instance')) else: create_document(kwargs.get('instance'))