mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 07:16:31 +01:00
15 lines
No EOL
637 B
Python
Executable file
15 lines
No EOL
637 B
Python
Executable file
from django.db.models.manager import Manager
|
|
|
|
class SharedMemoryManager(Manager):
|
|
# TODO: improve on this implementation
|
|
# We need a way to handle reverse lookups so that this model can
|
|
# still use the singleton cache, but the active model isn't required
|
|
# to be a SharedMemoryModel.
|
|
def get(self, **kwargs):
|
|
items = kwargs.keys()
|
|
inst = None
|
|
if len(items) == 1 and items[0] in ('pk', self.model._meta.pk.attname):
|
|
inst = self.model.get_cached_instance(kwargs[items[0]])
|
|
if inst is None:
|
|
inst = super(SharedMemoryManager, self).get(**kwargs)
|
|
return inst |