Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed monkeypatches from models.py, made patch() be idempotent, r=k…

…umar
  • Loading branch information...
commit 5c866af03a0fffd36e22fd29863b49fec70fa1a1 1 parent 1ff3396
@peterbe authored
View
3  funfactory/models.py
@@ -1,4 +1 @@
-# This is here to trick Django
-from funfactory import monkeypatches
-monkeypatches.patch()
View
14 funfactory/monkeypatches.py
@@ -2,7 +2,18 @@
from django.conf import settings
+__all__ = ['patch']
+
+
+# Idempotence! http://en.wikipedia.org/wiki/Idempotence
+_has_patched = False
+
+
def patch():
+ global _has_patched
+ if _has_patched:
+ return
+
# Import for side-effect: configures logging handlers.
# pylint: disable-msg=W0611
import log_settings
@@ -21,3 +32,6 @@ def patch():
admin.monkeypatch()
logging.debug("Note: funfactory monkey patches executed in %s" % __file__)
+
+ # prevent it from being run again later
+ _has_patched = True
View
5 tests/__init__.py
@@ -97,3 +97,8 @@ def begin(self):
os.chdir(wd)
# Puts path back to this dev version of funfactory:
sys.path.insert(0, ROOT)
+
+ # simulate what django does, which is to import the root urls.py
+ # once everything has been set up (e.g. setup_environ())
+ from funfactory.monkeypatches import patch
+ patch()
Please sign in to comment.
Something went wrong with that request. Please try again.