summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/Pipfile1
-rw-r--r--python/Pipfile.lock94
-rw-r--r--python/fatcat/__init__.py2
-rw-r--r--python/fatcat/routes.py28
-rw-r--r--python/tests/routes.py4
5 files changed, 72 insertions, 57 deletions
diff --git a/python/Pipfile b/python/Pipfile
index d60bf48f..a7e50535 100644
--- a/python/Pipfile
+++ b/python/Pipfile
@@ -22,6 +22,7 @@ raven = "*"
flask-sqlalchemy = "*"
marshmallow-sqlalchemy = "*"
flask-marshmallow = "*"
+flask-uuid = "*"
"psycopg2" = "*"
[requires]
diff --git a/python/Pipfile.lock b/python/Pipfile.lock
index 677cc5eb..c0eac84d 100644
--- a/python/Pipfile.lock
+++ b/python/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "ee7c7ec92727ff77576a3244fb2d9317e1c16a15eae26fdc1f21c8c8e3dcfa3a"
+ "sha256": "5e0d3c9c4d895c397638bba64cdeb20d752e309f927b5a435235c7e574ff4654"
},
"pipfile-spec": 6,
"requires": {
@@ -39,19 +39,19 @@
},
"flask": {
"hashes": [
- "sha256:0749df235e3ff61ac108f69ac178c9770caeaccad2509cb762ce1f65570a8856",
- "sha256:49f44461237b69ecd901cc7ce66feea0319b9158743dd27a2899962ab214dac1"
+ "sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48",
+ "sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05"
],
"index": "pypi",
- "version": "==0.12.2"
+ "version": "==1.0.2"
},
"flask-marshmallow": {
"hashes": [
- "sha256:7fefe98ba8088437e3cd940c813d2f71661da00f041826456cc1ae7c5250bf34",
- "sha256:d1457a8ee4cda662b121baacb22267774f3f7834e4adafae606b259bfbeb46b9"
+ "sha256:75c9d80f22af982b1e8ccec109d3b75c14bb5570602ae3705a4ff775badd2816",
+ "sha256:db7aff4130eb99fd05ab78fd2e2c58843ba0f208899aeb1c14aff9cd98ae8c80"
],
"index": "pypi",
- "version": "==0.8.0"
+ "version": "==0.9.0"
},
"flask-sqlalchemy": {
"hashes": [
@@ -61,6 +61,13 @@
"index": "pypi",
"version": "==2.3.2"
},
+ "flask-uuid": {
+ "hashes": [
+ "sha256:f9a8196eb896599ba9e74dcf713cfd1aca4669d418c19069e088620ae6294805"
+ ],
+ "index": "pypi",
+ "version": "==0.2"
+ },
"idna": {
"hashes": [
"sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",
@@ -89,10 +96,10 @@
},
"marshmallow": {
"hashes": [
- "sha256:8740ada95f47fa19f905772aa4932dc5512226a90c30da5672d6d6bf3dd791a7",
- "sha256:d3f31fe7be2106b1d783cbd0765ef4e1c6615505514695f33082805f929dd584"
+ "sha256:171f409d48b44786b7df2793cbd7f1a9062f0fe2c14d547da536b5010f671ade",
+ "sha256:c231784b5a5d2b26e50c90f3038004a3552ec27658cde6e0a5a7279d0c5a8e26"
],
- "version": "==2.15.0"
+ "version": "==2.15.3"
},
"marshmallow-sqlalchemy": {
"hashes": [
@@ -137,11 +144,11 @@
},
"raven": {
"hashes": [
- "sha256:e4edf648829a64234800a10ed94ca08e0b38592f7449fa5e70931db62f5cd851",
- "sha256:f908e9b39f02580e7f822030d119ed3b2e8d32300a2fec6373e5827d588bbae7"
+ "sha256:1c641e5ebc2d4185560608e253970ca0d4b98475f4edf67735015a415f9e1d48",
+ "sha256:95aecf76c414facaddbb056f3e98c7936318123e467728f2e50b3a66b65a6ef7"
],
"index": "pypi",
- "version": "==6.7.0"
+ "version": "==6.8.0"
},
"requests": {
"hashes": [
@@ -160,10 +167,10 @@
},
"sqlalchemy": {
"hashes": [
- "sha256:d6cda03b0187d6ed796ff70e87c9a7dce2c2c9650a7bc3c022cd331416853c31"
+ "sha256:2d5f08f714a886a1382c18be501e614bce50d362384dc089474019ce0768151c"
],
"index": "pypi",
- "version": "==1.2.7"
+ "version": "==1.2.8"
},
"urllib3": {
"hashes": [
@@ -183,17 +190,24 @@
"develop": {
"astroid": {
"hashes": [
- "sha256:35cfae47aac19c7b407b7095410e895e836f2285ccf1220336afba744cc4c5f2",
- "sha256:38186e481b65877fd8b1f9acc33e922109e983eb7b6e487bd4c71002134ad331"
+ "sha256:032f6e09161e96f417ea7fad46d3fac7a9019c775f202182c22df0e4f714cb1c",
+ "sha256:dea42ae6e0b789b543f728ddae7ddb6740ba33a49fb52c4a4d9cb7bb4aa6ec09"
],
- "version": "==1.6.3"
+ "version": "==1.6.4"
+ },
+ "atomicwrites": {
+ "hashes": [
+ "sha256:240831ea22da9ab882b551b31d4225591e5e447a68c5e188db5b89ca1d487585",
+ "sha256:a24da68318b08ac9c9c45029f4a10371ab5b20e4226738e150e6e7c571630ae6"
+ ],
+ "version": "==1.1.5"
},
"attrs": {
"hashes": [
- "sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9",
- "sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450"
+ "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265",
+ "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b"
],
- "version": "==17.4.0"
+ "version": "==18.1.0"
},
"backcall": {
"hashes": [
@@ -286,11 +300,11 @@
},
"flask": {
"hashes": [
- "sha256:0749df235e3ff61ac108f69ac178c9770caeaccad2509cb762ce1f65570a8856",
- "sha256:49f44461237b69ecd901cc7ce66feea0319b9158743dd27a2899962ab214dac1"
+ "sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48",
+ "sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05"
],
"index": "pypi",
- "version": "==0.12.2"
+ "version": "==1.0.2"
},
"flask-debugtoolbar": {
"hashes": [
@@ -309,11 +323,11 @@
},
"ipython": {
"hashes": [
- "sha256:85882f97d75122ff8cdfe129215a408085a26039527110c8d4a2b8a5e45b7639",
- "sha256:a6ac981381b3f5f604b37a293369963485200e3639fb0404fa76092383c10c41"
+ "sha256:a0c96853549b246991046f32d19db7140f5b1a644cc31f0dc1edc86713b7676f",
+ "sha256:eca537aa61592aca2fef4adea12af8e42f5c335004dfa80c78caf80e8b525e5c"
],
"index": "pypi",
- "version": "==6.3.1"
+ "version": "==6.4.0"
},
"ipython-genutils": {
"hashes": [
@@ -399,18 +413,18 @@
},
"more-itertools": {
"hashes": [
- "sha256:0dd8f72eeab0d2c3bd489025bb2f6a1b8342f9b198f6fc37b52d15cfa4531fea",
- "sha256:11a625025954c20145b37ff6309cd54e39ca94f72f6bb9576d1195db6fa2442e",
- "sha256:c9ce7eccdcb901a2c75d326ea134e0886abfbea5f93e91cc95de9507c0816c44"
+ "sha256:2b6b9893337bfd9166bee6a62c2b0c9fe7735dcf85948b387ec8cba30e85d8e8",
+ "sha256:6703844a52d3588f951883005efcf555e49566a48afd4db4e965d69b883980d3",
+ "sha256:a18d870ef2ffca2b8463c0070ad17b5978056f403fb64e3f15fe62a52db21cc0"
],
- "version": "==4.1.0"
+ "version": "==4.2.0"
},
"parso": {
"hashes": [
- "sha256:62bd6bf7f04ab5c817704ff513ef175328676471bdef3629d4bdd46626f75551",
- "sha256:a75a304d7090d2c67bd298091c14ef9d3d560e3c53de1c239617889f61d1d307"
+ "sha256:cdef26e8adc10d589f3ec4eb444bd0a29f3f1eb6d72a4292ab8afcb9d68976a6",
+ "sha256:f0604a40b96e062b0fd99cf134cc2d5cdf66939d0902f8267d938b0d5b26707f"
],
- "version": "==0.2.0"
+ "version": "==0.2.1"
},
"pexpect": {
"hashes": [
@@ -506,19 +520,19 @@
},
"pylint": {
"hashes": [
- "sha256:0b7e6b5d9f1d4e0b554b5d948f14ed7969e8cdf9a0120853e6e5af60813b18ab",
- "sha256:34738a82ab33cbd3bb6cd4cef823dbcabdd2b6b48a4e3a3054a2bbbf0c712be9"
+ "sha256:aa519865f8890a5905fa34924fed0f3bfc7d84fc9f9142c16dac52ffecd25a39",
+ "sha256:c353d8225195b37cc3aef18248b8f3fe94c5a6a95affaf885ae21a24ca31d8eb"
],
"index": "pypi",
- "version": "==1.8.4"
+ "version": "==1.9.1"
},
"pytest": {
"hashes": [
- "sha256:54713b26c97538db6ff0703a12b19aeaeb60b5e599de542e7fca0ec83b9038e8",
- "sha256:829230122facf05a5f81a6d4dfe6454a04978ea3746853b2b84567ecf8e5c526"
+ "sha256:39555d023af3200d004d09e51b4dd9fdd828baa863cded3fd6ba2f29f757ae2d",
+ "sha256:c76e93f3145a44812955e8d46cdd302d8a45fbfc7bf22be24fe231f9d8d8853a"
],
"index": "pypi",
- "version": "==3.5.1"
+ "version": "==3.6.0"
},
"pytest-cov": {
"hashes": [
diff --git a/python/fatcat/__init__.py b/python/fatcat/__init__.py
index 6a7f4620..aa12f972 100644
--- a/python/fatcat/__init__.py
+++ b/python/fatcat/__init__.py
@@ -1,5 +1,6 @@
from flask import Flask
+from flask_uuid import FlaskUUID
from flask_debugtoolbar import DebugToolbarExtension
from config import Config
import fatcat_client
@@ -8,6 +9,7 @@ toolbar = DebugToolbarExtension()
app = Flask(__name__)
app.config.from_object(Config)
toolbar = DebugToolbarExtension(app)
+FlaskUUID(app)
conf = fatcat_client.Configuration()
conf.host = "http://localhost:9411/v0"
diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py
index a7a2081f..a3d4d4ee 100644
--- a/python/fatcat/routes.py
+++ b/python/fatcat/routes.py
@@ -10,10 +10,10 @@ from fatcat_client.rest import ApiException
### Views ###################################################################
-@app.route('/container/<ident>', methods=['GET'])
+@app.route('/container/<uuid:ident>', methods=['GET'])
def container_view(ident):
try:
- entity = api.get_container(ident)
+ entity = api.get_container(str(ident))
except ApiException as ae:
abort(ae.status)
return render_template('container_view.html', container=entity)
@@ -36,10 +36,10 @@ def container_create():
edit = api.create_container(params=params)
return redirect("/container/{}".format(edit.ident))
-@app.route('/creator/<ident>', methods=['GET'])
+@app.route('/creator/<uuid:ident>', methods=['GET'])
def creator_view(ident):
try:
- entity = api.get_creator(ident)
+ entity = api.get_creator(str(ident))
except ApiException as ae:
abort(ae.status)
return render_template('creator_view.html', creator=entity)
@@ -49,10 +49,10 @@ def creator_random():
"""Not actually random, just a dummy example"""
return redirect("/creator/00000000-0000-0000-2222-000000000002")
-@app.route('/file/<ident>', methods=['GET'])
+@app.route('/file/<uuid:ident>', methods=['GET'])
def file_view(ident):
try:
- entity = api.get_file(ident)
+ entity = api.get_file(str(ident))
except ApiException as ae:
abort(ae.status)
return render_template('file_view.html', file=entity)
@@ -62,10 +62,10 @@ def file_random():
"""Not actually random, just a dummy example"""
return redirect("/file/00000000-0000-0000-3333-000000000002")
-@app.route('/release/<ident>', methods=['GET'])
+@app.route('/release/<uuid:ident>', methods=['GET'])
def release_view(ident):
try:
- entity = api.get_release(ident)
+ entity = api.get_release(str(ident))
except ApiException as ae:
abort(ae.status)
return render_template('release_view.html', release=entity)
@@ -75,23 +75,23 @@ def release_random():
"""Not actually random, just a dummy example"""
return redirect("/release/00000000-0000-0000-4444-000000000002")
-#@app.route('/release/<ident>/changelog', methods=['GET'])
+#@app.route('/release/<uuid:ident>/changelog', methods=['GET'])
#def release_changelog(ident):
# try:
-# entity = api.get_release(ident)
+# entity = api.get_release(str(ident))
# except ApiException as ae:
# abort(ae.status)
# try:
-# entries = api.release_changelog(ident)
+# entries = api.release_changelog(str(ident))
# except ApiException as ae:
# abort(ae.status)
# return render_template('release_changelog.html', release=entity,
# changelog_entries=entries)
-@app.route('/work/<ident>', methods=['GET'])
+@app.route('/work/<uuid:ident>', methods=['GET'])
def work_view(ident):
try:
- entity = api.get_work(ident)
+ entity = api.get_work(str(ident))
except ApiException as ae:
abort(ae.status)
return render_template('work_view.html', work=entity)
@@ -108,7 +108,7 @@ def work_create():
@app.route('/editgroup/<int:ident>', methods=['GET'])
def editgroup_view(ident):
try:
- entity = api.get_editgroup(ident)
+ entity = api.get_editgroup(str(ident))
except ApiException as ae:
print(ae.body)
abort(ae.status)
diff --git a/python/tests/routes.py b/python/tests/routes.py
index e11d024e..b4fb506c 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -18,10 +18,8 @@ def test_static_routes(app):
def test_all_views(app):
for route in ('work', 'release', 'creator', 'container', 'file'):
print(route)
- #with pytest.raises(ApiException) as api_fail:
- # rv = app.get('/{}/999999999999'.format(route))
rv = app.get('/{}/9999999999'.format(route))
- assert rv.status_code == 400
+ assert rv.status_code == 404
rv = app.get('/{}/f1f046a3-45c9-ffff-ffff-ffffffffffff'.format(route))
assert rv.status_code == 404