Moving the cache instance to the PublicEndpoint class

pull/67/head
Matheus Lima 2019-03-06 17:11:16 -03:00
parent fe8466a309
commit a4ecbae369
5 changed files with 3 additions and 8 deletions

View File

@ -6,7 +6,6 @@ from schematics.types import StringType, UUIDType
from selene.api import PublicEndpoint
from selene.data.device import DeviceRepository
from selene.util.cache import SeleneCache
from selene.util.db import get_db_connection
@ -21,7 +20,6 @@ class AccountDeviceEndpoint(PublicEndpoint):
def __init__(self):
super(AccountDeviceEndpoint, self).__init__()
self.cache: SeleneCache = self.config['SELENE_CACHE']
self.device_pairing_time = 86400
def post(self, account_id):

View File

@ -8,7 +8,6 @@ from schematics.types import StringType
from selene.api import PublicEndpoint
from selene.data.device import DeviceRepository
from selene.util.cache import SeleneCache
from selene.util.db import get_db_connection
@ -27,7 +26,6 @@ class DeviceActivateEndpoint(PublicEndpoint):
def __init__(self):
super(DeviceActivateEndpoint, self).__init__()
self.cache: SeleneCache = self.config.get('SELENE_CACHE')
self.sha512 = hashlib.sha512()
def post(self):

View File

@ -4,7 +4,6 @@ import random
import uuid
from selene.api import PublicEndpoint
from selene.util.cache import SeleneCache
class DeviceCodeEndpoint(PublicEndpoint):
@ -17,7 +16,6 @@ class DeviceCodeEndpoint(PublicEndpoint):
def __init__(self):
super(DeviceCodeEndpoint, self).__init__()
self.device_pairing_time = 86400
self.cache: SeleneCache = self.config.get('SELENE_CACHE')
self.sha512 = hashlib.sha512()
def get(self):

View File

@ -4,7 +4,6 @@ import uuid
from http import HTTPStatus
from selene.api import PublicEndpoint
from selene.util.cache import SeleneCache
class DeviceRefreshTokenEndpoint(PublicEndpoint):
@ -13,7 +12,6 @@ class DeviceRefreshTokenEndpoint(PublicEndpoint):
def __init__(self):
super(DeviceRefreshTokenEndpoint, self).__init__()
self.cache: SeleneCache = self.config['SELENE_CACHE']
self.sha512 = hashlib.sha512()
def get(self):

View File

@ -1,6 +1,8 @@
from flask import current_app, request
from flask.views import MethodView
from ..util.cache import SeleneCache
class PublicEndpoint(MethodView):
"""Abstract class for all endpoints used by Mycroft devices"""
@ -8,3 +10,4 @@ class PublicEndpoint(MethodView):
def __init__(self):
self.config: dict = current_app.config
self.request = request
self.cache: SeleneCache = self.config['SELENE_CACHE']