Skip to content

Commit

Permalink
Allow arbitrary ksdef attributes to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
thobbs committed Jul 17, 2012
1 parent a5b317c commit ccaf770
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pycassa/system_manager.py
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ccaf770

Please sign in to comment.