diff roundup/backends/rdbms_common.py @ 4474:9b4cf6c96ee2

Add flags to allow to restrict DB modifications.
author Stefan Seefeld <stefan@seefeld.name>
date Tue, 29 Mar 2011 20:13:53 +0000
parents fccf7e09af0c
children 143f52d48e60
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Mon Mar 21 20:49:56 2011 +0000
+++ b/roundup/backends/rdbms_common.py	Tue Mar 29 20:13:53 2011 +0000
@@ -513,6 +513,9 @@
             # no changes
             return 0
 
+        if not self.config.RDBMS_ALLOW_ALTER:
+            raise DatabaseError(_('ALTER operation disallowed: %r -> %r.'%(old_spec, new_spec)))
+
         logger = logging.getLogger('roundup.hyperdb')
         logger.info('update_class %s'%spec.classname)
 
@@ -737,6 +740,10 @@
     def create_class(self, spec):
         """ Create a database table according to the given spec.
         """
+
+        if not self.config.RDBMS_ALLOW_CREATE:
+            raise DatabaseError(_('CREATE operation disallowed: "%s".'%spec.classname))
+
         cols, mls = self.create_class_table(spec)
         self.create_journal_table(spec)
 
@@ -749,6 +756,10 @@
 
             Drop the journal and multilink tables too.
         """
+
+        if not self.config.RDBMS_ALLOW_DROP:
+            raise DatabaseError(_('DROP operation disallowed: "%s".'%cn))
+
         properties = spec[1]
         # figure the multilinks
         mls = []

Roundup Issue Tracker: http://roundup-tracker.org/