aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask
diff options
context:
space:
mode:
authorSam2013-09-04 15:31:22 -0500
committerSam2013-09-04 15:31:22 -0500
commit8d61798c41f9ec77dea3231cbcf0957c7cadc533 (patch)
tree1092463d4e09698fd90931c090f3c61487133e70 /wqflask/wqflask
parentcd4d985e7142f92e18f8cf316c72073cb3609a85 (diff)
downloadgenenetwork2-8d61798c41f9ec77dea3231cbcf0957c7cadc533.tar.gz
Trying to trace through files
Diffstat (limited to 'wqflask/wqflask')
-rw-r--r--wqflask/wqflask/model.py1
-rw-r--r--wqflask/wqflask/tracer.py41
-rw-r--r--wqflask/wqflask/views.py5
3 files changed, 47 insertions, 0 deletions
diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py
index 1f873545..c1b8d060 100644
--- a/wqflask/wqflask/model.py
+++ b/wqflask/wqflask/model.py
@@ -70,6 +70,7 @@ user_datastore = SQLAlchemyUserDatastore(db, User, Role)
class ExtendedRegisterForm(RegisterForm):
name = TextField('name')
+ #print("name is:", name['_name'], vars(name))
organization = TextField('organization')
security = Security(app, user_datastore, register_form=ExtendedRegisterForm)
diff --git a/wqflask/wqflask/tracer.py b/wqflask/wqflask/tracer.py
new file mode 100644
index 00000000..43a0f15e
--- /dev/null
+++ b/wqflask/wqflask/tracer.py
@@ -0,0 +1,41 @@
+from __future__ import absolute_import, division, print_function
+
+print("At top of tracer")
+
+import sys
+
+####################################################################################
+
+# Originally based on http://stackoverflow.com/a/8315566
+def tracefunc(frame, event, arg, indent=[0]):
+
+ func = dict(funcname = frame.f_code.co_name,
+ filename = frame.f_code.co_filename,
+ lineno = frame.f_lineno)
+
+ #These are too common to bother printing...
+ too_common = (
+ '/home/sam/ve27/local/lib/python2.7/site-packages/werkzeug/',
+ '/home/sam/ve27/local/lib/python2.7/site-packages/jinja2/',
+ )
+
+
+ if func['filename'].startswith(too_common):
+ return tracefunc
+
+ info = "{funcname} [{filename}: {lineno}]".format(**func)
+
+ if event == "call":
+ indent[0] += 2
+ #print("-" * indent[0] + "> call function", frame.f_code.co_name)
+ print("-" * indent[0] + "> call function:", info)
+ elif event == "return":
+ print("<" + "-" * indent[0], "exit function:", info)
+ indent[0] -= 2
+ return tracefunc
+
+def turn_on():
+ sys.settrace(tracefunc)
+ print("Tracing turned on!!!!")
+####################################################################################
+
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index d57bbaa7..2b16dd77 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -50,6 +50,11 @@ from wqflask import user_manager
@app.before_request
def connect_db():
g.db = sqlalchemy.create_engine(app.config['DB_URI'])
+
+@app.before_request
+def trace_it():
+ from wqflask import tracer
+ tracer.turn_on()
@app.route("/")
def index_page():