aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Sloan2013-03-22 22:40:57 +0000
committerZachary Sloan2013-03-22 22:40:57 +0000
commitb0cb34e8e4ddf09b0cfe3081439610c6f6d0341c (patch)
treede4f2cff8caf7f034dd631e731fbc1a44f8b3bae
parentcd58c17faec400968cfe6a3595ebe02099edd691 (diff)
downloadgenenetwork2-b0cb34e8e4ddf09b0cfe3081439610c6f6d0341c.tar.gz
Added secure_server.py
Updated notes.txt
-rw-r--r--misc/notes.txt7
-rw-r--r--wqflask/secure_server.py76
-rw-r--r--wqflask/wqflask/do_search.py14
3 files changed, 85 insertions, 12 deletions
diff --git a/misc/notes.txt b/misc/notes.txt
index cdd353ea..e40dad8f 100644
--- a/misc/notes.txt
+++ b/misc/notes.txt
@@ -219,3 +219,10 @@ grep -ir (search string) (directory)
-i ignores case
-r searches recursively through subdirectories of directory you specify
+
+===========================================
+
+MySQL Things -
+
+Create fulltext (MATCH AGAINST syntax) index:
+CREATE FULLTEXT INDEX __________ ON Table (Column);
diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py
new file mode 100644
index 00000000..49e0b433
--- /dev/null
+++ b/wqflask/secure_server.py
@@ -0,0 +1,76 @@
+from __future__ import print_function, division, absolute_import
+
+from wqflask import app
+
+from flask import Flask, render_template
+from flask.ext.sqlalchemy import SQLAlchemy
+from flask.ext.security import Security, SQLAlchemyUserDatastore, \
+ UserMixin, RoleMixin
+
+# Create app
+#app = Flask(__name__)
+app.config['SECRET_KEY'] = 'LjfrbDOlvdFMT5cCi9qrJqStxK4NcmxW'
+app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://webqtl:f2ZypIflRM@gn.cazhbciu2y1i.us-east-1.rds.amazonaws.com/db_webqtl'
+#app.config['SECURITY_CONFIRMABLE'] = True
+app.config['SECURITY_TRACKABLE'] = True
+
+# Create database connection object
+db = SQLAlchemy(app)
+
+# Define models
+roles_users = db.Table('roles_users',
+ db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
+ db.Column('role_id', db.Integer(), db.ForeignKey('role.id')))
+
+class Role(db.Model, RoleMixin):
+ id = db.Column(db.Integer(), primary_key=True)
+ name = db.Column(db.String(80), unique=True)
+ description = db.Column(db.String(255))
+
+class User(db.Model, UserMixin):
+ id = db.Column(db.Integer(), primary_key=True)
+ email = db.Column(db.String(255), unique=True)
+ password = db.Column(db.String(255))
+ active = db.Column(db.Boolean())
+ confirmed_at = db.Column(db.DateTime())
+
+ last_login_at = db.Column(db.DateTime())
+ current_login_at = db.Column(db.DateTime())
+ last_login_ip_= db.Column(db.String(39))
+ current_login_ip = db.Column(db.String(39))
+ login_count = db.Column(db.Integer())
+
+ roles = db.relationship('Role', secondary=roles_users,
+ backref=db.backref('users', lazy='dynamic'))
+
+# Setup Flask-Security
+user_datastore = SQLAlchemyUserDatastore(db, User, Role)
+security = Security(app, user_datastore)
+
+# Create a user to test with
+#@app.before_first_request
+def create_user():
+ db.create_all()
+ user_datastore.create_user(email='matt@example.com', password='notebook')
+ db.session.commit()
+
+## Views
+#@app.route('/')
+#def home():
+# return render_template('index.html')
+
+import logging
+#from themodule import TheHandlerYouWant
+file_handler = logging.FileHandler("/tmp/flask_gn_log")
+file_handler.setLevel(logging.DEBUG)
+app.logger.addHandler(file_handler)
+
+import logging_tree
+logging_tree.printout()
+
+if __name__ == '__main__':
+ #create_user()
+ app.run(host='0.0.0.0',
+ use_debugger=False,
+ threaded=True,
+ use_reloader=True)
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index b390bdc4..2e74d991 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -70,12 +70,7 @@ class QuickMrnaAssaySearch(DoSearch):
ProbeSet.Mb as ProbeSet_Mb,
ProbeSet.Symbol as ProbeSet_Symbol,
ProbeSet.name_num as ProbeSet_name_num
- FROM ProbeSet,
- ProbeSetXRef,
- ProbeSetFreeze,
- ProbeFreeze,
- InbredSet,
- Species """
+ FROM ProbeSet """
header_fields = ['',
'Record ID',
@@ -89,12 +84,7 @@ class QuickMrnaAssaySearch(DoSearch):
query = self.base_query + """WHERE (MATCH (ProbeSet.Name,
ProbeSet.description,
ProbeSet.symbol)
- AGAINST ('%s' IN BOOLEAN MODE)) and
- ProbeSet.Id = ProbeSetXRef.ProbeSetId and
- ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id and
- ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and
- ProbeFreeze.InbredSetId = InbredSet.Id and
- InbredSet.SpeciesId = Species.Id
+ AGAINST ('%s' IN BOOLEAN MODE))
""" % (escape(self.search_term[0]))
print("final query is:", pf(query))