Skip to content

Commit bd3a1af

Browse files
author
Kareem Zidane
committed
removed CustomImporter
1 parent 49b5e36 commit bd3a1af

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/cs50/__init__.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
import os
22
import sys
33

4-
5-
class CustomImporter(object):
6-
"""
7-
Import cs50.SQL lazily for performance (and so that rest of library can be used without SQLAlchemy installed).
8-
https://docs.python.org/3/library/imp.html
9-
http://xion.org.pl/2012/05/06/hacking-python-imports/
10-
http://dangerontheranger.blogspot.com/2012/07/how-to-use-sysmetapath-with-python.html
11-
"""
12-
13-
def find_module(self, fullname, path=None):
14-
if fullname == "cs50.SQL":
15-
return self
16-
return None
17-
18-
def load_module(self, name):
19-
if name in sys.modules:
20-
return sys.modules[name]
21-
from .sql import SQL
22-
sys.modules[name] = SQL
23-
return SQL
24-
25-
264
try:
275

286
# Save student's sys.path
@@ -41,8 +19,8 @@ def load_module(self, name):
4119
# Replace Flask's logger
4220
from . import flask
4321

44-
# Lazily load CS50.SQL
45-
sys.meta_path.append(CustomImporter())
22+
# Wrap SQLAlchemy
23+
from .sql import SQL
4624

4725
finally:
4826

0 commit comments

Comments
 (0)