Skip to content

Commit

Permalink
Merge pull request #21 from JBKahn/update-settings-name
Browse files Browse the repository at this point in the history
update settings name
  • Loading branch information
JBKahn committed Dec 15, 2015
2 parents d627fd6 + 44bf31f commit f67e794
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

0.0.6 (Dec 15th 2015)
------------------

### Small fix of legacy settings name

- `DJANGO_FRAGMENTS_SHARD_SETTINGS` to `DJANGO_SHARDING_SETTINGS`.

0.0.5 (Dec 14th 2015)
------------------

Expand Down
2 changes: 1 addition & 1 deletion django_sharding/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ShardingConfig(AppConfig):
name = 'django_sharding'

def ready(self):
shard_settings = getattr(settings, 'DJANGO_FRAGMENTS_SHARD_SETTINGS', {})
shard_settings = getattr(settings, 'DJANGO_SHARDING_SETTINGS', {})
shard_groups = [settings.DATABASES[db_settings]['SHARD_GROUP'] for db_settings in settings.DATABASES]
shard_groups = set(filter(lambda group: group is not None, shard_groups))
self.bucketers = {}
Expand Down
2 changes: 1 addition & 1 deletion django_sharding_library/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def save_shard(self, model_instance):
shard_storage_table = getattr(self, 'django_sharding__shard_storage_table')
shard_group = getattr(self, 'django_sharding__shard_group')

app_config_app_label = getattr(settings, 'DJANGO_FRAGMENTS_SHARD_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
app_config_app_label = getattr(settings, 'DJANGO_SHARDING_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
bucketer = apps.get_app_config(app_config_app_label).get_bucketer(shard_group)
shard = bucketer.pick_shard(model_instance)
shard_object, _ = shard_storage_table.objects.get_or_create(shard_key=shard_key)
Expand Down
2 changes: 1 addition & 1 deletion django_sharding_library/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_shard_for_instance(self, instance):
return instance._state.db or instance.get_shard()

def get_read_db_routing_strategy(self, shard_group):
app_config_app_label = getattr(settings, 'DJANGO_FRAGMENTS_SHARD_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
app_config_app_label = getattr(settings, 'DJANGO_SHARDING_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
return apps.get_app_config(app_config_app_label).get_routing_strategy(shard_group)

def db_for_read(self, model, **hints):
Expand Down
2 changes: 1 addition & 1 deletion django_sharding_library/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def save_shard_handler(sender, instance, **kwargs):
def shard_handler(sender, instance, **kwargs):
save_shard_handler(sender, instance, **kwargs)
"""
app_config_app_label = getattr(settings, 'DJANGO_FRAGMENTS_SHARD_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
app_config_app_label = getattr(settings, 'DJANGO_SHARDING_SETTINGS', {}).get('APP_CONFIG_APP', 'django_sharding')
bucketer = apps.get_app_config(app_config_app_label).get_bucketer(sender.django_sharding__shard_group)
shard_fields = filter(lambda field: getattr(field, 'django_sharding__stores_shard', False), sender._meta.fields)
if not any(shard_fields):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '0.0.5'
version = '0.0.6'


setup(
Expand Down

0 comments on commit f67e794

Please sign in to comment.