Skip to content

Commit

Permalink
The registires did not use separate registration lists. This update f…
Browse files Browse the repository at this point in the history
…ixes that
  • Loading branch information
Tim Schneider committed Jan 27, 2016
1 parent 4d85e1b commit c7e988b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ The objects can be retrieved like so:
The included tests can be run standalone by running the `tests/runtests.py` script. You need to have Django and
mock installed for them to run. If you also want to run coverage, you need to install it before running the tests

###v.0.0.2
- Bugfix: Using a metaclass to separate the lists for each subclass of `MultiListPartRegistry`. Before each registry
used the same list resulting in element mixtures if more than one registry was used

###v.0.0.1a
- Rename `Type` to `List` in classes

Expand Down
8 changes: 6 additions & 2 deletions django_appregistration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.encoding import force_text
from six import with_metaclass

__author__ = 'Tim Schneider <tim.schneider@northbridge-development.de>'
__copyright__ = "Copyright 2016, Northbridge Development Konrad & Schneider GbR"
Expand All @@ -12,9 +13,12 @@
__email__ = "mail@northbridge-development.de"
__status__ = "Development"

class RegistryMetaClass(type):
def __init__(self, *args, **kwargs):
super(RegistryMetaClass, self).__init__(*args, **kwargs)
self.lists = {}

class MultiListPartRegistry(object):
lists = {}
class MultiListPartRegistry(with_metaclass(RegistryMetaClass, object)):
loaded = False
lock = threading.Lock()
part_class = None
Expand Down
17 changes: 17 additions & 0 deletions django_appregistration/tests/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,21 @@ def test_get(self, get):
get.assert_called_once_with('')


class MultipleReistriesDividedSettingsTestCase(TestCase):
def test_multiple_registries(self):
class Registry1(SingleListPartRegistry):
part_class = object
call_function_subpath = 'non_existent_subpath'

class Registry2(SingleListPartRegistry):
part_class = object
call_function_subpath = 'non_existent_subpath'

id_obj1 = object()
id_obj2 = object()

Registry1.add_part(id_obj1)
Registry2.add_part(id_obj2)

self.assertEqual(len(Registry1.get()), 1)
self.assertEqual(len(Registry2.get()), 1)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

setup(
name='django-appregistration',
version='0.0.1a',
version='0.0.2',
packages=find_packages(exclude=['*.tests',]),
include_package_data=True,
install_requires=['Django >=1.6',],
Expand Down

0 comments on commit c7e988b

Please sign in to comment.