Browse Source

[IMP] only commit where absolutely necessary, mute pylint there

pull/469/head
Holger Brunn 8 years ago
parent
commit
b7308cfb07
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 4
      database_cleanup/models/purge_columns.py
  2. 1
      database_cleanup/models/purge_models.py
  3. 4
      database_cleanup/models/purge_modules.py
  4. 1
      database_cleanup/models/purge_tables.py

4
database_cleanup/models/purge_columns.py

@ -46,7 +46,9 @@ class CleanupPurgeLineColumn(models.TransientModel):
IdentifierAdapter(line.name) IdentifierAdapter(line.name)
)) ))
line.write({'purged': True}) line.write({'purged': True})
self.env.cr.commit()
# we need this commit because the ORM will deadlock if
# we still have a pending transaction
self.env.cr.commit() # pylint: disable=invalid-commit
return True return True

1
database_cleanup/models/purge_models.py

@ -93,7 +93,6 @@ class CleanupPurgeLineModel(models.TransientModel):
self.env['ir.model'].browse([row[0]])\ self.env['ir.model'].browse([row[0]])\
.with_context(**context_flags).unlink() .with_context(**context_flags).unlink()
line.write({'purged': True}) line.write({'purged': True})
self.env.cr.commit()
return True return True

4
database_cleanup/models/purge_modules.py

@ -49,7 +49,9 @@ class CleanupPurgeLineModule(models.TransientModel):
return True return True
self.logger.info('Purging modules %s', ', '.join(module_names)) self.logger.info('Purging modules %s', ', '.join(module_names))
modules.write({'state': 'to remove'}) modules.write({'state': 'to remove'})
self.env.cr.commit()
# we need this commit because reloading the registry would roll back
# our changes
self.env.cr.commit() # pylint: disable=invalid-commit
RegistryManager.new(self.env.cr.dbname, update_module=True) RegistryManager.new(self.env.cr.dbname, update_module=True)
modules.unlink() modules.unlink()
return self.write({'purged': True}) return self.write({'purged': True})

1
database_cleanup/models/purge_tables.py

@ -62,7 +62,6 @@ class CleanupPurgeLineTable(models.TransientModel):
self.env.cr.execute( self.env.cr.execute(
"DROP TABLE %s", (IdentifierAdapter(line.name),)) "DROP TABLE %s", (IdentifierAdapter(line.name),))
line.write({'purged': True}) line.write({'purged': True})
self.env.cr.commit()
return True return True

Loading…
Cancel
Save