mirror of
https://github.com/nikdoof/django-evesde.git
synced 2025-12-23 06:39:21 +00:00
Add API caching, move calls out into its own modules for reuse.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from locations import Location, Region, Constellation, System, SystemJump, Planet, Moon, Station
|
||||
from objects import InSpaceObject
|
||||
from types import TypeCategory, TypeGroup, Type, UnitType, AttributeType, TypeAttribute
|
||||
from types import TypeCategory, TypeGroup, Type, UnitType, AttributeType, TypeAttribute
|
||||
from cache import EVEAPICache
|
||||
14
evesde/models/cache.py
Normal file
14
evesde/models/cache.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class EVEAPICache(models.Model):
|
||||
|
||||
key = models.CharField('Cache Key', blank=False, max_length=40)
|
||||
cache_until = models.DateTimeField('Cached Until', blank=False)
|
||||
document = models.TextField('Document')
|
||||
|
||||
class Meta:
|
||||
app_label = 'evesde'
|
||||
|
||||
def __unicode__(self):
|
||||
return '%(key)s - %(cache_until)s' % self.__dict__
|
||||
@@ -6,8 +6,8 @@ class InheritanceQuerySet(QuerySet):
|
||||
def select_subclasses(self, *subclasses):
|
||||
if not subclasses:
|
||||
subclasses = [o for o in dir(self.model)
|
||||
if isinstance(getattr(self.model, o), SingleRelatedObjectDescriptor)\
|
||||
and issubclass(getattr(self.model,o).related.model, self.model)]
|
||||
if isinstance(getattr(self.model, o), SingleRelatedObjectDescriptor)
|
||||
and issubclass(getattr(self.model, o).related.model, self.model)]
|
||||
new_qs = self.select_related(*subclasses)
|
||||
new_qs.subclasses = subclasses
|
||||
return new_qs
|
||||
|
||||
Reference in New Issue
Block a user