Changed how lazy-loading of handlers work, using a werkzeug recipe. Much more efficient now.
This commit is contained in:
parent
680e603c4d
commit
e6950aadf2
10 changed files with 125 additions and 144 deletions
|
|
@ -14,7 +14,7 @@ from src.utils.idmapper.models import SharedMemoryModel
|
|||
from src.help.manager import HelpEntryManager
|
||||
from src.typeclasses.models import Tag, TagHandler
|
||||
from src.locks.lockhandler import LockHandler
|
||||
from src.utils.utils import LazyLoadHandler
|
||||
from src.utils.utils import lazy_property
|
||||
__all__ = ("HelpEntry",)
|
||||
|
||||
|
||||
|
|
@ -66,10 +66,16 @@ class HelpEntry(SharedMemoryModel):
|
|||
objects = HelpEntryManager()
|
||||
_is_deleted = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
SharedMemoryModel.__init__(self, *args, **kwargs)
|
||||
self.locks = LazyLoadHandler(self, "locks", LockHandler)
|
||||
self.tags = LazyLoadHandler(self, "tags", TagHandler)
|
||||
# lazy-loaded handlers
|
||||
|
||||
@lazy_property
|
||||
def locks(self):
|
||||
return LockHandler(self)
|
||||
|
||||
@lazy_property
|
||||
def tags(self):
|
||||
return TagHandler(self)
|
||||
|
||||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue