diff --git a/alembic.ini b/alembic.ini
new file mode 100644
index 0000000..f15b1d7
--- /dev/null
+++ b/alembic.ini
@@ -0,0 +1,49 @@
+# A generic, single database configuration.
+
+[alembic]
+# path to migration scripts
+script_location = alembic
+
+# template used to generate migration files
+# file_template = %%(rev)s_%%(slug)s
+
+# set to 'true' to run the environment during
+# the 'revision' command, regardless of autogenerate
+# revision_environment = false
+
+sqlalchemy.url = postgresql://mercy:mercy@postgresql.aklabs.net/mercy
+
+# Logging configuration
+[loggers]
+keys = root,sqlalchemy,alembic
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+qualname =
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+
+[logger_alembic]
+level = INFO
+handlers =
+qualname = alembic
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S
diff --git a/alembic/README b/alembic/README
new file mode 100644
index 0000000..98e4f9c
--- /dev/null
+++ b/alembic/README
@@ -0,0 +1 @@
+Generic single-database configuration.
\ No newline at end of file
diff --git a/alembic/env.py b/alembic/env.py
new file mode 100644
index 0000000..f72400b
--- /dev/null
+++ b/alembic/env.py
@@ -0,0 +1,71 @@
+from __future__ import with_statement
+from alembic import context
+from sqlalchemy import engine_from_config, pool
+from logging.config import fileConfig
+
+# this is the Alembic Config object, which provides
+# access to the values within the .ini file in use.
+config = context.config
+
+# Interpret the config file for Python logging.
+# This line sets up loggers basically.
+fileConfig(config.config_file_name)
+
+# add your model's MetaData object here
+# for 'autogenerate' support
+# from myapp import mymodel
+# target_metadata = mymodel.Base.metadata
+target_metadata = None
+
+# other values from the config, defined by the needs of env.py,
+# can be acquired:
+# my_important_option = config.get_main_option("my_important_option")
+# ... etc.
+
+def run_migrations_offline():
+ """Run migrations in 'offline' mode.
+
+ This configures the context with just a URL
+ and not an Engine, though an Engine is acceptable
+ here as well. By skipping the Engine creation
+ we don't even need a DBAPI to be available.
+
+ Calls to context.execute() here emit the given string to the
+ script output.
+
+ """
+ url = config.get_main_option("sqlalchemy.url")
+ context.configure(url=url)
+
+ with context.begin_transaction():
+ context.run_migrations()
+
+def run_migrations_online():
+ """Run migrations in 'online' mode.
+
+ In this scenario we need to create an Engine
+ and associate a connection with the context.
+
+ """
+ engine = engine_from_config(
+ config.get_section(config.config_ini_section),
+ prefix='sqlalchemy.',
+ poolclass=pool.NullPool)
+
+ connection = engine.connect()
+ context.configure(
+ connection=connection,
+ target_metadata=target_metadata
+ )
+
+ try:
+ with context.begin_transaction():
+ context.run_migrations()
+ finally:
+ connection.close()
+
+if context.is_offline_mode():
+ run_migrations_offline()
+else:
+ run_migrations_online()
+
diff --git a/alembic/env.pyc b/alembic/env.pyc
new file mode 100644
index 0000000..5068e06
Binary files /dev/null and b/alembic/env.pyc differ
diff --git a/alembic/script.py.mako b/alembic/script.py.mako
new file mode 100644
index 0000000..9570201
--- /dev/null
+++ b/alembic/script.py.mako
@@ -0,0 +1,22 @@
+"""${message}
+
+Revision ID: ${up_revision}
+Revises: ${down_revision}
+Create Date: ${create_date}
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = ${repr(up_revision)}
+down_revision = ${repr(down_revision)}
+
+from alembic import op
+import sqlalchemy as sa
+${imports if imports else ""}
+
+def upgrade():
+ ${upgrades if upgrades else "pass"}
+
+
+def downgrade():
+ ${downgrades if downgrades else "pass"}
diff --git a/alembic/versions/58f6a99bd6ec_create_fda_product_t.py b/alembic/versions/58f6a99bd6ec_create_fda_product_t.py
new file mode 100644
index 0000000..22f88ee
--- /dev/null
+++ b/alembic/versions/58f6a99bd6ec_create_fda_product_t.py
@@ -0,0 +1,91 @@
+"""create fda_product table
+
+Revision ID: 58f6a99bd6ec
+Revises: None
+Create Date: 2013-10-19 21:21:03.977000
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '58f6a99bd6ec'
+down_revision = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ op.create_table(
+ 'fda_products',
+ sa.Column('id', sa.String, primary_key=True),
+ sa.Column('ndc', sa.String, nullable=False),
+ sa.Column('type', sa.String, nullable=False),
+ sa.Column('proprietaryName', sa.String, nullable=False, index=True),
+ sa.Column('proprietaryNameSuffix', sa.String),
+ sa.Column('genericName', sa.String, nullable=False),
+ sa.Column('marketingCategoryName', sa.String, nullable=False),
+ sa.Column('labelerName', sa.String, nullable=False)
+ sa.Column('deaSchedule', sa.String, nullable=False)
+ )
+ op.create_table(
+ 'fda_product_substances',
+ sa.Column('fda_product_id',
+ sa.String,
+ ForeignKey('fda_products.id'),
+ nullable=False),
+ sa.Column('substanceName', sa.String, nullable=False),
+ sa.Column('strengthNumber', sa.String, nullable=False),
+ sa.Column('strengthUnit', sa.String, nullable=False),
+ sa.Column('pharmaClasses', sa.String, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_drugs',
+ sa.Column('id', sa.String, primary_key=True, unique=True),
+ sa.Column('name', sa.String, nullable=False, index=True),
+ sa.Column('indication', sa.String, nullable=False),
+ sa.Column('ndc_id', sa.String, ForeignKey('fda_products.id'), nullable=True),
+ sa.Column('wikipedia', sa.String, nullable=True)
+ )
+ op.create_table(
+ 'drugbank_prices',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('description', sa.String, nullable=False),
+ sa.Column('currency', sa.String, nullable=False),
+ sa.Column('cost', sa.Float, nullable=False, index=True)
+ sa.Column('unit', sa.String, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_categories',
+ sa.Column('id', sa.Integer, primary_key=true, autoincrement=True),
+ sa.Column('name', sa.String, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_drug_categories',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('category_id', sa.Integer, ForeignKey('drugbank_categories.id'), nullable=False)
+ )
+ op.create_table(
+ 'drugbank_packagers',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('name', sa.String, nullable=False),
+ sa.Column('url', sa.String, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_manufacturers',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('name', sa.String, nullable=False),
+ sa.Column('generic', sa.Boolean, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_genericnames',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('name', sa.String, index=True, nullable=False)
+ )
+ op.create_table(
+ 'drugbank_synonyms',
+ sa.Column('id', sa.String, ForeignKey('drugbank_drugs.id'), nullable=False),
+ sa.Column('name', sa.String, index=True, nullable=False)
+ )
+
+def downgrade():
+ pass
diff --git a/alembic/versions/58f6a99bd6ec_create_fda_product_t.py~ b/alembic/versions/58f6a99bd6ec_create_fda_product_t.py~
new file mode 100644
index 0000000..161b8c3
--- /dev/null
+++ b/alembic/versions/58f6a99bd6ec_create_fda_product_t.py~
@@ -0,0 +1,22 @@
+"""create fda_product table
+
+Revision ID: 58f6a99bd6ec
+Revises: None
+Create Date: 2013-10-19 21:21:03.977000
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '58f6a99bd6ec'
+down_revision = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ pass
+
+
+def downgrade():
+ pass
diff --git a/puppet/mercy/manifests/#init.pp# b/puppet/mercy/manifests/#init.pp#
new file mode 100644
index 0000000..28a67ba
--- /dev/null
+++ b/puppet/mercy/manifests/#init.pp#
@@ -0,0 +1,31 @@
+class mercy(
+ $environment,
+ $version,
+ $ensure,
+ $rabbitmq_uri,
+ $process_user => 'mercy',
+ $process_group => 'mercy',
+ $process_threads => 5,
+ $servername => $::fqdn,
+ $rabbitmq_user => 'mercy',
+ $rabbitmq_pw => 'mercy',
+ $rabbitmq_vhost => 'mercy',
+ $vhost_dir => '/etc/apache/httpd/conf.d',
+ $apache_service => 'httpd',
+ $port => 443,
+ $postgres_uri => 'localhost',
+ $postgres_user => 'mercy',
+ $postgres_pw => 'mercy',
+ $postgres_db => 'mercy')
+{
+ if ! defined(User[$process_user]) {
+ user { $process_user:
+ ensure => 'present'
+ }
+ }
+ if ! defined(Group[$process_group]) {
+ user { $process_group:
+ ensure => 'present'
+ }
+ }
+}
diff --git a/puppet/mercy/manifests/init.pp b/puppet/mercy/manifests/init.pp
new file mode 100644
index 0000000..fae1c76
--- /dev/null
+++ b/puppet/mercy/manifests/init.pp
@@ -0,0 +1,22 @@
+class mercy(
+ $environment,
+ $version,
+ $ensure,
+ $rabbitmq_uri,
+ $process_user => 'mercy',
+ $process_group => 'mercy',
+ $process_threads => 5,
+ $servername => $::fqdn,
+ $rabbitmq_user => 'mercy',
+ $rabbitmq_pw => 'mercy',
+ $rabbitmq_vhost => 'mercy',
+ $vhost_dir => '/etc/apache/httpd/conf.d',
+ $apache_service => 'httpd',
+ $port => 443,
+ $postgres_uri => 'localhost',
+ $postgres_user => 'mercy',
+ $postgres_pw => 'mercy',
+ $postgres_db => 'mercy')
+{
+ include 'mercy::params'
+}
diff --git a/puppet/mercy/manifests/params.pp b/puppet/mercy/manifests/params.pp
new file mode 100644
index 0000000..03c6d0e
--- /dev/null
+++ b/puppet/mercy/manifests/params.pp
@@ -0,0 +1,4 @@
+class mercy::params
+{
+
+}
diff --git a/puppet/mercy/manifests/params.pp~ b/puppet/mercy/manifests/params.pp~
new file mode 100644
index 0000000..3f9e754
--- /dev/null
+++ b/puppet/mercy/manifests/params.pp~
@@ -0,0 +1,23 @@
+class mercy::params ( $environment,
+ $version,
+ $ensure,
+ $rabbitmq_uri,
+ # ---- Everything below is optional
+ $process_user => 'mercy',
+ $process_group => 'mercy',
+ $process_threads => 5,
+ $servername => $::fqdn,
+ $rabbitmq_user => 'mercy',
+ $rabbitmq_pw => 'mercy',
+ $rabbitmq_vhost => 'mercy',
+ $vhost_dir => '/etc/apache/httpd/conf.d',
+ $apache_service => 'httpd',
+ $port => 443,
+ $postgres_uri => 'localhost',
+ $postgres_user => 'mercy',
+ $postgres_pw => 'mercy',
+ $postgres_db => 'mercy'
+ )
+{
+
+}
diff --git a/puppet/mercy/templates/apache/vhost.erb b/puppet/mercy/templates/apache/vhost.erb
new file mode 100644
index 0000000..a47ec70
--- /dev/null
+++ b/puppet/mercy/templates/apache/vhost.erb
@@ -0,0 +1,12 @@
+>
+ ServerName <%= scope.lookupvar('::fqdn') %>
+ WSGIDaemonProcess mercy user=<%= scope.lookupvar('::mercy::process_user') %> group=<%= scope.lookupvar('::mercy::process_group') %> threads=<%= scope.lookupvar('::mercy::process_threads') %>
+ WSGIScriptAlias / /opt/mercy/scripts/mercy.wsgi
+
+
+ WSGIProcessGroup mercy
+ WSGIApplicationGroup %{GLOBAL}
+ Order deny, allow
+ Allow from all
+
+
\ No newline at end of file
diff --git a/puppet/mercy/templates/apache/vhost.erb~ b/puppet/mercy/templates/apache/vhost.erb~
new file mode 100644
index 0000000..ad3bc5f
--- /dev/null
+++ b/puppet/mercy/templates/apache/vhost.erb~
@@ -0,0 +1,12 @@
+>
+ ServerName <%= scope.lookupvar('::fqdn') %>
+ WSGIDaemonProcess mercy user=<%= scope.lookupvar('::mercy::params::process_user') %> group=<%= scope.lookupvar('::mercy::params::process_group') %> threads=<%= scope.lookupvar('::mercy::params::process_threads') %>
+ WSGIScriptAlias / /opt/mercy/scripts/mercy.wsgi
+
+
+ WSGIProcessGroup mercy
+ WSGIApplicationGroup %{GLOBAL}
+ Order deny, allow
+ Allow from all
+
+
\ No newline at end of file
diff --git a/puppet/mercy/templates/python/alembic.ini.erb b/puppet/mercy/templates/python/alembic.ini.erb
new file mode 100644
index 0000000..dafb558
--- /dev/null
+++ b/puppet/mercy/templates/python/alembic.ini.erb
@@ -0,0 +1,49 @@
+# A generic, single database configuration.
+
+[alembic]
+# path to migration scripts
+script_location = /opt/mercy/alembic
+
+# template used to generate migration files
+# file_template = %%(rev)s_%%(slug)s
+
+# set to 'true' to run the environment during
+# the 'revision' command, regardless of autogenerate
+# revision_environment = false
+
+sqlalchemy.url = postgresql://<%= scope.lookupvar('::mercy::postgres_user') %>:<%+ scope.lookupvar('::mercy::postgres_pw') %>@<%= scope.lookupvar('::mercy::postgres_uri') %>/<%= scope.lookupvar('::mercy::postgres_db') %>
+
+# Logging configuration
+[loggers]
+keys = root,sqlalchemy,alembic
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+qualname =
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+
+[logger_alembic]
+level = INFO
+handlers =
+qualname = alembic
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S
diff --git a/puppet/mercy/templates/python/alembic.ini.erb~ b/puppet/mercy/templates/python/alembic.ini.erb~
new file mode 100644
index 0000000..88a9e8a
--- /dev/null
+++ b/puppet/mercy/templates/python/alembic.ini.erb~
@@ -0,0 +1,49 @@
+# A generic, single database configuration.
+
+[alembic]
+# path to migration scripts
+script_location = alembic
+
+# template used to generate migration files
+# file_template = %%(rev)s_%%(slug)s
+
+# set to 'true' to run the environment during
+# the 'revision' command, regardless of autogenerate
+# revision_environment = false
+
+sqlalchemy.url = driver://mercy:mercy@postgresql.aklabs.net/mercy
+
+# Logging configuration
+[loggers]
+keys = root,sqlalchemy,alembic
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = WARN
+handlers = console
+qualname =
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+
+[logger_alembic]
+level = INFO
+handlers =
+qualname = alembic
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S
diff --git a/scripts/mercy.wsgi b/scripts/mercy.wsgi
new file mode 100644
index 0000000..7348088
--- /dev/null
+++ b/scripts/mercy.wsgi
@@ -0,0 +1,14 @@
+from mercy.MercyApplication import MercyApplication
+
+class ScriptNameStripper(object):
+ def __init__(self, app):
+ self.app = app
+
+ def __call_(self, environ, start_response):
+ environ['SCRIPT_NAME'] = ''
+ return self.app(environ, start_response)
+
+app = ScriptNameStripper(MercyApplication())
+
+if __name__ == "__main__":
+ app.run()