forgot to add cookies.py

This commit is contained in:
Izalia Mae 2022-07-30 15:28:13 -04:00
parent 8c18736e22
commit 5baadc9258

28
barkshark_web/cookies.py Normal file
View file

@ -0,0 +1,28 @@
from izzylib_sql import Database, Session
row_classes = {}
def register_row(table):
def wrapper(cls):
row_classes[table] = cls
return cls
class CookieSession(Session):
def get_domain(self, domain):
return self.execute(f"SELECT * FROM moz_cookies WHERE host LIKE '%{domain}' or host = '.{domain}'")
def get_host(self, host):
#return self.execute(f"SELECT * FROM moz_cookies WHERE host LIKE '%{host}' or host = '{host}'")
return self.execute(f"SELECT * FROM moz_cookies WHERE host == '{host}' or host == '.{host}'")
def get_cookie_db(app):
return Database(
database = app.path.cookies,
session_class = CookieSession,
row_classes = row_classes
)