import sys needle svarga apps class MyTest object inserted False def f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
needle = 'svarga.apps'
class MyTest(object):
inserted = False
def find_module(self, fullname, path=None):
if fullname in sys.modules:
print "Yes: %s" % fullname
return None
if fullname[:len(needle)] == needle:
return self
return None
def load_module(self, fullname):
print fullname
name = fullname[len(needle)+1:]
if not name:
mod = __import__('svarga')
else:
mod = __import__('django.' + name)
sys.modules[fullname] = mod
return mod
sys.meta_path.append(MyTest())
from svarga.apps.core import mail
print mail
from svarga.apps.core import mail
print sys.modules