From ccaf770ebfcd0b7e2f28b87e79c996b09a45e7e4 Mon Sep 17 00:00:00 2001 From: Tyler Hobbs Date: Tue, 17 Jul 2012 16:23:47 -0700 Subject: [PATCH] Allow arbitrary ksdef attributes to be set --- pycassa/system_manager.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pycassa/system_manager.py b/pycassa/system_manager.py index c440d15b..0edc2101 100644 --- a/pycassa/system_manager.py +++ b/pycassa/system_manager.py @@ -150,7 +150,7 @@ def _system_update_keyspace(self, ksdef): def create_keyspace(self, name, replication_strategy=SIMPLE_STRATEGY, - strategy_options=None, durable_writes=True): + strategy_options=None, durable_writes=True, **ks_kwargs): """ Creates a new keyspace. Column families may be added to this keyspace @@ -186,14 +186,19 @@ def create_keyspace(self, name, strategy_class = 'org.apache.cassandra.locator.%s' % replication_strategy else: strategy_class = replication_strategy + ksdef = KsDef(name, strategy_class=strategy_class, strategy_options=strategy_options, cf_defs=[], durable_writes=durable_writes) + + for k, v in ks_kwargs.iteritems(): + setattr(ksdef, k, v) + self._system_add_keyspace(ksdef) def alter_keyspace(self, keyspace, replication_strategy=None, - strategy_options=None, durable_writes=None): + strategy_options=None, durable_writes=None, **ks_kwargs): """ Alters an existing keyspace. @@ -222,6 +227,9 @@ def alter_keyspace(self, keyspace, replication_strategy=None, if durable_writes is not None: ksdef.durable_writes = durable_writes + for k, v in ks_kwargs.iteritems(): + setattr(ksdef, k, v) + self._system_update_keyspace(ksdef) def drop_keyspace(self, keyspace):