diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/flask_security/forms.py | 6 | ||||
-rw-r--r-- | wqflask/secure_server.py | 19 | ||||
-rw-r--r-- | wqflask/wqflask/model.py | 1 | ||||
-rw-r--r-- | wqflask/wqflask/tracer.py | 41 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 5 |
5 files changed, 55 insertions, 17 deletions
diff --git a/wqflask/flask_security/forms.py b/wqflask/flask_security/forms.py index 4c1dc894..54677e77 100644 --- a/wqflask/flask_security/forms.py +++ b/wqflask/flask_security/forms.py @@ -89,6 +89,10 @@ def valid_user_email(form, field): class Form(BaseForm): def __init__(self, *args, **kwargs): + #print "importing tracer" + #from wqflask import tracer + #tracer.turn_on() + #print "imported tracer" print "in Form, args:", args print "in Form, kwargs:", kwargs if current_app.testing: @@ -154,7 +158,9 @@ class RegisterFormMixin(): return isinstance(member, Field) and \ hasattr(_datastore.user_model, member.name) + print("green:", vars(form)) fields = inspect.getmembers(form, is_field_and_user_attr) + print("fields:" ,vars(form)) return dict((key, value.data) for key, value in fields) diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py index b877c544..697ebfe0 100644 --- a/wqflask/secure_server.py +++ b/wqflask/secure_server.py @@ -1,4 +1,4 @@ -from __future__ import print_function, division, absolute_import +from __future__ import absolute_import, division, print_function from wqflask import app @@ -28,21 +28,6 @@ logging_tree.printout() import sys print("At startup, path is:", sys.path) - -######## -def tracefunc(frame, event, arg, indent=[0]): - if event == "call": - indent[0] += 2 - print("-" * indent[0] + "> call function", frame.f_code.co_name) - elif event == "return": - print("<" + "-" * indent[0], "exit function", frame.f_code.co_name) - indent[0] -= 2 - return tracefunc - -import sys -sys.settrace(tracefunc) -############## - #print("app.config is:", app.config) if __name__ == '__main__': @@ -51,4 +36,4 @@ if __name__ == '__main__': port=app.config['SERVER_PORT'], use_debugger=False, threaded=True, - use_reloader=True) + use_reloader=False) 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(): |