Thinking better of making the manager methods properties.

This commit is contained in:
Luke Sneeringer
2014-09-30 10:44:13 -05:00
parent a9260db790
commit 1c11f43ea2

View File

@@ -12,16 +12,14 @@ class InstanceManager(models.Manager):
Provides "table-level" methods including getting the currently active
instance or role.
"""
@cached_property
def me(self):
"""Return the currently active instance."""
return self.get(uuid=settings.SYSTEM_UUID)
@cached_property
def my_role(self):
"""Return the role of the currently active instance, as a string
('primary' or 'secondary').
"""
if self.me.primary:
if self.me().primary:
return 'primary'
return 'secondary'